[jboss-user] [JBoss Messaging Users] - Simple example but failing to get onMessage called

glynbach do-not-reply at jboss.com
Tue Dec 1 10:23:27 EST 2009


Hi

I wonder if someone could point out what I might be doing wrong here. The JBoss installation is out of the box and running in default mode. The queue seems to be correctly added in the destinations-service.xml (as in I can see it when I do a naming lookup). The producer seems to be sending messages to the queue fine. There aren't any errors subscribing to the queue. But the onMessage isn't getting called.

My code is:


  | import java.io.Serializable;
  | import java.util.Properties;
  | 
  | import javax.jms.Connection;
  | import javax.jms.ConnectionFactory;
  | import javax.jms.JMSException;
  | import javax.jms.Message;
  | import javax.jms.MessageConsumer;
  | import javax.jms.MessageListener;
  | import javax.jms.MessageProducer;
  | import javax.jms.ObjectMessage;
  | import javax.jms.Queue;
  | import javax.jms.QueueConnection;
  | import javax.jms.Session;
  | import javax.jms.TextMessage;
  | import javax.naming.InitialContext;
  | import javax.naming.NamingException;
  | 
  | public class QueueTest {
  | 	
  | 	InitialContext ic = null;
  | 	ConnectionFactory cf = null;
  | 	Queue queue = null;
  | 	
  | 	public static void main(String[] args) {
  | 		new QueueTest();
  | 	}
  | 	
  | 	public QueueTest() {
  | 		try {
  | 			Properties properties = new Properties();
  | 			properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
  | 			properties.setProperty("java.naming.provider.url", "localhost");
  | 			properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");			
  | 			ic = new InitialContext(properties);
  | 			
  | 			cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
  | 			queue = (Queue)ic.lookup("/queue/FixiOrderQueue");
  | 			
  | 			QueueConsumer consumer = new QueueConsumer();
  | 			consumer.start();
  | 			QueueProducer producer = new QueueProducer();
  | 			producer.start();
  | 			
  | 		} catch (NamingException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		} 
  | 	}
  | 	
  | 	private class QueueProducer extends Thread {
  | 		
  | 		Session session = null;
  | 		MessageProducer producer = null;
  | 		
  | 		public QueueProducer() {
  | 			Connection connection;
  | 			try {
  | 				connection = cf.createConnection();
  | 				session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  | 				producer = session.createProducer(queue);
  | 			} catch (JMSException e) {
  | 				// TODO Auto-generated catch block
  | 				e.printStackTrace();
  | 			}
  | 		}
  | 		
  | 		public void run() {
  | 			while (true) {
  | 				try {
  | 					Thread.sleep(5000);
  | 					Thread.yield();
  | 				} catch (InterruptedException e) {
  | 					// TODO Auto-generated catch block
  | 					e.printStackTrace();
  | 				}
  | 				try {
  | 					//ObjectMessage message = session.createObjectMessage();
  | 					//message.setObject(new TestMessage());
  | 					TextMessage message = session.createTextMessage();
  | 					message.setText("Yo");
  | 					producer.send(message);
  | 					System.out.println("Sent message");
  | 				} catch (JMSException e) {
  | 					// TODO Auto-generated catch block
  | 					e.printStackTrace();
  | 				}
  | 			}
  | 		}
  | 	}
  | 	
  | 	private class QueueConsumer extends Thread implements MessageListener {
  | 
  | 		public QueueConsumer() {
  | 			try {
  | 				Connection connection = cf.createConnection();
  | 				Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  | 				MessageConsumer consumer = session.createConsumer(queue);
  | 				consumer.setMessageListener(this);
  | 			} catch (JMSException e) {
  | 				// TODO Auto-generated catch block
  | 				e.printStackTrace();
  | 			}
  | 		}
  | 		
  | 		public void run() {
  | 			try {
  | 				Thread.sleep(10);
  | 				Thread.yield();
  | 			} catch (InterruptedException e) {
  | 				// TODO Auto-generated catch block
  | 				e.printStackTrace();
  | 			}
  | 		}
  | 
  | 		public void onMessage(Message message) {
  | 			System.out.println("Received " + message);
  | 		}
  | 	}
  | 	
  | 	private class TestMessage implements Serializable {
  | 		
  | 		private long systemTimeInMillis;
  | 		
  | 		public TestMessage() {
  | 			systemTimeInMillis = System.currentTimeMillis();
  | 		}
  | 
  | 		public long getSystemTimeInMillis() {
  | 			return systemTimeInMillis;
  | 		}
  | 
  | 		public void setSystemTimeInMillis(long systemTimeInMillis) {
  | 			this.systemTimeInMillis = systemTimeInMillis;
  | 		}
  | 
  | 	}
  | }
  | 

The System.out is below, if anything looks out of place in it please let me know. Thanks for any advice

DEBUG [01 Dec 2009 15:14:39,160] - createSocket, hostAddr: localhost/127.0.0.1, port: 1099, localAddr: null, localPort: 0, timeout: 0
DEBUG [01 Dec 2009 15:14:39,919] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:39,920] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:39,920] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:39,920] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] constructed
DEBUG [01 Dec 2009 15:14:39,920] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:39,921] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:39,921] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:39,922] - Setting ping frequency to: 214748364
DEBUG [01 Dec 2009 15:14:39,923] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] connecting
DEBUG [01 Dec 2009 15:14:39,923] - Creating semaphore with size 50
DEBUG [01 Dec 2009 15:14:39,926] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] connected
DEBUG [01 Dec 2009 15:14:40,537] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting maxPoolSize to 200
DEBUG [01 Dec 2009 15:14:40,537] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:40,537] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:40,537] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:40,538] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] constructed
DEBUG [01 Dec 2009 15:14:40,541] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting maxPoolSize to 200
DEBUG [01 Dec 2009 15:14:40,541] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:40,541] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:40,542] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:40,542] - Setting ping frequency to: 214748364
DEBUG [01 Dec 2009 15:14:40,542] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] connecting
DEBUG [01 Dec 2009 15:14:40,542] - Creating semaphore with size 200
DEBUG [01 Dec 2009 15:14:40,542] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] connected
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting maxPoolSize to 1
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] constructed
DEBUG [01 Dec 2009 15:14:40,771] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting maxPoolSize to 1
DEBUG [01 Dec 2009 15:14:40,771] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:40,771] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:40,772] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:40,772] - Setting ping frequency to: 214748364
DEBUG [01 Dec 2009 15:14:40,772] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] connecting
DEBUG [01 Dec 2009 15:14:40,772] - Creating semaphore with size 1
DEBUG [01 Dec 2009 15:14:40,772] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] connected
DEBUG [01 Dec 2009 15:14:40,807] - starting callback Connector: InvokerLocator [bisocket://192.168.0.7:1743590291/callback?callbackServerHost=192.168.0.7&callbackServerPort=1743590291&callbackServerProtocol=bisocket&clientMaxPoolSize=1&clientSocketClass=org.jboss.jms.client.remoting.ClientSocketWrapper&datatype=jms&guid=5c4o07-4avrks-g2ot8evd-1-g2ot8fm2-8&isCallbackServer=true&onewayThreadPool=org.jboss.jms.server.remoting.DirectThreadPool&serverSocketClass=org.jboss.jms.server.remoting.ServerSocketWrapper]
DEBUG [01 Dec 2009 15:14:40,880] - SocketServerInvoker[192.168.0.7:1743590291] did not find server socket factory configuration as mbean service or classname. Creating default server socket factory.
DEBUG [01 Dec 2009 15:14:40,881] - SocketServerInvoker[192.168.0.7:1743590291] created server socket factory javax.net.DefaultServerSocketFactory at 5a199939
DEBUG [01 Dec 2009 15:14:40,881] - SocketServerInvoker[192.168.0.7:1743590291] setting pingFrequency to 214748364
DEBUG [01 Dec 2009 15:14:40,881] - SocketServerInvoker[192.168.0.7:1743590291] setting pingWindowFactor to 10
DEBUG [01 Dec 2009 15:14:40,886] - org.jboss.remoting.transport.Connector at 651db6bb started
DEBUG [01 Dec 2009 15:14:40,895] - ServerInvoker (SocketServerInvoker[192.168.0.7:1743590291]) added client callback handler CallbackManager[71bfc4fc] with session id of 5c4o07-4avrks-g2ot8evd-1-g2ot8fdc-4+5c4o07-4avrks-g2ot8evd-1-g2ot8fp3-9 and callback handle object of null.
DEBUG [01 Dec 2009 15:14:40,896] - removed org.jboss.remoting.transport.local.LocalClientInvoker at 506835fb from registry
DEBUG [01 Dec 2009 15:14:40,896] - getting secondary locator
DEBUG [01 Dec 2009 15:14:40,904] - secondary locator: InvokerLocator [null://127.0.0.1:4017/?]
DEBUG [01 Dec 2009 15:14:40,904] - creating control connection: InvokerLocator [null://127.0.0.1:4017/?]
DEBUG [01 Dec 2009 15:14:40,907] - SocketServerInvoker[192.168.0.7:1743590291] created control connection (5c4o07-4avrks-g2ot8evd-1-g2ot8fp3-9): Socket[addr=/127.0.0.1,port=4017,localport=50346]
DEBUG [01 Dec 2009 15:14:41,045] - ConnectionValidator[7054f9f1:null, pingPeriod=10000 ms] created
DEBUG [01 Dec 2009 15:14:41,045] - ConnectionValidator[7054f9f1:null, pingPeriod=10000 ms]: pingPeriod:  10000
DEBUG [01 Dec 2009 15:14:41,045] - ConnectionValidator[7054f9f1:null, pingPeriod=10000 ms]: pingTimeout: 5000
DEBUG [01 Dec 2009 15:14:41,046] - ConnectionValidator[7054f9f1:null, pingPeriod=10000 ms]: ping retries: 1
DEBUG [01 Dec 2009 15:14:41,055] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] constructed
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:41,056] - Setting ping frequency to: 214748364
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] connecting
DEBUG [01 Dec 2009 15:14:41,057] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] connected
DEBUG [01 Dec 2009 15:14:41,058] - ConnectionValidator[7054f9f1:SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457], pingPeriod=10000 ms] started
DEBUG [01 Dec 2009 15:14:41,573] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] added client with session ID 5c4o07-4avrks-g2ot8evd-1-g2ot8g81-d to the lease pinger
DEBUG [01 Dec 2009 15:14:41,574] - starting callback Connector: InvokerLocator [bisocket://192.168.0.7:1744242764/callback?callbackServerHost=192.168.0.7&callbackServerPort=1744242764&callbackServerProtocol=bisocket&clientMaxPoolSize=1&clientSocketClass=org.jboss.jms.client.remoting.ClientSocketWrapper&datatype=jms&guid=5c4o07-4avrks-g2ot8evd-1-g2ot8g85-f&isCallbackServer=true&onewayThreadPool=org.jboss.jms.server.remoting.DirectThreadPool&serverSocketClass=org.jboss.jms.server.remoting.ServerSocketWrapper]
DEBUG [01 Dec 2009 15:14:41,583] - SocketServerInvoker[192.168.0.7:1744242764] did not find server socket factory configuration as mbean service or classname. Creating default server socket factory.
DEBUG [01 Dec 2009 15:14:41,583] - SocketServerInvoker[192.168.0.7:1744242764] created server socket factory javax.net.DefaultServerSocketFactory at 5a199939
DEBUG [01 Dec 2009 15:14:41,584] - SocketServerInvoker[192.168.0.7:1744242764] setting pingFrequency to 214748364
DEBUG [01 Dec 2009 15:14:41,584] - SocketServerInvoker[192.168.0.7:1744242764] setting pingWindowFactor to 10
DEBUG [01 Dec 2009 15:14:41,584] - org.jboss.remoting.transport.Connector at 3496212a started
DEBUG [01 Dec 2009 15:14:41,584] - ServerInvoker (SocketServerInvoker[192.168.0.7:1744242764]) added client callback handler CallbackManager[525c7734] with session id of 5c4o07-4avrks-g2ot8evd-1-g2ot8g81-d+5c4o07-4avrks-g2ot8evd-1-g2ot8g8g-g and callback handle object of null.
DEBUG [01 Dec 2009 15:14:41,585] - removed org.jboss.remoting.transport.local.LocalClientInvoker at 6c5b675e from registry
DEBUG [01 Dec 2009 15:14:41,585] - getting secondary locator
DEBUG [01 Dec 2009 15:14:41,587] - secondary locator: InvokerLocator [null://127.0.0.1:4017/?]
DEBUG [01 Dec 2009 15:14:41,587] - creating control connection: InvokerLocator [null://127.0.0.1:4017/?]
DEBUG [01 Dec 2009 15:14:41,587] - SocketServerInvoker[192.168.0.7:1744242764] created control connection (5c4o07-4avrks-g2ot8evd-1-g2ot8g8g-g): Socket[addr=/127.0.0.1,port=4017,localport=50347]
DEBUG [01 Dec 2009 15:14:41,599] - ConnectionValidator[ad72200:null, pingPeriod=10000 ms] created
DEBUG [01 Dec 2009 15:14:41,599] - ConnectionValidator[ad72200:null, pingPeriod=10000 ms]: pingPeriod:  10000
DEBUG [01 Dec 2009 15:14:41,599] - ConnectionValidator[ad72200:null, pingPeriod=10000 ms]: pingTimeout: 5000
DEBUG [01 Dec 2009 15:14:41,599] - ConnectionValidator[ad72200:null, pingPeriod=10000 ms]: ping retries: 1
DEBUG [01 Dec 2009 15:14:41,600] - ConnectionValidator[ad72200:SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457], pingPeriod=10000 ms] started
Sent message
Sent message

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

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



More information about the jboss-user mailing list