Announcement Announcement Module
Collapse
No announcement yet.
service-activator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • service-activator

    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
    Code:
      <integration:gateway id="publishService"
             service-interface="com.abc.messagebus.publisher.example.PublishService"          
             request-channel="requestChannel"
             reply-channel="replyChannel"
             message-creator="messageCreator"
             message-mapper="messageMapper" />
    publisher code
    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.

    Code:
        <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>
    ProcessorService

    I tried both public Message<String> handle(Message<String> m) and public String handle(String m) as the signature.

    Code:
    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;		
    	}
    }
    My Subscriber with annotation handler

    This version work prefectly fine.

    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;		
    	}
    }
    Thanks,

    Michael
    Last edited by markous; Oct 22nd, 2008, 04:24 AM. Reason: fix typo

  • #2
    What version are you using?

    Comment


    • #3
      I am using milestone 6.

      Comment

      Working...
      X