Announcement Announcement Module
No announcement yet.
ActiveMQ/JCA/Mulitple Message Listeners Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ActiveMQ/JCA/Mulitple Message Listeners

    Hi All,
    This is my current problem:

    I am using the Publisher/Subscriber model deployed under weblogic 8.1 (Express) using the JMS 1.0.2b implementation.

    I am unable to use the J2EE container to supply JMS as I am restricted by the Weblogic Express license, so the idea was to use ActiveMQ & Spring to provide the messaging framework.

    Current architecture has one publisher and multiple subscribers. Each subscriber is responsible for retrieving different data from different suppliers. Each subscriber has a pool of message listeners attached to accomplish this data retrieval.

    I have used an example from the ActiveMQ (org.codehaus.activemq.jca.TargetSourceMessageList ener) and the Spring's CommonsPoolTargetSource to create the pool.

    Subscriber code:
    TargetSourceMessageListener listener; //set by Spring Context
    JmsTemplate102 template; //set by Spring
    ConnectionFactory factory = template.getConnectionFactory();
    connection = ((TopicConnectionFactory)factory).createTopicConnection();
    TopicSession session = connection.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);
    TopicSubscriber subscriber = session.createSubscriber((Topic)destination);
    Each subscriber is started at deployment.

    Spring context file:
    	<bean id="pooledSearch" class="org.codehaus.activemq.jca.TargetSourceMessageListener">
    		<property name="targetSource">
    			<bean id="pooledListenerTargetSource" class="">
    				<property name="targetBeanName">
    				<property name="maxSize">
      <bean id="pooledListeners" class="" singleton="false">
    The idea of this was that the Subscriber, calls the onMessage() of the TargetSourceMessageListener and this retrieves a Message Listener (ML) from the pool, calls the onMessage on that ML and then releases the connection when its finished. Unfortunately this is all done by Subscriber thread and until the ML finishes its business, only then is the ML released back to the pool. Not exactly brilliant for handling multiple concurrent requests. Where have I gone wrong? What I am missing?

    What I want it do to is each time a message is published, I want each subscriber to retrieve a ML in a new thread, allowing it go off and do it's thing and if another message comes along, the Subscriber retrieves another ML, without waiting for the first ML to finish. Does this make sense?

    Could JCA be the solution? If so how? If not, what else? What of Message-Driven POJO's?

    Appreciate any help, thanks, Andrew.

  • #2
    This sounds like a good use case for the JCA container which takes care of all of the pooling & thread handling & connection/session/consumer processing (as well as transactions / acknowledgements).

    Have you tried using the example Spring XML to consume from a topic/queue using your own MessageListener POJO, e.g. using this file as a basic example...