[jboss-user] [JBoss Messaging] - Re: MQ migration help

tnine do-not-reply at jboss.com
Thu May 1 07:54:13 EDT 2008


I haven't forgotten about this, but I have had to put it off while working on production issues.  I'm now reading from the DLQ, however I'm getting very erratic behavior.  Somtimes a read with "receiveNoWait" will return messages on the DLQ, other times I'll have to call it 4 or 5 times before I receive a message, and the message count is > than 0 then viewing the queue on the jmx-console.  I've attached my inner class that manages connections, am I calling something incorrectly?  I'm looking up the connectionFactory via a remote JNDi, location "ClusteredXAConnectionFactory".  Any help/advice would be appreciated.


  | 
  | /**
  | 	 * Inner class to manage connections per thread
  | 	 * 
  | 	 * @author Todd Nine
  | 	 * 
  | 	 */
  | 	private class SynchronousConnectionFactory {
  | 
  | 		private final Logger connectionLogger = Logger
  | 				.getLogger(SynchronousConnectionFactory.class);
  | 
  | 		// instance beans
  | 		private QueueConnection connection;
  | 		private QueueSession session;
  | 
  | 		//pointers passed in during initialization and injection
  | 		private QueueConnectionFactory globalQueueConnectionFactory;
  | 		private Queue globalQueue;
  | 		private QueueReceiver receiver;
  | 
  | 		/**
  | 		 * Default constructor
  | 		 * 
  | 		 * @param connectionFactory
  | 		 * @param queue
  | 		 */
  | 		public SynchronousConnectionFactory(
  | 				QueueConnectionFactory connectionFactory, Queue queue) {
  | 			this.globalQueueConnectionFactory = connectionFactory;
  | 			this.globalQueue = queue;
  | 		}
  | 
  | 		/**
  | 		 * Open the connection to the JMS queue
  | 		 * 
  | 		 * @throws JMSException
  | 		 */
  | 		public void openConnection() throws JMSException {
  | 			connection = getConnection();
  | 
  | 			// create a session that we manually acknowledge so we can ignore
  | 			// messages that
  | 			// don't have the correct payload
  | 			session = connection.createQueueSession(false,
  | 					Session.CLIENT_ACKNOWLEDGE);
  | 
  | 			receiver = session.createReceiver(this.globalQueue);
  | 
  | 			connection.start();
  | 		}
  | 
  | 		/**
  | 		 * Return the message from the jms queue
  | 		 * 
  | 		 * @return
  | 		 * @throws JMSException
  | 		 */
  | 		public Message getMessage() throws JMSException {
  | 			return receiver.receiveNoWait();
  | 		}
  | 
  | 		/**
  | 		 * Close the queue connection
  | 		 * 
  | 		 * @param connection
  | 		 */
  | 		public void closeReceiver() {
  | 			try {
  | 
  | 				
  | 				if (session != null) {
  | 					session.close();
  | 				}
  | 
  | 				if (connection != null) {
  | 					connection.close();
  | 				}
  | 			} catch (JMSException e) {
  | 				connectionLogger.warn("Could not close JMS connection", e);
  | 			}
  | 		}
  | 
  | 		/**
  | 		 * Get the connection from the factory
  | 		 * 
  | 		 * @return
  | 		 * @throws JMSException
  | 		 */
  | 		protected QueueConnection getConnection() throws JMSException {
  | 			return globalQueueConnectionFactory.createQueueConnection();
  | 		}
  | 
  | 	}

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4148095#4148095

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4148095



More information about the jboss-user mailing list