Announcement Announcement Module
Collapse
No announcement yet.
Sequencer not working with Splitter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sequencer not working with Splitter

    Hi,

    I am writing a Test Splitter which just sends the splitted message to the aggregator.The sequence no,correlation id and sequence size are set.

    I pass the list of the aggregated messages to the sequencer.But it is not getting sequenced.


    Here is my Splitter code:

    Code:
    public class MessageSplitter
    {
    
    	public List<Message<String>> splitMessage(Message<Map<String, List<String>>> message)
    	{
    		List<Message<String>> result = new LinkedList<Message<String>>();
    		System.out.println("message is in splitter " + message.getPayload());
    		
    		Message<String> firstMessage = MessageBuilder.withPayload("\"are you...\"}").setCorrelationId("ABC").setSequenceSize(2)
    				.setSequenceNumber(2).build();
    		Message<String> secondMessage = MessageBuilder.withPayload("{\"message\":\"Hello how ").setCorrelationId("ABC").setSequenceSize(2)
    				.setSequenceNumber(1).build();
    
    		result.add(firstMessage);
    		result.add(secondMessage);
    		
    		return result;
    		
    	}
    
    }

    This is my config file:

    Code:
    	<int-http:inbound-channel-adapter id="smsInboundAdapter"
    		channel="smsChannel" name="/smsInboundAdapter.htm" supported-methods="GET" />
    
    	<int:channel id="smsChannel" />
    
    	<int:channel id="aggregationChannel" />
    
    	<int:channel id="errorChannel" />
    
    	<int:channel id="sequencerChannel" />
    
    
    
    	<int:splitter id ="messageSplitter" input-channel="smsChannel" output-channel="sequencerChannel">
    	    <bean class="sms.communication.MessageSplitter" />
    	</int:splitter>
    
    	<int:resequencer input-channel="sequencerChannel"
    		output-channel="aggregationChannel" />
    
    	<int:aggregator method="add" input-channel="aggregationChannel"
    		output-channel="completeMessageChannel" discard-channel="errorChannel"
    		send-timeout="1" send-partial-result-on-expiry="false">
    		<bean class="sms.communication.MessageAggragator" />
    	</int:aggregator>
    
    	<int:channel id="completeMessageChannel" />
    
    	<int:service-activator id="gateway"
    		input-channel="errorChannel" ref="errorUnWrapper" />
    
    	<int:outbound-channel-adapter ref="messageProcessor"
    		channel="completeMessageChannel" />
    
    	<bean id="messageProcessor" class="sms.communication.MessageProcessor" />
    
    	<bean id="errorUnWrapper" class="sms.communication.ErrorUnWrapper" />

    The output is :

    Code:
    message is in splitter {longcode=[9892457458], body=[{Hello how are you......}], msidn=[9833804]}
    MessageAggragator : ["are you..."}, {"message":"Hello how ]
    MessageProcessor : "are you..."}{"message":"Hello how 
     -------------------------------------------

    Please help....

  • #2
    Could you please explain what exactly are you trying to accomplish? What is the purpose of putting re-sequencer in front of aggregator? Resequencer is responsible in managing the order of messages while the aggregator does not enforce any order so Messages in the message group are naturally un-ordered unless some custom code orders them. If you do so then why do you need resequences as you can simply accomplish the same in sms.communication.MessageAggragator
    Also can you show the source for sms.communication.MessageAggragator

    Comment


    • #3
      Hi Thanks for the reply,

      I am trying to test if my messages are sequenced properly.
      I just want to make sure that my messages are sequenced properly so that the aggregated output is correct.

      This is my Aggregator code:

      Code:
      public class MessageAggregator
      {
      	private Log log = LogFactory.getLog(getClass());
      	
      	public String add(List<String> messageLists)
      	{
      		log.info("-----MessageAggragator :---------------------" + messageLists);
      
      		String totalJsonString = "";
      
      		for (String partialResult : messageLists)
      		{
      			totalJsonString += partialResult;
      
      		}
      		return totalJsonString;
      
      	}
      
      }

      Comment

      Working...
      X