嗨我試圖使用Spring集成實現以下流程。 公開REST服務,處理有效內容,將更改後的有效內容寫入JMS並回復到REST服務。春季集成:REST到JMS集成給出超時錯誤
@Bean
public IntegrationFlow httpInputFlow() {
return IntegrationFlows
.from(Http.inboundGateway(「/company」)
.requestMapping(r -> r
.methods(HttpMethod.POST))
.requestPayloadType(com.poc.model.Company.class))
.transform(jsonToObjectTransformer())
.channel(requestChannel())
.get();
}
@Bean
@Transformer(inputChannel=「requestChannel」, outputChannel=「responseChannel」)
ObjectToJsonTransformer jsonToObjectTransformer() {
return new ObjectToJsonTransformer();
}
@Bean
public DirectChannel requestChannel() {
return MessageChannels.direct().get();
}
@Bean
public DirectChannel responseChannel() {
return MessageChannels.direct().get();
}
@Bean
IntegrationFlow outboundFlow() throws Exception {
return IntegrationFlows.from(responseChannel()) .handle(Jms.outboundAdapter(connectionFactory()).destination(「samplequeue」))
.get();
}
請求有效載荷正在到達隊列。但是,REST服務超時沒有回覆。我需要將轉換後的有效負載放入隊列中,並將其發送給其餘服務的響應。我找不到任何可用的例子。
任何幫助表示讚賞。
謝謝Artem,會試試這個。 – jack
你可以建議如何通過.bridge()橋處理程序? Bridge方法期望Consumer>作爲參數。樣本是在xml中,而不是在java dsl中。 –
jack
必須是'.brdige(null)'。在將Java DSL移植到5.0中的Spring Integration Core後,我們添加了不帶參數的'.bridge()'。 –