2

我正在使用 Spring Integration & SI AMQP 3.0.0-RELEASE。

我在两个 SI 实例之间通过 AMQP 有一个相当简单的请求-响应。

我发现当响应返回到请求服务器时,SI 正在尝试使用 Request 对象的类型而不是 Response 对象来反序列化响应。

即,给定网关接口:

public AnalyticsReponse getAnalyticsReport(EntityMessage objectUri);

我发现即使 an 的正确 JSONAnalyticsResponse到达服务器,SI 仍试图将其反序列化为EntityMessage,但失败了。

我已经调试过了,我怀疑原因是响应方正在复制入站json__TypeId__标头,而不是提供自己的标头。但是,我看不到我在哪里配置错误。

这是我的配置——我做错了什么?

请求方:

<int:channel id="analytics.reports.requests.channel" /> 
<int:channel id="analytics.reports.responses.channel" />
<int:gateway service-interface="com.project.analytics.gateway.AnalyticsReportingGateway">
    <int:method name="getAnalyticsReport" request-channel="analytics.reports.requests.channel" reply-channel="analytics.reports.responses.channel"/>
</int:gateway>
<int-amqp:outbound-gateway 
    request-channel="analytics.reports.requests.channel" 
    reply-channel="analytics.reports.responses.channel"
    exchange-name="analytics.reports.exchange" amqp-template="amqpTemplate" />

响应方:

<int:channel id="analytics.reports.requests.channel" /> 
<int:channel id="analytics.reports.responses.channel" />    
<int-amqp:inbound-gateway request-channel="analytics.reports.requests.channel" reply-channel="analytics.reports.responses.channel"
    queue-names="analytics.reports.queue" connection-factory="rabbitConnectionFactory" message-converter="jsonMessageConverter"/>

<int:service-activator input-channel="analytics.reports.requests.channel" output-channel="analytics.reports.responses.channel" 
    ref="analyticsReporter" method="getAnalytics"/>
<bean class="com.project.analytics.reporters.SimpleAnalyticsReporter" id="analyticsReporter"/>


public class SimpleAnalyticsReporter {

@SneakyThrows
public AnalyticsReponse getAnalytics(EntityMessage message) {
    return new AnalyticsReponse("Hello");
 }
4

1 回答 1

2

只要您不感兴趣org.springframework.integration.mapping.support.JsonHeaders,因为您使用jsonMessageConverter,您应该过滤它们(<header-filter>)或完全忽略所有 AMQP 标头(mapped-request-headers="-"mapped-reply-headers="-")。

但是我发现我昨天不对(https://jira.springsource.org/browse/INT-3285)并重新打开问题以修改默认情况下我们如何处理标准标题以允许工作类似的场景。谢谢!

于 2014-02-06T08:08:14.227 回答