Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
定义了IntegrationFlow的Spring Integration Java DSL-响应中缺少数据和不匹配的CorrelationID_Java_Spring_Spring Integration_Spring Integration Dsl - Fatal编程技术网

定义了IntegrationFlow的Spring Integration Java DSL-响应中缺少数据和不匹配的CorrelationID

定义了IntegrationFlow的Spring Integration Java DSL-响应中缺少数据和不匹配的CorrelationID,java,spring,spring-integration,spring-integration-dsl,Java,Spring,Spring Integration,Spring Integration Dsl,我正在使用SpringIntegrationJavaDSL和定义的IntegrationFlow。我看到响应缺少数据块,聚合器响应中的correlationId与调用服务接收的响应中的值不匹配 背景: 我在使用随机数据的服务器上运行了一个JMeter性能测试,该测试以每分钟600个请求的速度运行。在我的笔记本电脑上,我有一个SoapUI性能测试正在运行,它会访问同一台服务器。SoapUI项目以每分钟60个请求的速率发送具有相同搜索条件的请求(我们正在进行匹配)。所有响应都应包含相同的结果数据 大

我正在使用SpringIntegrationJavaDSL和定义的IntegrationFlow。我看到响应缺少数据块,聚合器响应中的correlationId与调用服务接收的响应中的值不匹配

背景:

我在使用随机数据的服务器上运行了一个JMeter性能测试,该测试以每分钟600个请求的速度运行。在我的笔记本电脑上,我有一个SoapUI性能测试正在运行,它会访问同一台服务器。SoapUI项目以每分钟60个请求的速率发送具有相同搜索条件的请求(我们正在进行匹配)。所有响应都应包含相同的结果数据

大约有0.5%的时间返回缺少数据的响应。在这些响应中,从聚合器记录的响应的correlationId与从调用服务记录的响应的correlationId(在响应返回到调用服务并已通过聚合器后记录)不匹配

你知道怎么了吗?请参阅下面的代码片段

@Configuration
@EnableAutoConfiguration
@Import(.....AServiceConfig.class)
public class ServiceConfig {

@Bean(name = "inputChannel")
public DirectChannel inputChannel() {
    return new DirectChannel();
}

@Bean(name = "outputChannel")
public QueueChannel outputChannel() {
    return new QueueChannel();
}

@Bean(name = "transactionLogger")
public ourLogger ourTransactionLogger() {
    return OurLoggerFactory.getLogger("ourAppTrx", new ourLoggerConfig(ourTransactionLoggerKey.values()));
}

public IntegrationFlow ourFlow() {
     return IntegrationFlows.from(inputChannel())
            .split(splitter(ourTransactionLogger()))
            .channel(MessageChannels.executor(getExecutor()))
            .handle(ourServiceActivator, "service")
            .aggregate(t -> t.processor(ourAggregator, AGGREGATE))
            .channel(outputChannel())
            .get();
}

@Bean(name = "executor")
public Executor getExecutor()
{
    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newCachedThreadPool();
    executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
    return executor;
}
}
//snippet from calling service

public InquiryResponse inquire(InquiryRequest request) {

    inputChannel.send(MessageBuilder.withPayload(request).build());
    Message<?> msgResponse = outputChannel.receive();   
    InquiryResponse response = (InquiryResponse) msgResponse.getPayload();
    TransactionLogger.debug("correlationId + msgResponse.getHeaders().get("correlationId"));
    TransactionLogger.debug("InquiryService inquire response = " + response.toString());

    return response;
}

//snippet from aggregator

@Aggregator
public <T> InquiryResponse aggregate(List<Message> serviceResponses) {
    InquiryResponse response = new InquiryResponse();
     serviceResponses.forEach(serviceResponse -> {
            Object payload = serviceResponse.getPayload();

            if (payload instanceof AMatchResponse) {
                response.setA(((AMatchResponse) payload).getA());
            } else if (payload instanceof BValueResponse) {
                response.setB(((BValueResponse) payload).getB());
            } else if (payload instanceof BError) {
                 response.setB(new B().addBErrorsItem((BError) payload));
            } else if (payload instanceof AError) {
                response.setA(new A().AError((AError) payload));
            } else {
                transactionLogger.warn("Unknown message type received. This message will not be aggregated into the response. ||| model=" + payload.getClass().getName());
            }

    });
    transactionLogger.debug("OurAggregator.response = " + response.toString());
    return response;
}   
@配置
@启用自动配置
@导入(..…AServiceConfig.class)
公共类ServiceConfig{
@Bean(name=“inputChannel”)
公共DirectChannel inputChannel(){
返回新的DirectChannel();
}
@Bean(name=“outputChannel”)
公共队列通道输出通道(){
返回新的队列通道();
}
@Bean(name=“transactionLogger”)
public ourLogger ourTransactionLogger(){
返回OurLoggerFactory.getLogger(“ourAppTrx”,新的ourLoggerConfig(ourTransactionLoggerKey.values());
}
公共集成流ourFlow(){
返回IntegrationFlows.from(inputChannel())
.split(拆分器(ourTransactionLogger()))
.channel(MessageChannels.executor(getExecutor()))
.handle(我们的服务激活器,“服务”)
.aggregate(t->t.processor(我们的聚合器,聚合))
.channel(outputChannel())
.get();
}
@Bean(name=“executor”)
公共执行器getExecutor()
{
ThreadPoolExecutor executor=(ThreadPoolExecutor)Executors.newCachedThreadPool();
setRejectedExecutionHandler(新的ThreadPoolExecutor.CallerRunPolicy());
返还执行人;
}
}
//调用服务的代码片段
公共查询响应查询(查询请求){
inputChannel.send(MessageBuilder.withPayload(request.build());
消息msgResponse=outputChannel.receive();
InquiryResponse=(InquiryResponse)msgResponse.getPayload();
调试(“correlationId+msgResponse.getHeaders().get(“correlationId”));
TransactionLogger.debug(“InquiryService inquire response=“+response.toString());
返回响应;
}
//来自聚合器的代码段
@聚合器
公共查询响应聚合(列出serviceResponses){
InquiryResponse=新的InquiryResponse();
serviceResponse.forEach(serviceResponse->{
对象负载=serviceResponse.getPayload();
if(AMatchResponse的有效负载实例){
setA(((AMatchResponse)有效载荷).getA());
}else if(BValueResponse的有效负载实例){
response.setB(((BValueResponse)payload.getB());
}else if(有效负载实例错误){
response.setB(新的B().addBErrorsItem((BError)有效载荷));
}else if(有效负载故障实例){
setA(新的A().AError((AError)有效载荷));
}否则{
transactionLogger.warn(“收到未知消息类型。此消息不会聚合到响应中。| | | model=“+payload.getClass().getName());
}
});
transactionLogger.debug(“OurAggregator.response=“+response.toString());
返回响应;
}   

很抱歉,此权益中的自定义变量太多。由于您没有演示自己的代码,我们无法确定问题出在哪里。您始终可以打开
org.springframework.integration
的调试日志,并观察消息的过程。我将springframework日志设置为跟踪,并添加了自己的日志记录陈述。从聚合器返回响应对象到InquiryService收到响应对象的时间之间,它偶尔会丢失数据,吞吐量越高,发生的频率越高。我不确定您对我的问题的回答的确切含义。我是否可以发布一些有助于澄清问题的特定内容em?在我发布的代码(ServiceConfig、Aggregator或InquiryService)中,您看到了什么引人注目的东西吗这可能是导致问题的原因?我的意思是有太多的自定义逻辑。你真的应该尽量减少问题的范围。现在很难确定问题的根源,因为它已经超出了框架组件的范围。当然,我不介意问题是否在聚合器中的某个位置,并且很乐意将其修复,以使其成为可能为其他人避免类似的问题,但是你必须展示简单的测试用例来重现。我们无法通过复杂的目标应用程序逻辑来帮助你。这就是我的问题所在。好的,谢谢,我将尝试找出问题所在。原因是,在这个公平中有太多的自定义变量。我们不能说问题出在哪里,因为你没有演示你的自己的代码。您始终可以打开
org.springframework.integration
的调试日志记录,并观察消息的过程。我将springframework日志记录设置为跟踪,并添加了自己的日志记录语句。从聚合器返回响应对象到InquiryService接收响应对象的时间之间,它偶尔会丢失数据,吞吐量越高,发生的频率就越高。我不确定您对我的问题的回答到底是什么意思。我可以发布一些具体的信息来帮助澄清问题吗