我正在做下面的案例研究。
我已经创建了Rest服务,并且使用Ref Id从数据库获取数据,但是在将消息放入通道(队列)后,我无法将响应发送回rest客户端。Rest客户端接收的输出为:在超时中没有收到答复
基本上,我希望在数据(CLOB)被推送到通道(队列)后立即返回请求线程。
下面是配置。
<int:channel id="responseChannel"/>
<int:channel id="initCalculation">
<int:queue/>
</int:channel>
<!-- GET -->
<int-http:inbound-gateway
request-channel="httpGetChannel"
reply-channel="responseChannel"
supported-methods="GET"
path="/init/{refId}"
payload-expression="#pathVariables.refId">
<int-http:request-mapping produces="application/json"/>
</int-http:inbound-gateway>
<int:chain input-channel="httpGetChannel" output-channel="initCalculation">
<int-jdbc:stored-proc-outbound-gateway
id="outbound-gateway-storedproc-get-forma" data-source="dataSource"
is-function="false"
stored-procedure-name="XX_EMPROC.GET_FRMA"
ignore-column-meta-data="true"
expect-single-result="true">
<int-jdbc:sql-parameter-definition name="V_REF_ID" direction="IN" />
<int-jdbc:sql-parameter-definition name="V_FRMA" direction="OUT" type="#{T(oracle.jdbc.OracleTypes).CLOB}"/>
<int-jdbc:parameter name="V_REF_ID" expression="payload" />
</int-jdbc:stored-proc-outbound-gateway>
<!- Convert to JSON Format -->
<int:service-activator ref="brInitGateway" method="getResponse"/>
</int:chain>
<int:outbound-channel-adapter channel="initCalculation" ref="brInitGateway" method="process"/>请告知以上所需的更正。
谢谢
发布于 2017-06-27 21:38:51
看,没有人会将消息作为回复发送给<int-http:inbound-gateway>。您已经声明了responseChannel,但是谁将使用它作为output-channel
我建议你这样做:
<publish-subscribe-channel id="responseChannel"/>
<int:chain input-channel="httpGetChannel" output-channel="responseChannel">
<int:bridge input-channel="responseChannel" output-channel="initCalculation"/>那么,这里发生了什么:
作为订阅者之一,用于publish-subscribe-channel的reply-channel为replyChannel报头建立了一个内部桥。
您可以从<chain>向该频道发送一个结果。因此,<int-http:inbound-gateway>将得到它的答复。
有了对<int:bridge>的响应,您就有了第二个订阅服务器,因此,会向所需的队列发送一条消息。
如果您对brInitGateway.getResponse()请求的答复不感兴趣,则应该考虑根本没有该reply-channel="responseChannel",但仍然使用一些<publish-subscribe-channel>发送到队列,使用一些转换器来准备答复,例如:
<transformer input-channel="prepareProcess" expression="' {"status": true,"message": "RECEIVED"}'"/>此转换器没有output-channel,因为它将将其结果发送到replyChannel头,因此发送到<int-http:inbound-gateway>启动器。
https://stackoverflow.com/questions/44790143
复制相似问题