Code Monkey home page Code Monkey logo

sofa-rpc-boot-projects's Introduction

The code has been migrated to rpc-sofa-boot-starter since SOFABoot v3.2.0, this project will be archived and stop maintenance.

SOFARPC Boot Projects

Build Status Coverage Status License Release

概述

rpc-sofa-boot-starter

SOFABoot 是一个完全兼容 SpringBoot 的开发框架,rpc-sofa-boot-starter 的作用就是将 SOFARPC 功能集成到 SOFABoot 中。rpc-sofa-boot-starter 提供了统一方便的编程界面、配置方式,同时提供了 SOFABoot 的健康检查,类隔离,日志空间隔离等基础能力。

rpc-sofa-boot-samples

用户使用 rpc-sofa-boot-starter 的例子。

功能特性

  • 支持多种协议的服务发布和引用
  • 支持同步、单向、回调、泛化等多种调用方式
  • 支持自定义Filter
  • 支持服务预热
  • 支持直连路由策略
  • 支持自动故障隔离
  • 支持自定义线程池
  • 支持多种注册中心的选择

构建

编译需要 JDK 8 及以上、Maven 3.2.5 及以上。

文档

贡献

如何参与代码贡献

开源许可

基于 Apache License 2.0 协议。

sofa-rpc-boot-projects's People

Contributors

glmapper avatar jervyshi avatar khotyn avatar leizhiyuan avatar negnail avatar qilongzhang avatar scienjus avatar ujjboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sofa-rpc-boot-projects's Issues

support consul registry convertor

Your question

support consul registry convertor

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

服务配置多协议发布,健康检查出错

Describe the bug

多协议发布
<sofa:service ref="restServiceImpl" interface="com.jsmfbank.sse.facade.RestService">
sofa:binding.bolt/
sofa:binding.rest/
</sofa:service>

健康检查结果:
{
"status":"DOWN",
"sofaBootComponentHealthCheckInfo":{
"status":"DOWN",
"Middleware":{
"RUNTIME-COMPONENT":{
"status":"DOWN",
"reference:com.jsmfbank.sse.facade.HelloService:#1490387169":"passed",
"reference:com.jsmfbank.sse.facade.RestService:#-486687820":"passed",
"service:com.jsmfbank.sse.facade.HelloService":"passed",
"service:com.jsmfbank.sse.facade.RestService":"Status: RESOLVED"
}
}
},
"springContextHealthCheckInfo":{
"status":"UP"
},
"diskSpace":{
"status":"UP",
"total":499963170816,
"free":406920048640,
"threshold":10485760
}
}

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

REST协议的服务如何实现跨域拦截?

Describe the bug

在RESTful协议做服务的时候,我们增加了跨域请求的拦截起功能, 但是不走我们的拦截起, 请帮忙看看这个问题,谢谢!

代码如下:
@Provider
public class CommonContainerResponseFilter extends CorsFilter {

@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
    String origin = requestContext.getHeaderString(CorsHeaders.ORIGIN);

    if (origin == null || requestContext.getProperty("cors.failure") != null) {
        // don't do anything if origin is null, its an OPTIONS request, or cors.failure is set
        return;
    }

    responseContext.getHeaders().putSingle(CorsHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, origin);
    responseContext.getHeaders().putSingle(CorsHeaders.ACCESS_CONTROL_ALLOW_METHODS, "*");
    StringBuilder allowHeaders = new StringBuilder();
    MultivaluedMap<String, String> headers = requestContext.getHeaders();
    for (String headerKey : headers.keySet()) {
        allowHeaders.append(headerKey).append(",");
    }
    responseContext.getHeaders().putSingle(CorsHeaders.ACCESS_CONTROL_ALLOW_HEADERS, allowHeaders.toString());


    if (allowCredentials) {
        responseContext.getHeaders().putSingle(CorsHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
    }

    if (exposedHeaders != null) {
        responseContext.getHeaders().putSingle(CorsHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, exposedHeaders);
    }
}

public void setAllowedOrigins(Set allowedOrigins) {
this.allowedOrigins = allowedOrigins;
}

}

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

请问是否支持consul注册中心

Your question

请问是否支持consul注册中心,如果配置使用?

Your scenes

Your advice

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

Support context path setting of rest.

Your question

See more: sofastack/sofa-boot#77

Your advice

  • Add context path parameter for rest in com.alipay.sofa.rpc.boot.config.SofaBootRpcProperties
  • Set value to ServerConfig with setContextPath() in com.alipay.sofa.rpc.boot.container.ServerConfigContainer#createRestServerConfig

Environment

  • Starter version: 5.3.2

sofaboot客户端不同版本使用api方式引用的问题

Your question

describe your question clearly
客户端使用5.3.2版本api方式引用,终端(控制台)可以正常停止,使用5.4.2 终端(控制台)不能正常停止
ConsumerConfig consumerConfig = new ConsumerConfig()
.setInterfaceId(IdCardVerifyFacade.class.getName()) // 指定接口
.setProtocol("rest") // 指定协议
.setDirectUrl("rest:// ip:port")//
.setConnectTimeout(2000); // 指定直连地址

	IdCardVerifyFacade f = consumerConfig.refer();
	
	IdCardVerifyRequest r = new IdCardVerifyRequest();
	r.setName("");
	r.setIdCard("");
	Result<IdCardVerify> result = f.verify(r);
	System.out.println(JSON.toJSONString(result));

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
com.alipay.sofa sofa-rpc-all 5.4.2 com.alibaba fastjson 1.2.0 org.apache.httpcomponents httpclient 4.4
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-context</artifactId>
	    <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-core</artifactId>
	    <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-web</artifactId>
	    <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-webmvc</artifactId>
	   <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-beans</artifactId>
	   <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>com.fasterxml.jackson.core</groupId>
	    <artifactId>jackson-core</artifactId>
	    <version>2.9.0</version>
	</dependency>
	<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.9.0</version>
</dependency>
  • IDE version:

support multi network interface ip

Your question

support multi network interface ip

Your scenes

machine has multi network interfaces

Your advice

ServerConfig .setHost can solve.

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

Improve callback class set API in RpcBindingParam

SOFARPC provide a method in RpcBindingParam for users to set callback class when users use callback invocation type, but the method accept a String as type:

public void setCallbackClass(String callbackClass) {
}

We should improve this method to a more strong typed method, such as

public void setCallbackClass(Class<? extends SofaResponseCallback> callbackClass) {
}

so users are less likely to make mistakes.

LoadBalance annotation的支持

Your question

请问LoadBalance是否支持annotation版本

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

adapte to SOFABoot 3.0 which depends on Spring Boot 3.0

Your question

adapte to SOFABoot 3.0 which depends on Spring Boot 3.0, we change version to 3.x

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

api方式引用带有数据校验的接口抛异常

Your question

describe your question clearly
sofaboot服务端发布带有数据校验的服务,在客户端以api方式引用抛异常。
服务端接口
@post
@path("/verify")
public Result verify(@Valid IdCardVerifyRequest idCardVerifyRequest);
全局数据验证异常处理
public class SimpleValidationExceptionMapper implements ExceptionMapper {

public static final Logger logger = LoggerFactory.getLogger(SimpleValidationExceptionMapper.class);

/* (non-Javadoc)
 * @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable)
 */
@Override
public Response toResponse(ResteasyViolationException exception) {
	List<String> list = new ArrayList<String>();
	Set<ConstraintViolation<?>> set = exception.getConstraintViolations();
	for(ConstraintViolation<?> cv : set) {
		list.add(cv.getMessage());
	}
	
	logger.warn("数据验证失败:{}",JSON.toJSONString(list));
	
	int code = Integer.parseInt(CodeMsgEnum.VALIDATE_FAILURE.getCode());
	return Response.status(code).entity(list).build();
}

}
客户端引用
ConsumerConfig consumerConfig = new ConsumerConfig()
.setInterfaceId(IdCardVerifyFacade.class.getName()) // 指定接口
.setProtocol("rest") // 指定协议
.setDirectUrl("rest://88.251.24.187:9999")//
.setConnectTimeout(2000); // 指定直连地址

	IdCardVerifyFacade f = consumerConfig.refer();
	
	IdCardVerifyRequest r = new IdCardVerifyRequest();
	r.setName("");
	r.setIdCard("");
	Result<IdCardVerify> result = f.verify(r);
	System.out.println(JSON.toJSONString(result));

运行结果
Exception in thread "main" com.alipay.sofa.rpc.core.exception.SofaRpcException: Send message to remote catch error: HTTP 409 Conflict
at com.alipay.sofa.rpc.transport.AbstractProxyClientTransport.convertToRpcException(AbstractProxyClientTransport.java:233)
at com.alipay.sofa.rpc.transport.AbstractProxyClientTransport.syncSend(AbstractProxyClientTransport.java:156)
at com.alipay.sofa.rpc.client.AbstractCluster.doSendMsg(AbstractCluster.java:509)
at com.alipay.sofa.rpc.client.AbstractCluster.sendMsg(AbstractCluster.java:480)
at com.alipay.sofa.rpc.filter.ConsumerInvoker.invoke(ConsumerInvoker.java:60)
at com.alipay.sofa.rpc.filter.RpcReferenceContextFilter.invoke(RpcReferenceContextFilter.java:80)
at com.alipay.sofa.rpc.filter.FilterInvoker.invoke(FilterInvoker.java:96)
at com.alipay.sofa.rpc.filter.ConsumerExceptionFilter.invoke(ConsumerExceptionFilter.java:37)
at com.alipay.sofa.rpc.filter.FilterInvoker.invoke(FilterInvoker.java:96)
at com.alipay.sofa.rpc.filter.FilterChain.invoke(FilterChain.java:299)
at com.alipay.sofa.rpc.client.AbstractCluster.filterChain(AbstractCluster.java:473)
at com.alipay.sofa.rpc.client.FailoverCluster.doInvoke(FailoverCluster.java:66)
at com.alipay.sofa.rpc.client.AbstractCluster.invoke(AbstractCluster.java:286)
at com.alipay.sofa.rpc.client.ClientProxyInvoker.invoke(ClientProxyInvoker.java:83)
at com.alipay.sofa.rpc.proxy.jdk.JDKInvocationHandler.invoke(JDKInvocationHandler.java:75)
at com.sun.proxy.$Proxy22.verify(Unknown Source)
at com.mfbank.service.MainC.main(MainC.java:40)
Caused by: javax.ws.rs.ClientErrorException: HTTP 409 Conflict
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.handleErrorStatus(ClientInvocation.java:216)
at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.extractResult(ClientInvocation.java:174)
at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.BodyEntityExtractor.extractEntity(BodyEntityExtractor.java:58)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:104)
at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:62)
at com.sun.proxy.$Proxy22.verify(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.alipay.sofa.rpc.transport.AbstractProxyClientTransport.doInvokeSync(AbstractProxyClientTransport.java:183)
at com.alipay.sofa.rpc.transport.AbstractProxyClientTransport.syncSend(AbstractProxyClientTransport.java:154)
... 15 more

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
com.alipay.sofa sofa-rpc-all 5.3.2 com.alibaba fastjson 1.2.0 org.apache.httpcomponents httpclient 4.4
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-context</artifactId>
	    <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-core</artifactId>
	    <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-web</artifactId>
	    <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-webmvc</artifactId>
	   <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-beans</artifactId>
	   <version>4.3.4.RELEASE</version>
	</dependency>
	<dependency>
	    <groupId>com.fasterxml.jackson.core</groupId>
	    <artifactId>jackson-core</artifactId>
	    <version>2.9.0</version>
	</dependency>
	<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.9.0</version>
</dependency>
- IDE version:

starter 配置转换问题

com.alipay.sofa.rpc.boot.container.ServerConfigContainer#createBoltServerConfig

转换的时候,遗漏了对 bolt 服务端队列的设置. 需要补充.其他的转换点

关于restful风格的一些疑问

我尝试使用rpc-sofa-boot-starter启动依赖,参考rpc-sofa-boot-samples项目,使用restful风格方式,代码分为server和client,目前本地项目可正常启动,但是访问client端调用服务会报java.lang.IllegalArgumentException: You did not supply enough values to fill path parameters

我有几点疑惑关于rpc-sofa-boot-starter:
1.采用restful风格,服务端提供的服务是注册进入zookeeper了么?
2.可否有控制台来查看维护的服务列表。
3.针对其他非sofa服务,能否与服务端实现连接
4.xml配置不太好看,可否改为类初始化
项目提交到https://github.com/renshihan/sofa-boot-study.git,

关于sofa-boot配置的疑问

您好,我按照快速入门的教程配置完后,报的
“om.example.demo.HelloSyncService:1.0]的调用地址,请检查服务是否已经推送”'这个错误,反复按照教程配了好几遍,还是不行。。。请问您对这个问题有没有解决的思路或者一点提示?非常感谢~

support serialization type setting

Your question

support serialization type setting

Your scenes

support serialization type setting

Your advice

support serialization type setting

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

A bug that refers to the same service in multiple protocols at runtime.

For example:

    <sofa:reference id="lazyServiceReferenceBolt" interface="com.alipay.sofa.rpc.samples.lazy.LazyService">
        <sofa:binding.bolt/>
    </sofa:reference>

    <sofa:reference id="lazyServiceReferenceDubbo" interface="com.alipay.sofa.rpc.samples.lazy.LazyService">
        <sofa:binding.dubbo/>
    </sofa:reference>

Because the same service is referenced by the bolt and the dubbo protocol, the startup is in an infinite wait.

关于使用@SofaReference的问题

在使用@SofaReference的客户端来引用RPC服务,使用方式如下:
@SofaReference(interfaceType = HelloSyncService.class,
binding = @SofaReferenceBinding(bindingType = "bolt",invokeType = "sync"))
private HelloSyncService helloSyncService;

但是在调试过程中发现ConsumerConfigHelper中getConsumerConfig时,
String type = param.getType();
if (StringUtils.hasText(type)) {
consumerConfig.setInvokeType(type);
}
发现consumerConfig的invokeType发生了改变,变成了BOLT,导致后续报错,请问我这是否有问题

动态绑定DynamicFeature未生效

Your question

在DynamicFeature接口实现类加上@Provider注解 ,但启动时未调用DynamicFeature接口的configure方法。
@Provider
@ConstrainedTo(RuntimeType.SERVER)
public class ApiMetricsFeature implements DynamicFeature

在DynamicFeature实现类初始化之后, 实现InitializingBean接口,在afterPropertiesSet调用JAXRSProviderManager.registerCustomProviderInstance(this)也未触发调用configure

单步跟DynamicFeature实现类初始化在registerProvider之后才调用到,系统已经初始化完Provider,此时再registerCustomProviderInstance实际并没有效果,求解

Environment

  • Starter version:2.5.0
  • JVM version (e.g. java -version):1.8

reform RegistryConfigContainer

Your question

reform RegistryConfigContainer to support custom registry

now we set registry like this

com.alipay.sofa.rpc.registry.address

so we only can have one registry in one application,

in sofa:reference we can set registry for every consumer and provider
then when we translate to consumerconfig,we set to it

Your scenes

com.alipay.sofa.rpc.registry.alias[zk1]=xxx:11
com.alipay.sofa.rpc.registry.alias[zk2]=xxx:11

they can set
<sofa:reference registry="zk1,zk2" />
<sofa:reference registry="zk1,default" /> if default,will use com.alipay.sofa.rpc.registry.address as default

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

switch master to 6.x and create a new branch for 5.x

Your question

  1. complete all issues about 6.x branch
  2. create a brach 5.x from master
  3. merge 6.x to master
  4. delete 6.x branch
  5. change readme

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

SofaBoot RPC demo 不能正常工作

Your question

按照https://github.com/alipay/sofa-rpc-boot-projects/wiki/GettingStarted,搭建项目并设置相关配置,
当直接run整个application时,会提示下边的SofaRouteException
Exception in thread "main" com.alipay.sofa.rpc.core.exception.SofaRouteException: RPC-02306: 没有获得服务[com.example.demo.Service.HelloSyncService:1.0]的调用地址,请检查服务是否已经推送
at com.alipay.sofa.rpc.client.AbstractCluster.noAvailableProviderException(AbstractCluster.java:419)
at com.alipay.sofa.rpc.client.AbstractCluster.select(AbstractCluster.java:391)
at com.alipay.sofa.rpc.client.FailoverCluster.doInvoke(FailoverCluster.java:64)
at com.alipay.sofa.rpc.client.AbstractCluster.invoke(AbstractCluster.java:286)
at com.alipay.sofa.rpc.client.ClientProxyInvoker.invoke(ClientProxyInvoker.java:83)
at com.alipay.sofa.rpc.proxy.jdk.JDKInvocationHandler.invoke(JDKInvocationHandler.java:74)
at com.sun.proxy.$Proxy52.saySync(Unknown Source)
at com.example.demo.DemoApplication.main(DemoApplication.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
但是当在main函数的 System.out.println(helloSyncServiceReference.saySync("sync"));所对应的行打断点进行调试时 最终能够正确返回saySync函数所对应的结果?所以想问下你们在实现demo的时候有没有遇到过类似的问题

`
public static void main(String[] args) throws Exception{

	SpringApplication springApplication = new SpringApplication(DemoApplication.class);

	ApplicationContext applicationContext = springApplication.run(args);

	HelloSyncService helloSyncServiceReference = (HelloSyncService) applicationContext
			.getBean("helloSyncServiceReference")

	System.out.println(helloSyncServiceReference.saySync("sync"));

}
`

Environment

  • Starter version: sofa boot parent:2.3.1
  • JVM version (e.g. java -version): 1.8.0_77
  • OS version (e.g. uname -a): WIN7
  • Maven version: 3.3.9
  • IDE version: IDEA 16.3

希望能提供基于spring boot environment 的测试服务直连选项

Your question

目前 SOFA-RPC 提供了基于注解的直连参数配置方式 ,但是这种方式对于 artifact jar 来说不太友好,需要重新构建才能测试。 我认为 spring boot 的环境变量策略就是一个比较好的方法。

由于SOFA的服务是以接口类为单位的,希望能有类似于logging.level一样的配置方法,以 application.yaml 为例:

com.alipay.sofa.rpc:
    ref:
        com.some.clazz.DemoService: bolt://127.0.0.1:9999
        com.some.pkg: bolt://127.0.0.1:10000

这样针对不同的包服务或者特定的类服务,就能简单的指定直连测试的地址。

对已经生成的 artifact jar 而言,也可以简单的通过修改启动参数的方式进行直连测试

java -jar my-demo-app.jar \
    --com.alipay.sofa.rpc.ref.com.some.pkg=bolt://10.1.34.68:12200 \
    --com.alipay.sofa.rpc.ref.com.some.clazz.DemoService=bolt://10.1.34.68:12201

还有 com.alipay.sofa 感觉有点长,yaml里面用着怪怪的,改短点有商量么?

Environment

  • Starter version: new feature
  • JVM version (e.g. java -version): 1.8+
  • OS version (e.g. uname -a): any
  • Maven version: 3.2.0+
  • IDE version: idea/eclipse

使用java -jar启动项目的jar包,访问非常缓慢

Your question

测试demo,达成jar包后运行,访问rest服务发现非常缓慢,一个demo的service都需要5s,请帮忙这个是什么问题?

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

集成spring-cloud-starter-consul-discovery的健康检查报错问题

Your question

集成spring-cloud-starter-consul-discovery的健康检查报错, 健康检查内容如下:
{"status":"DOWN","ConsulHealthIndicator":{"status":"DOWN","services":{"consul":[],"consul-server":["dev"],"spring-boot-sse":[],"webapi":["dev"]},"error":"java.lang.IllegalArgumentException: Value must not be null"},"sofaBootComponentHealthCheckInfo":{"status":"DOWN","Middleware-start-period":{"RUNTIME-COMPONENT":{"status":"UP","service:com.jsmfbank.sse.facade.RestService":"passed","reference:com.jsmfbank.sse.facade.RestService:#-2144235840":"passed"}}},"springContextHealthCheckInfo":{"status":"UP"},"DiskSpaceHealthIndicator":{"status":"UP","total":499963170816,"free":365070671872,"threshold":10485760},"RefreshScopeHealthIndicator":{"status":"UP"}}

spring-cloud-starter-consul-discovery版本是1.2.3.RELEASE

请帮忙看看这是什么问题,谢谢

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

discuss process way when getSpringBean occurs an exception

just like

 /**
     * 根据配置的ref获得真正的spring bean
     *
     *
     * @param beanRef            spring ref
     * @param applicationContext spring上下文
     * @param appClassLoader     业务上下文
     * @return 业务bean
     */
    public static Object getSpringBean(String beanRef,
                                       ApplicationContext applicationContext,
                                       ClassLoader appClassLoader,
                                       String appName) {
        Object object = null;

        if (StringUtils.hasText(beanRef)) {
            if (applicationContext == null) {
                LOGGER.error("get bean from spring failed. beanRef[" + beanRef + "];classLoader[" + appClassLoader +
                    "];appName[" + appName + "]");
            } else {
                object = applicationContext.getBean(beanRef);
            }
        }

        return object;
    }

I think when applicationContext == null we should throw an exception, but not only print a log.

allow user custom server config

Your question

describe your question clearly

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

Fix possible failure during startup when depends on rpc starter alone in project.

java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

	at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:161)
	at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:225)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:88)
	at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:58)
	at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
	at com.alipay.test.embeded.sofa.EmbeddedContextInitializerTest.init(EmbeddedContextInitializerTest.java:43)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)

As the dependency of commons-logging is removed at PR #97 . Actually, we should add jcl-over-slf4j.

sofa boot rest开发实现ContainerRequestFilter接口过滤器未生效

Your question

在ContainerRequestFilter接口实现类加上@Provider和@PreMatching注解 ,配置文件中加上bean过滤器未生效
我采用的是2.3.2版本

@Provider
@PreMatching
public class LoginFilter implements ContainerRequestFilter{

@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
	System.out.println("============requestContext=====s=s=s=s=s=s==");
	 String methodOverride = requestContext.getHeaderString("X-Http-Method-Override");
    if (methodOverride != null) requestContext.setMethod(methodOverride);
	System.out.println("============requestContext=====s=s=s=s=s=s==");
}

}
求解

sofaboot能否集成到spring

Your question

describe your question clearly
sofaboot发布了服务,能否在spring中以xml方式引用?如果可以在spring需要引入哪些包或能否提供一个demo

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

我把服务分开在两个项目里部署无法正常调用,类型转换问题

我把service和reference分开在两个项目里,在reference中从springApplicationContext中获取对象时无法获取真正对象实际为一个代理对象,java.lang.ClassCastException: com.sun.proxy.$Proxy83 cannot
reference.xml
<sofa:reference id="restServiceReference" interface="com.ali.rest.RestService"> <sofa:binding.rest /> </sofa:reference>
service.xml
<bean id="restServiceImpl" class="com.ali.rest.impl.RestServiceImpl" /> <sofa:service ref="restServiceImpl" interface="com.ali.rest.RestService"> <sofa:binding.rest /> </sofa:service>
获取代码如下:
SpringApplication app = new SpringApplication(RpcConsumerApplication.class); ConfigurableApplicationContext applicationContext = app.run(args); Object obj =applicationContext.getBean("restServiceReference"); //class com.sun.proxy.$Proxy83 com.ali.rest.RestService:1.0

provider应用重启后 consumer连接不上

Your question

1.首先我是本地两个应用 分别是QuickStartServer,QuickStartClient ,注册中心用的是zookeeper
2.启动QuickStartServer
3.启动QuickStartClient
4.运行一段时间后关闭QuickStartServer并重启QuickStartServer
使用的是bolt协议
sofaboot-dependencies 2.4.0|rpc-sofa-boot-starter
jdk1.8
Idea debug模式
重启server后的client的提示信息如下
2018-06-14 09:42:58.665 WARN 5156 --- [rker-1-thread-1] c.a.remoting.DefaultConnectionManager : Remove and close the last connection in ConnectionPool with poolKey 172.16.249.78:12200
client访问结果如下
{
"success": false,
"message": "RPC-02306: 没有获得服务[com.ransyh.rpc.service.integral.IIntegralService:1.0]的调用地址,请检查服务是否已经推送 ",
"result": null,
"code": "210"
}

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • Starter version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

SpringBoot 2.0 can not use underscore with lower case letters

Describe the bug

after upgrade to spring 2.0

com.alipay.sofa.rpc.boot.config.SofaBootRpcPropertiesTest#testUnderscoreConfig

this case will fail because spring boot 2.0 cannot use this style now.

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-relaxed-binding

if we use os environment ,

we should use

"COM_ALIPAY_SOFA_RPC_BOLT_THREAD_POOL_MAX_SIZE=600"

but this is a compatible style ,we cannot change these settings of users。 so will it an incompatible change in this version?

or we can add

    private String getUnderScoreString(String enclosingMethodName) {
        if (environment == null) {
            return null;
        }
        return environment.getProperty(PREFIX + "_" + camelToUndre(enclosingMethodName.substring(3)));
    }

to achieve this?

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • Starter version: 3.0.0
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

Global filter does not work

<bean class="com.alipay.sofa.rpc.bean.SampleGlobalFilter" id="sampleGlobalFilter"/>
<sofa:rpc-global-filter ref="sampleGlobalFilter"/>

Such a global filter does not work.

sofa-boot中支持哪几种全局配置?

是否支持注解方式获取配置文件application.properties中配置项?
是否支持全局日志级别的配置,如在application.properties增加日志级别为info

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.