Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.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
Spring integration 使用Spring Integration SQS对多个队列上的SQS确认/错误的聚合未来/响应_Spring Integration_Spring Integration Aws - Fatal编程技术网

Spring integration 使用Spring Integration SQS对多个队列上的SQS确认/错误的聚合未来/响应

Spring integration 使用Spring Integration SQS对多个队列上的SQS确认/错误的聚合未来/响应,spring-integration,spring-integration-aws,Spring Integration,Spring Integration Aws,我使用的是网关,在网关内部,我通过sqs出站适配器将消息发送到两个队列 我想实现这样的目标: jsonArray.forEach(data -> { Future<AggregatedAckorErrorFrom2Queues> result = dataPublishGateway.publishToService(data); futures.add(result); }); futures.forEach(f -> {

我使用的是
网关
,在网关内部,我通过
sqs出站适配器
将消息发送到两个队列

我想实现这样的目标:

jsonArray.forEach(data -> {
    Future<AggregatedAckorErrorFrom2Queues> result = dataPublishGateway.publishToService(data);
    futures.add(result);
});
futures.forEach(f -> {                      
    System.out.println("Future Result -> "+ f.get())
});
jsonArray.forEach(数据->{
未来结果=dataPublishGateway.publishToService(数据);
添加(结果);
});
futures.forEach(f->{
System.out.println(“未来结果->”+f.get())
});
网关和SQS适配器配置


我正在查看
数据通道上的
应用序列
聚合器
,但是
聚合器
必须能够处理
确认
错误


问题:如何从2个队列返回聚合响应(ack+错误)到网关?

您使用的
成功通道
失败通道
方向正确。聚合器可以订阅该
成功频道
,并使用默认策略进行关联和发布。对于
故障通道
,您可能需要一个自定义错误通道,而不是一个全局
错误通道
。从
SqsMessageHandler
发送到该通道的
ErrorMessage
有一个类似于
AwsRequestFailureException
的有效负载,其中它的
failedMessage
确实包含一个具有所述相关详细信息的请求消息。因此,您需要添加一些转换步骤,以便在继续到聚合器之前从异常中提取该信息。

如何从该调用将结果返回到网关,例如线程1-->
Future result=dataPublishGateway.publishToService(data)
。由于
dataPublishGateway
通过发布/子通道(
dataChannel
)发布到2个SQS队列,调用线程(上面的线程1)如何从这两个队列的回调中获取结果?聚合器将根据要聚合的消息之一的
replyChannel
头自动执行此操作。网关中的等待线程将对该回复进行关联。该线程不会等待,因为数据通道的订户是基于执行器的订户。我缺少什么?您从
dataPublishGateway
发起调用,因此确实存在请求-应答行为。即使它是
未来的
结果,它仍然将由来自
回复频道
标题的回复消息来完成。好吧,需要看看你在
中做了什么
<!-- Gateway to Publish to SQS -->
<task:executor id="dataExecutor" pool-size="5"/>
<int:publish-subscribe-channel id="dataChannel" task-executor="dataExecutor" />
<int:gateway service-interface="com.integration.gateway.PublishGateway" id="dataPublishGateway">
    <int:method name="publishToDataService" payload-expression="#args[0]" request-channel="dataChannel" />
</int:gateway>

<!-- Send to 2 Queues -->

    <int:channel id="successChannel"/>
    <int-aws:sqs-outbound-channel-adapter sqs="amazonSQS"
                                          queue="queue-1"
                                          channel="dataChannel"
                                          success-channel="successChannel"
                                          failure-channel="errorChannel"/>
    <int-aws:sqs-outbound-channel-adapter sqs="amazonSQS"
                                          queue="queue-2"
                                          channel="dataChannel"
                                          success-channel="successChannel"
                                          failure-channel="errorChannel"/>