standalone consumer for clustered queue did not get all mess
arminhaaf Dec 9, 2009 4:09 AMwe are currently migrating from JBoss AS 4.2.2 with MQ to a clustered JBoss AS 5.1 with messaging
We have some standalone JMS consumers to connect external systems.
The problem is that a standalone JMS consumer connects to only one node and so gets the messages from this node only.
The queue is Clustered:
<mbean code="org.jboss.jms.server.destination.QueueService" name="jboss.messaging.destination:service=Queue,name=TestClusteredQueue" xmbean-dd="xmdesc/Queue-xmbean.xml"> <depends>jboss.messaging:service=PostOffice</depends> <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends> <attribute name="Clustered">true</attribute> </mbean>
A sample external consumer
public static void main(String[] args) throws Exception {
System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
System.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
System.setProperty("java.naming.provider.url", "node1:1100,node2:1100");
final InitialContext tInitialContext = new InitialContext();
final ConnectionFactory tConnFactory = (ConnectionFactory) tInitialContext.lookup("ClusteredConnectionFactory");
final Queue tLisaToMfcQueue = (Queue) tInitialContext.lookup("/queue/TestClusteredQueue");
javax.jms.Connection jmsConnection = tConnFactory.createConnection();
Session tSession = jmsConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
System.out.println("from browser");
Enumeration tMessages = tSession.createBrowser(tLisaToMfcQueue).getEnumeration();
while (tMessages.hasMoreElements()) {
Message tMessage = (Message) tMessages.nextElement();
System.out.println(tMessage);
}
System.out.println("from consumer");
final MessageConsumer tConsumer = tSession.createConsumer(tLisaToMfcQueue);
tConsumer.setMessageListener(new MessageListener() {
public void onMessage(final Message pMessage) {
System.out.println(pMessage);
try {
pMessage.acknowledge();
} catch (JMSException e) {
e.printStackTrace();
}
}
});
jmsConnection.setExceptionListener(new ExceptionListener() {
public void onException(final JMSException e) {
System.out.println("got exception");
}
});
jmsConnection.start();
}
So how can i get a standalone consumer getting all messages from the queue