Announcement Announcement Module
Collapse
No announcement yet.
Release strategy and recipient list router issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Release strategy and recipient list router issue

    I have discovered that my release strategy on my aggregator behaves differently if I set the recipient-list-router property 'apply-sequence' to true, let me explain further...

    The Setup
    ...I have an aggregator whose channel is fed from 2 sources. Source_1 sends 3 files (a,b and c). Source_2 sends 1 file (d) that is transformed, it is also sent to another channel in its original type - the recipient-list-router is ideal for my needs when considering 'file d'.

    The Behavior
    ...I have noticed that if I set 'apply-sequence' to true the collection of generic Message objects does not contain any other correlated messages. However, if I set it to false it works as I expect it. The same thread is used in the release strategy processing so it looks like the correlation is impacted by 'apply-sequence=true'. I've tried my own and enriching the message header to used the default correlation strategy but get the same result.

    Is this a bug or am I missing something?
    Last edited by jamesclinton; Jul 18th, 2011, 10:44 AM. Reason: grammer

  • #2
    Could you please provide a sample configuration which helps to reproduce the issue as I am not clear how your messages are aggregated now without apply-sequence="true"?

    Comment


    • #3
      Here is an extracted configuration of what I am trying to explain in the post.

      The aggregatorChannel expects 4 messages.

      3 come in to that channel via CustomOneHandler.
      (Release Strategy returns FALSE)

      The 1 final message (via SourceTwo) in to that channel is from the router (recipient-list-router). I've only put in a single recipient for brevity.

      When apply-sequence is true none of the messages from SourceOne are passed to the CustomReleaseStrategy. It's as if the CustomCorrelationStrategy did not think they should be grouped.
      (Release Strategy returns FALSE)

      However when apply-sequence is false.
      (Release Strategy returns TRUE)

      Other things to note.

      1. If a message is dropped in via SourceOne - the release strategy always finds other messages from this source and vice versa.

      2. Take out the router and problems go away or as I say set the sequence to false.

      3. The same object is used to determine the release.

      Surely the recipient-list-router configuration should have no impact on the aggregator's release strategy in this scernario?


      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans 
          xmlns="http://www.springframework.org/schema/beans" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:p="http://www.springframework.org/schema/p" 
          xmlns:util="http://www.springframework.org/schema/util" 
          xmlns:si="http://www.springframework.org/schema/integration"
          xmlns:file="http://www.springframework.org/schema/integration/file"
          xmlns:jms="http://www.springframework.org/schema/integration/jms"
          xmlns:rmi="http://www.springframework.org/schema/integration/rmi"
          xmlns:task="http://www.springframework.org/schema/task"
          xsi:schemaLocation="
              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
              http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
              http://www.springframework.org/schema/util  http://www.springframework.org/schema/util/spring-util-3.0.xsd
              http://www.springframework.org/schema/task  http://www.springframework.org/schema/task/spring-task-3.0.xsd      
              http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
              http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-2.0.xsd
              http://www.springframework.org/schema/integration/rmi http://www.springframework.org/schema/integration/rmi/spring-integration-rmi-2.0.xsd
              http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file-2.0.xsd">
          
          
      
          <!-- SOURCE 1 -->
          
          <si:channel id="SourceOneChannel"/>
          
          <si:service-activator
              input-channel="SourceOneChannel"
              output-channel="aggregatorChannel"
              method="execute"
              ref="handler"/>
                      
          <bean
              id="handlerOne"
              class="CustomOneHandler"/> 
      
      	<!-- SOURCE 2 goes to aggregator via recipient-list-router -->
      	
      	<si:channel id="SourceTwoChannel"/>
      
          <si:service-activator
              input-channel="SourceTwoChannel"
              output-channel="router"
              method="execute"
              ref="handler"/>
                      
          <bean
              id="handlerTwo"
              class="CustomTwoHandler"/> 
              
          <si:recipient-list-router 
      		input-channel="router"
              timeout="1234"
              ignore-send-failures="true"
              apply-sequence="true">
        		<si:recipient channel="aggregatorChannel"/>
      	</si:recipient-list-router>
        
                
          <!-- AGGEGATION -->
          
          <si:channel id="aggregatorChannel"/>
      
          <si:aggregator 
              input-channel="aggregatorChannel" 
              output-channel="aggregatedChannel" 
              ref="aggregator" 
              method="add"
              release-strategy="releaseStrategyBean"
              release-strategy-method="isComplete"
              correlation-strategy="correlationStrategyBean" 
              correlation-strategy-method="groupBy" 
              send-partial-result-on-expiry="false" 
              />
              
          <bean
              id="aggregator"
              class="CustomAggregator"/>  
      
           <bean id="releaseStrategyBean" class="CustomReleaseStrategy"/> 
           
           <bean id="correlationStrategyBean" class="CustomCorrelationStrategy"/>
          
      </beans>

      Comment


      • #4
        That makes sense.
        You are using Custom release and correlation strategy, but when using applySequence='true' the router creates 'correlationId' and 'sequenceSize' headers which essentially put that message in the different MessageGroup by the CorreltingMessageHandler, so 3 Messages are sitting in one MessageGroup while 1 is sitting in another. Actually i think one is being released right away since its sequence size is 1 right? Its the other 3 that are lost.

        Is there a reason why you use apply-sequence="true"?

        Comment


        • #5
          Just to add, apply-sequence="true" is kind of a convenience attribute when someone is relying on the default correlation and release strategy or someone who is building custom correlation and release strategy which will rely on 'correlationId" and "sequenceSize" headers. If you are not relying on those headers, that you don't really need them there in the first place, so you don't need apply-sequence to be set to 'true'

          Comment


          • #6
            I wrongly assumed apply-sequence was possibly related to the order in which the message was sent to each recipient channel. Pretty stupid when I come to think about it.

            Thanks for your help on clearing this up.

            Comment


            • #7
              No problem.

              Speaking of sequencing of the messages if it is important to you than you can look at the Resequencer which is a variation of the aggregator http://static.springsource.org/sprin...e/#resequencer

              Comment

              Working...
              X