Announcement Announcement Module
Collapse
No announcement yet.
Multiple consumers of a topic Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple consumers of a topic

    Hi!

    How do I setup an effective way to consume messages from a topic in multiple threads.


    With ejb3 you can do it like this:

    Code:
    @MessageDriven(activationConfig={
    @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic"),
    @ActivationConfigProperty(propertyName="destination", propertyValue="topic/testDistributedTopic"),
    @ActivationConfigProperty(propertyName="maxSession", propertyValue="5"),
    @ActivationConfigProperty(propertyName="SubscriptionDurability", propertyValue="Durable"),
    @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="AUTO_ACKNOWLEDGE")
    })

    With spring jms I seem to get the same setup with this configuration:

    Code:
     <jms:listener-container connection-factory="connectionFactory" destination-type="durableTopic" acknowledge="auto" client-id="client1">
            <jms:listener destination="testDistributedTopic" ref="messageListener"/>
            <jms:listener destination="testDistributedTopic" ref="messageListener"/>
            <jms:listener destination="testDistributedTopic" ref="messageListener"/>
            <jms:listener destination="testDistributedTopic" ref="messageListener"/>
            <jms:listener destination="testDistributedTopic" ref="messageListener"/>
    
        </jms:listener-container>
    Is there a downside to do it like this?

    Even if the listener-container reads the messages in one thread I still want to process them in multiple threads. With the configuration above it seems to be working like I want but I have to repeat my self in the configuration.

  • #2
    You are currently creating multiple containers (each listener needs its own container). I suggest you take a look at the XSD and what you can specify. You are probably more interested in the concurrency attribute.

    Reference guide.

    Comment


    • #3
      thanks, that solved my problem.

      Comment

      Working...
      X