-
1. Re: JBoss Messaging not working as expected
gaohoward May 12, 2009 4:38 AM (in response to fenrizwolf)Does it always happen or sometimes?
-
2. Re: JBoss Messaging not working as expected
ataylor May 12, 2009 5:49 AM (in response to fenrizwolf)How do you know messages are left in the queue?
when are you starting the consumers, messages can be buffered by a client so it may be that the first consumer to connect has all the messages sitting in its buffer.
Post your code so we can take a look. -
3. Re: JBoss Messaging not working as expected
fenrizwolf May 12, 2009 6:14 AM (in response to fenrizwolf)Hi.
I had a look in the JMX interface and there it says that 2 messages are pending in the queue.
There is only one producer, consumer on each queue. So it should not happen that one consumer buffers messages from another queue.
The producer should send 10.000 messages to one queue and the receivers expect to receive 10.000 messages. The receivers will prompt a message when all messages are received.
Producer:
initialization:public void init(String ip, int port, String qname) throws Exception { connection = createConnection(ip, port); connection.start(); session = connection .createQueueSession(false, Session.AUTO_ACKNOWLEDGE); try { q = (Queue) ctx.lookup(qname); } catch (Exception e) { q = session.createQueue(qname); ctx.bind(qname, q); } producer = session.createSender(q); } public QueueConnection createConnection(String ip, int port) throws NamingException, JMSException { try { ctx = (InitialContext) createContext(ip, 1099); } catch (Exception e) { e.printStackTrace(); } QueueConnectionFactory qcf = (QueueConnectionFactory) ctx .lookup("ConnectionFactory"); return qcf.createQueueConnection(); } protected Context createContext(String ip, int port) throws Exception { String host = "jnp://" + ip + ":" + port; return createContext(host); } protected Context createContext(String host) throws Exception { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL, host); props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); return new InitialContext(props); }
sending messages:public void sendMsg(String msgtxt) throws Exception { TextMessage simpleMessage = session.createTextMessage(); simpleMessage.setText(msgtxt); producer.send(simpleMessage); }
Consumer implements MessageListener:
inititalization:private void init(String ip, int port, String qname) throws JMSException, NamingException { connection = createConnection(ip, port); connection.start(); session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); Queue q = session.createQueue(qname); msgConsumer = session.createReceiver(q); msgConsumer.setMessageListener(this); } public QueueConnection createConnection(String ip, int port) throws NamingException, JMSException { try { ctx = (InitialContext) createContext(ip, 1099); } catch (Exception e) { e.printStackTrace(); } ConnectionFactory tmp = (ConnectionFactory) ctx .lookup("ConnectionFactory"); QueueConnectionFactory qcf = (QueueConnectionFactory) tmp; return qcf.createQueueConnection(); } // the default method protected Context createContext(String ip, int port) throws Exception { String host = "jnp://" + ip + ":" + port; return createContext(host); } protected Context createContext(String host) throws Exception { Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL, host); props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); return new InitialContext(props); }
receiving messages:public void onMessage(Message msg) { cnt = cnt + 1; TextMessage txtMsg = (TextMessage) msg; if (cnt == msgToReceive) { running = !running; System.out.println(getClientId() + " Received all msg @ " + System.currentTimeMillis()); cnt = 0; } else if (cnt > msgToReceive) { cnt = 0; } }
-
4. Re: JBoss Messaging not working as expected
ataylor May 12, 2009 6:51 AM (in response to fenrizwolf)Can you try jboss 5.0.1.GA, messaging is the default jms provider with this.
-
5. Re: JBoss Messaging not working as expected
fenrizwolf May 12, 2009 6:54 AM (in response to fenrizwolf)Thanks for the advice, I'm going to try it!
-
6. Re: JBoss Messaging not working as expected
fenrizwolf Jun 10, 2009 6:31 AM (in response to fenrizwolf)Hi.
I've now tried using JBoss AS 5.0.1GA as suggested but the problem remains the same.
Any advice?
Alex -
7. Re: JBoss Messaging not working as expected
timfox Jun 10, 2009 6:40 AM (in response to fenrizwolf)If you create a JIRA and attach a self contained test program that we can run to replicate the issue, someone can take a look at it.
-
8. Re: JBoss Messaging not working as expected
fenrizwolf Jun 15, 2009 5:42 AM (in response to fenrizwolf)Hi!
Can you please tell me the link to JIRA and what do you mean with "self contained test"? Do you mean the source of the program i am using?
So long!
Alex -
9. Re: JBoss Messaging not working as expected
gaohoward Jun 15, 2009 6:35 AM (in response to fenrizwolf)https://jira.jboss.org/jira/browse/JBMESSAGING
If you have a program that can reproduce the issue, it will be perfect for us to solve it. Thanks. -
10. Re: JBoss Messaging not working as expected
gaohoward Jun 16, 2009 8:54 AM (in response to fenrizwolf)Hi, I did a simple test as follows:
1. start up a JBM node which has 5 queues deployed. They are A, B, C, D, E
2. start 5 processes on another machine. Each process continuously sends and receive messages from a different queue.
My results is that all the process works normally, all messages sent have been received.
My question is how long before you find the message delivering start to slow down? -
11. Re: JBoss Messaging not working as expected
fenrizwolf Jul 14, 2009 2:54 AM (in response to fenrizwolf)Hi.
Finally i managed to create a jira task and attached my eclipse project.
If anyone could have a look at it and help me it would be great.
Here is the link to jira: https://jira.jboss.org/jira/browse/JBMESSAGING-1684
Thanks in advance.
@gaohoward: If i use 1 queue it works just fine. Even with 5 queues it works most of the time but with for example 10 queues i never successfully finished a test.
-Alex -
12. Re: JBoss Messaging not working as expected
gaohoward Jul 14, 2009 2:57 AM (in response to fenrizwolf)That's great Alex. I'll take a look. Thanks.
Howard