Hi,
we are using JBM 1.4.0.SP3 configured in a cluster. We have a four node
cluster and use custom correlation ids to correlate messages.
Our messaging clients post a message to a queue and wait a specified amount of
time for a message to appear on a response queue with the correlation id they
expect.
Now the problem we are experiencing is that when several concurrent calls are
made sometimes we are not able to retrieve the message from the clustered
queue. We have verified that the message is infact there, with the correct
correlation id.
We have tried to simulate this behaviour with the test class below.
| public class DestinationPeeker
| {
|
| private static final String QUEUE_NAME = "queue/clusteredQueue";
| private static final String JNDI_SERVER = "hostname:1100";
|
| private static final String CORRELATION_ID = "12345";
|
| private static String messageSelector = "JMSCorrelationID = \'" +
CORRELATION_ID + "\'";
|
| @Test
| public void peek() throws NamingException, JMSException
| {
| Context ctx = getContext();
| Queue queue = (Queue) ctx.lookup( QUEUE_NAME );
| QueueConnectionFactory factory = (QueueConnectionFactory)
ctx.lookup( "ConnectionFactory" );
| QueueConnection cnn = factory.createQueueConnection();
| QueueSession session = cnn.createQueueSession( false,
QueueSession.AUTO_ACKNOWLEDGE );
|
| QueueBrowser browser = session.createBrowser( queue,
messageSelector );
| String messageSelector = browser.getMessageSelector();
|
| Enumeration enumeration = browser.getEnumeration();
| while ( enumeration.hasMoreElements() ) {
| Message jmsMsg = (Message) enumeration.nextElement();
| System.out.print( "JMSMessageID : " +
jmsMsg.getJMSMessageID() );
| System.out.print( ", JMSCorrelelationID : " +
jmsMsg.getJMSCorrelationID() );
| System.out.print( ", JMSExpiration : " +
jmsMsg.getJMSExpiration() );
| System.out.println("");
| }
| browser.close();
| session.close();
| cnn.close();
| }
|
| @Test
| @Ignore
| public void putMessageOnQueue() throws NamingException, JMSException
| {
| Context ctx = getContext();
| Queue queue = (Queue) ctx.lookup( QUEUE_NAME );
| QueueConnectionFactory factory = ( QueueConnectionFactory )
ctx.lookup( "/ClusteredConnectionFactory" );
| QueueConnection cnn = factory.createQueueConnection();
| QueueSession session = cnn.createQueueSession( false,
QueueSession.AUTO_ACKNOWLEDGE );
| MessageProducer producer = session.createProducer( queue );
| TextMessage msg = session.createTextMessage();
| msg.setJMSCorrelationID( CORRELATION_ID );
| producer.send( msg );
| producer.close();
| session.close();
| cnn.close();
| ctx.close();
| }
|
| private Context getContext() throws NamingException
| {
| Hashtable<String, String> env = new Hashtable<String, String>();
| env.put( Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory" );
| env.put( Context.URL_PKG_PREFIXES, "org.jboss.naming" );
| env.put( Context.PROVIDER_URL, JNDI_SERVER );
| return new InitialContext(env);
| }
| }
|
Note that we are using a QueueBrowser to peek a the queue. I've tried this by
consuming from the queue and seen the same behaviour.
When I run the above (having run once with only executing putMessageOnQueue())
I sometimes get a messages back and sometimes don't. It's not deterministic.
Is this a valid way to verfiy the functionality of clustering with message
correlation id's?
Has anyone see this sort of behaviour before?
Any comments or suggestions are welcome.
Thanks,
/Daniel
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4126475#4126475
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4126475
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user