【发布时间】:2019-01-04 12:25:36
【问题描述】:
您好,我正在尝试使用 Spring 集成构建 Spring Boot 应用程序
应用 1:发布者
Jms Message -> Broker ->queue1
应用 2:订阅者和发布者
Broker->queue1->Transform->HTTP CALL->HTTP Response->JMS Message->Broker->queue2
发布者流程
@Configuration
public class EchoFlowOutBound {
@Autowired
private ConnectionFactory connectionFactory;
@Bean
public IntegrationFlow toOutboundQueueFlow() {
return IntegrationFlows.from("requestChannel")
.handle(Jms.outboundGateway(connectionFactory)
.requestDestination("amq.outbound1")).get();
}
}
//Gateway
@MessagingGateway
public interface EchoGateway {
@Gateway(requestChannel = "requestChannel")
String echo(String message);
}
订阅者和发布者流程
@Configuration
public class MainOrchestrationFlow {
@Autowired
private ConnectionFactory connectionFactory;
@Autowired
private QueueChannel jmsOutChannel;
@Bean
public IntegrationFlow orchestrationFlow() {
return IntegrationFlows.from(
Jms.messageDrivenChannelAdapter(connectionFactory)
.destination("amq.outbound1")
.outputChannel(jmsOutChannel))
.<String, String>transform(s -> {
return s.toLowerCase();
})
// HTTP part goes here
.<String, HttpEntity>transform(HttpEntity::new)
.handle(
Http.outboundChannelAdapter("http://localhost:8080/uppercase")
.httpMethod(HttpMethod.POST)
.extractPayload(true)
.expectedResponseType(String.class)
)
// and here HTTP part ends
.handle(
Jms.outboundAdapter(connectionFactory)
.destination("amq.outbound2")
)
.get();
}
}
当我运行应用程序时,出现错误
引起:org.springframework.integration.MessageTimeoutException: 未能在超时时间内接收 JMS 响应:5000 毫秒 org.springframework.integration.jms.JmsOutboundGateway.handleRequestMessage(JmsOutboundGateway.java:762) ~[spring-integration-jms-5.0.6.RELEASE.jar:5.0.6.RELEASE] 在 org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109) ~[spring-integration-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] 在 org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:158) ~[spring-integration-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] 在 org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) ~[spring-integration-core-5.0.6.RELEASE.jar:5.0.6.RELEASE]
谁能告诉我我做错了什么,
【问题讨论】:
-
@Gimby 感谢您的指点,不用担心 url,我只是把它当作 dummy 放在那里,我得到的错误不是 http
-
如果 HTTP 调用已完成,但该 HTTP 调用未完成但超时时间比您的 JMS 消息处理程序长,那么您会遇到此问题。
-
@Gimby 我也尝试过不使用 http 部分,这与我遇到的错误相同
标签: java spring-boot spring-integration spring-integration-dsl