Announcement Announcement Module
Collapse
No announcement yet.
Communication with Other MessageChannels Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Communication with Other MessageChannels

    Hi All,

    I have implemented Spring Integration as posted in the below post

    http://forum.springsource.org/showth...424#post323424


    Code:
                                       ------Gateway----
                                                    |
                                          inputChannel
                                                    |
                                                Filter 
                                                    |
                                              Splitter
                                                 |||||
                                              Router                                              
                                                / \  
                                               /   \
                                              /     \
                                          (SA)      Splitter (SplitChannel)
                                          /               \\     
                       OutputChannel(Queue)      ||    
                                 |                        /|\    
                                 |                       / | \
                                 |                      /  |  \
                                 |                     /   |   \
                                 |                 (SA) (SA) (SA)
                                 |                   /     |     \           
                                 |             OutputChannel(Queue)       
                                 |                  |          
                            Aggregator (which will aggregate the message based on the correlation key)
    Now here is my problem statement:

    I am using gateway which takes a list of Message & using a corelation strategy to group the messages.

    As per the use case here is how it works.

    A sorted List of Messages(say for example 6 messages) go one by one to SA as per the above diagram & are combined in a group & returned as a list ( return of a gateway is List). Now even though I pass this list of message at the end I use only 2 messages (based on some sorting which is already done & the success of the message in SA). I pick the first 2 successful messages. it could be the item 1&2 or 1&3 or 2&4. Bottom line is I always use on 2 successful message even though I pass 6 messages in list. There is some business reason in sending 6 different messages & pick only 2 out of it.

    What I want is as soon as first 2 messages are successful (which are decided in SA) I don't want the rest of the messages to be processed. Important point is the success flag is Message (a boolean variable). Also I want to do this validation check in SA.

    Let me know if you need more clarification, or have any questions

  • #2
    It seems many people are reading this post but don't have solution to the above problem, Spring forum Leaders please, can you suggest some solution ..

    Comment


    • #3
      If I understand you correctly all you need to do is to have an aggregator polling from OutputChannel(Queue) and outputting message to another channel which essentially is hooked up to a final aggregator. So basically since you have two layers of splitting you should have two layers of aggregation, than in the final aggregator where you'll aggregation will happen based on 2 messages (first layer of splitting) you can filter out the messages you don't need that came form aggregation result of 3 service activator you hav there.
      Code:
      ------Gateway----
                                                      |
                                            inputChannel
                                                      |
                                                  Filter 
                                                      |
                                                Splitter
                                                   |||||
                                                Router                                              
                                                  / \  
                                                 /   \
                                                /     \
                                            (SA)      Splitter (SplitChannel)
                                            /               \\     
                         OutputChannel(Queue)      ||    
                                   |                        /|\    
                                   |                       / | \
                                   |                      /  |  \
                                   |                     /   |   \
                                   |                 (SA) (SA) (SA)
                                   |                   /     |     \           
                                   |             OutputChannel(Queue)       
                                   |                   |   
                                   |               Aggregator
                                   |                   |       
                                   |                 some-channel
                                   |                    |
                              Aggregator (which will aggregate the message based on the correlation key)

      Comment


      • #4
        I guess that is not what we need. All the messages will eventually be processed SA.

        Let me simplify the problem

        Consider this simple structure of SI.

        Code:
                                           ------Gateway----
                                                        |
                                              inputChannel
                                                        |
                                                    Filter 
                                                        |
                                                    Splitter
                                                      ||||                                              
                                                       /|\    
                                                      / | \
                                                     /  |  \
                                                    /   |   \
                                                 (SA) (SA) (SA)
                                                  /     |     \           
                                              OutputChannel(Queue)       
                                                |  |  |  |  |   |
                                Aggregator (which will aggregate the message based on the correlation key)
        
                                                |List of Messages
        out of this list of messages only first 2 successful messages are picked.
        
        ---------
        Now in this simple structure the splitter is creating 6 messages, all of which go to SA
        In this SA it hits Webservice & Database. Now out of this list of 6 messages due to some business logic we pick the latest 2 successful message.

        Now what we need is , can we have interaction of the messages in SA such that when first 2 successful messages; for a given correlation id; are processed we don;t want rest of the messages to hit Webservice & Database in SA.
        this way we would reduce the number of hit to webservice server & database server, which would definitely help us in improving performance.

        Comment


        • #5
          can we have interaction of the messages in SA such that when first 2 successful messages are processed we don;t want rest of the messages to hit Webservice & Database in SA.
          Well what if at the time when aggregator received two messages the other 10 are already in the middle of the process? I mean its not that difficult to wire a flow in a way where aggregator itself could result in the message that would signal to other components that processing is no longer necessary, but without defining the boundaries of what the 'processing' really means in the context of your use case its hard to say.

          Comment


          • #6
            I understand what you are trying to say, but somewhere or other we can reduce the number of hits to webservice Server & Database server,

            May be somewhere in SA we could have some check like

            ---- Code in SA

            if(no of success message for this correlation strategy is > = 2)
            {
            return the message;
            }else{
            hit webservice;
            hit Database;
            }

            I understand that there is a possibility that all messages hit the if condition at the same time, but putting such condition can help during load. I am not denying the fact that most of the time all the messages hit the condition same time ( or before any 2 messages are successful) but imagine a scenario when messages are bit delayed due to load.

            The Reason I am trying to find out a solution is because of our parallel execution, we see that during load on our server, the web service server & database servers are overloaded. Because in our case for 1 user we are creating minimum 6 threads (i.e 6 messages) which go to web-service & database servers. so 1 user on our server is like 6 users on web service or Database servers (Note that is minimum number).

            Comment

            Working...
            X