I have a publisher who pushes posts to the topic. I have several subscribers, each of which performs a different task when they consume a message from this topic. Now I want my system to scale to multiple instances of the same process on different hosts / same host. for example, I want to run multiple copies of my application A on different hosts, so that if one instance of A is slow, other instances can pull out subsequent messages and move forward. I found out that this is possible using virtual directions. I followed these steps - http://activemq.apache.org/virtual-destinations.html
But how do I set up multiple subscribers on the same topic with the same client ID? when I try to do this, I get errors. when I try differently, it does not work. can someone help?
I usually start the subscriber by following these steps:
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER, ActiveMQConnection.DEFAULT_PASSWORD, ActiveMQConnection.DEFAULT_BROKER_URL;); activeMQConnection = connectionFactory.createConnection(); activeMQConnection.setClientID("subscriber1"); activeMQConnection.setExceptionListener(exceptionListener); activeMQSession = activeMQConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE); activeMQTopic = activeMQSession.createTopic("myTopic"); activeConsumer = activeMQSession.createDurableSubscriber(activeMQTopic, "myTopic"); activeConsumer.setMessageListener(messageListener); activeMQConnection.start();
when I try to create a second subscriber and pass the topic name as "VirtualTopic.myTopic", nothing happens.
thanks
source share