Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration Spring集成:使用@Gateway接口实现时入站网关的侦听器不工作_Spring Integration_Spring Jms - Fatal编程技术网

Spring integration Spring集成:使用@Gateway接口实现时入站网关的侦听器不工作

Spring integration Spring集成:使用@Gateway接口实现时入站网关的侦听器不工作,spring-integration,spring-jms,Spring Integration,Spring Jms,在我的应用程序中,通过SpringJMS集成出站网关将消息发送到Tibco队列。我们有配置文件来加载连接工厂和服务器启动期间的所有信息 但是当我们尝试从入站网关检索消息时,调用进入GenericMessageTemplate类的doReceive(),而不是从该方法返回 下面是我们应用程序的配置 网关类为: @MessagingGateway public Interface MessageGateway { @Gateway(requestChannel="Inboun

在我的应用程序中,通过SpringJMS集成出站网关将消息发送到Tibco队列。我们有配置文件来加载连接工厂和服务器启动期间的所有信息

但是当我们尝试从入站网关检索消息时,调用进入GenericMessageTemplate类的doReceive(),而不是从该方法返回

下面是我们应用程序的配置

网关类为:

 @MessagingGateway 
 public Interface MessageGateway 
 {   
    @Gateway(requestChannel="InboundChannel")
    public Object listent(@Headers Map<String,Object> cusHeader, @Payload Object obj)
}
我有一个自定义的入站类,它重写了实际用于处理消息的handleMessageInternal()方法

我的客户端应用程序或测试调用将调用MessageGateway.listen,它必须返回JMS响应,而JMS响应不返回任何内容


有人能帮我一下吗?

这个
AbstractMessageHandler
确实没有返回任何东西。它是单向组件。如果你想从下游返回一些东西,你必须使用请求-应答组件。在Spring集成中,它们都是
AbstractReplyProducingMessageHandler
的扩展。然而,这完全不清楚为什么您应该使用如此低的级别—简单的POJO,该方法可以为网关调用返回任何内容,这就足够了。您仍然可以使用
@ServiceActivator
注释:

您的问题中没有足够的信息供任何人帮助您;你需要提供更多的细节。使用侦听器容器来处理请求似乎有些奇怪——这是用于异步入站消息传递的。您是否尝试过启用调试日志并观察应用程序中的消息流?听起来好像没有回复;您可以向网关添加回复超时,以避免线程在
receive()
中永远等待。谢谢。实际上,作为实现的一部分,我需要使用入站网关侦听消息。在我的例子中,消息已经使用出站网关发送。将使用入站网关处理的消息必须针对想要使用该消息的任何客户端进行自定义。希望这能解释我的情况,我需要解决这个问题。另外,正如您所说的,尝试了超时,在这种情况下,它使用了临时ReplyChannel接收方法,该方法不返回任何响应如果它的请求/响应,为什么不使用JMS出站网关呢?您不需要为此编写任何代码。是的,Gary,我们也将请求/响应与出站网关一起使用,但我们有一个用例,我们只想接收或使用消息。因此,我们决定通过配置请求通道和目标名称来使用入站网关。我们还注意到,在这种情况下,它调用的是doSendandReceive方法,而不是receive方法。所以被困于如何处理,你不能使用网关;您应该使用入站通道适配器和
@ServiceActivator
在消息到达时调用代码。
public Class Msgconfig {

   @Bean
   public MessageChannel InboundChannel(){
      return new DirectChannel();
   }

   @Bean
   @ServiceActivator(inputChannel ="InboundChannel")
   public AbstractMessageHandler listenMessage() {
      // having the logic of DefaultMessageListenerContainer class to load connection factory and setting the message listener
    // Have the logic of ChannelPublishingJmsMessageListener class to set the request channel
   }  
}