Hi all,
I am trying to write an example a request-reply message using spring integration. I am only able to get it working with my annotation handler but not with the service-activator element. I am keep getting a null reply msg. It never hit the handle method in my subscriber bundle. It will be great if any experts can point out my mistakes...Thanks
My Publisher
publisher context.xml
publisher codeCode:<integration:gateway id="publishService" service-interface="com.abc.messagebus.publisher.example.PublishService" request-channel="requestChannel" reply-channel="replyChannel" message-creator="messageCreator" message-mapper="messageMapper" />
Code:logger.info(">>> sending message to publish Service"); String msg = publishService.publish("whatever "); logger.info("<<< publish service response: " + msg);
My Subscriber with service-activator element
The publisher above return null for the response msg.
ProcessorServiceCode:<bean id="processorService" class="com.abc.messagebus.transaction.example.ProcessorService"/> <integration:service-activator input-channel="requestChannel" output-channel="replyChannel" ref="processorService" method="handle"> <integration:poller period="1000" /> </integration:service-activator>
I tried both public Message<String> handle(Message<String> m) and public String handle(String m) as the signature.
My Subscriber with annotation handlerCode:public class ProcessorService { private final Log logger = LogFactory.getLog(getClass()); public Message<String> handle(Message<String> m) { String value = m.getPayload(); logger.info(value); value += System.currentTimeMillis(); StringMessage returnMsg = new StringMessage(value); logger.info("Returning " + returnMsg); return returnMsg; } }
This version work prefectly fine.
Thanks,Code:@MessageEndpoint(input="requestChannel", output="replyChannel") @Poller(period=2000) public class ProcessorHandler { private final Log logger = LogFactory.getLog(getClass()); @Handler public Message<String> handle(Message<String> m) { String value = m.getPayload(); logger.info(value); value += System.currentTimeMillis(); StringMessage returnMsg = new StringMessage(value); logger.info("Returning " + returnMsg); return returnMsg; } }
Michael


Reply With Quote