Results 1 to 3 of 3

Thread: Multiple consumers of a topic

  1. #1
    Join Date
    Dec 2006
    Posts
    11

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Dec 2006
    Posts
    11

    Default

    thanks, that solved my problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •