Announcement Announcement Module
No announcement yet.
Multicast cloned messages Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multicast cloned messages

    Use Case:
    Incoming messages need to go through a common set of filtering, validation and transformation. After the "common steps" I need to "clone" the message and multicast it to N number of parallel channels that each will do specific filtering, transformation, validation. So the important part is that each parallel channel will be messing with the message so each parallel channel needs a copy of the message.

    I have not found a way to do this based on reading the reference documentation and searching through the forum.

    Any help would be appreciated.



  • #2
    Messages are immutable. The payload migh not be, but it should in most cases. For that reason we don't need to clone messages. Iaw, you simply can't "mess" with the message.

    If you need to clone the payloads, I'd suggest to use a splitter and implement your own cloning logic.

    I'd appreciate if you would be a little more specific on the use case, possibly with a few samples. I don't see why it would be useful to change different copies of a message without linking them back together at the end.


    • #3
      multi cast cloned messages

      "Publishers" send me messages via a jms queue.
      My Spring Integration implementation listens to the messages on the queue.
      Messages have some metadata and a list of people in them.
      I have to split the messages on each person, then:
      schema validate each person. If the specific person does not schema validate, then I audit log it and drop it from the list.
      I then do some other filtering on each individual person ....
      I then aggregate the message back together.

      At this point the "common" system steps are done. Now I need to send the message out to 6 different clients via jms queues. However, each of the 6 specific clients "flows" get their own specific filtering and transformations before the message gets published to the client specific queue in the client specific format.

      I'm new to Spring Integration so I'm sure there are things I'm not understanding correctly.

      Right now I have my "common" steps done and I'm using the RecipientListRouter to send aggregated message to the 6 "client flows."
      I'm not sure if I should be using the publish subscribe channel instead.
      The RecipientListRouter sends the message to the 6 "client flow" channels.

      This seems to happen sequentially so I have a problem if an exception gets thrown in one of the "client flows." If an exception happens, the following client flows do not get called. This is one issue that makes me think I should be using the publish subscribe channel instead.

      It does seem that the message that goes to each "client flow" channel is a copy. In other words, if in my "client flow 1" channel, I filter out 90% of the people, my "client flow 2" will still get the entire original message that came into the RecipientListRouter. In other words, when I mess with the message in one client, it doesn't seem to affect the message in other "client flow" channels.


      • #4
        Thanks for taking the time to share this.

        It sounds like you would be better off using a pub-sub channel. The copying of the message is by design. In fact every time you "change" a message you will actually create a new message with the changes in it.

        If I get it right everything you're doing is working according to spec, except the part where exceptions being thrown block further sending. This will be resolved by using a pub-sub channel.

        Looks like an interesting use case. I think you should browse the forums and our JIRA for error handling. You might have useful input for the changes we're planning there.


        • #5
          Sorry if I am hijacking the thread.
          But this is related to this thread.

          In a pure jms world, we do
          QueueReceiver receiver = queueSession.createReceiver(Queue queue,
          java.lang.String messageSelector)


          TopicSubscriber subscriber = topicSession.createSubscriber(Topic topic,
          java.lang.String messageSelector,
          boolean noLocal)

          Here we specify messageSelector. But this is sort of a static filtering. Usage of this selector will happen at the JMS server side, and the message does not come to the client side itself.
          But does spring integration provides anything like that?

          Current filtering capability in spring intgeration kicks in only after the client received the message. I agree it is by design.

          Would it be a good idea to add a filter attibute for the <jms:message-driven-channel-adapter/> tag?