Results 1 to 2 of 2

Thread: ActiveMQ/JCA/Mulitple Message Listeners

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Posts
    8

    Default 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:
    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);
    
    subscriber.setMessageListener(listener);
    connection.start();
    Each subscriber is started at deployment.

    Spring context file:
    Code:
    	<bean id="pooledSearch" class="org.codehaus.activemq.jca.TargetSourceMessageListener">
    		<property name="targetSource">
    			<bean id="pooledListenerTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">
    				<property name="targetBeanName">
    					<value>pooledListeners</value>
    				</property>
    				<property name="maxSize">
    					<value>5</value>
    				</property>
    			</bean>
    		</property>
    	</bean>
    
      <bean id="pooledListeners" class="uk.co.bred.SearchMessageListener" 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. #2
    Join Date
    Aug 2004
    Location
    London
    Posts
    164

    Default

    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).

    http://activemq.codehaus.org/JCA+Container

    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...

    http://cvs.activemq.codehaus.org/vie...ing.xml?r=HEAD
    James Strachan
    ------------------
    Open Source Integration
    Iona

Similar Threads

  1. Message Bundle - No Message Found exception
    By arumugamkasi in forum Web
    Replies: 18
    Last Post: Jun 20th, 2011, 04:24 AM
  2. UpgradeAcegi Security System from 0.6.1 to 0.8.3
    By mannobug in forum Security
    Replies: 3
    Last Post: Sep 23rd, 2005, 07:00 PM
  3. How to display message about last action?
    By pir8ped in forum Architecture
    Replies: 8
    Last Post: Jun 6th, 2005, 11:01 AM
  4. Channel and message transformation question
    By Alarmnummer in forum Architecture
    Replies: 12
    Last Post: May 11th, 2005, 05:06 PM
  5. Displaying Error from message resource
    By qtipz4ever in forum Web
    Replies: 3
    Last Post: Mar 16th, 2005, 04:48 PM

Posting Permissions

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