Saravana Kumar
Saravana Kumar

Reputation: 11

Spring Integration : listener of Inbound Gateway not working when implemented with @Gateway Interface

In my application, sending the messages to Tibco Queue with the help of Spring JMS Integration Outbound Gateway. We are having configuration file to load the Connection factory and all the information during server start up.

But when we try to retrieve the messages from Inbound Gateway, the call gets into the doReceive() of GenericMessagingTemplate class and not returned from that method.

Below is the configuration of our application

The Gateway Class as:

 @MessagingGateway 
 public Interface MessageGateway 
 {   
    @Gateway(requestChannel="InboundChannel")
    public Object listent(@Headers Map<String,Object> cusHeader, @Payload Object obj)
}

Below is the config and registers listener class:

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
   }  
}

I have Custom Inbound class which overrides the handleMessageInternal() method which is actually used for handling the messages.

My client app or test call will call the MessageGateway.listen which has to return the JMS response which is not returning anything.

Can someone help me on this

Upvotes: 1

Views: 594

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121177

The AbstractMessageHandler indeed doesn't return anything. It is one-way component. If you would like to return something from downstream you have to use request-reply component. In the Spring Integration all of them are extension of the AbstractReplyProducingMessageHandler. However that's full unclear why you should go so low level - the simple POJO with the method to return anything for the gateway call is fully enough. You still can use that @ServiceActivator annotation: https://docs.spring.io/spring-integration/docs/5.0.0.RELEASE/reference/html/configuration.html#annotations

Upvotes: 1

Related Questions