我正在使用 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");
}