This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Message lost or are not pulled by MDB

 
Raymond Ong
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a pool of MDBs listening to a queue. I bombard the queue with 1000 messages concurrently (I made an app that creates 1000 threads that each sends a JMS message to the queue all at the same time approximately). The messages in the queue are persisted in a MySQL database.

As the onMessage() method of the MDB is triggered, I log that event to a file. I'm wondering why sometimes, I dont get 1000 logs which I expect and instead get logs less than 1000.

There are times when a number of messages stay stuck on the queue even if there are active MDBs listening. I can say the MDBs are listening because when I send a JMS message, it gets processed, yet the previously stuck messages remain stucked.

I suspect It has something to do with the memory. I tried to cut down the number of threads into half, so that's 500 concurrent messages sent to the queue and out of the 12 times I tested, only once did I not receive all 500. I lost about 48 messages, which neither was logged (pulled by MDB) nor exists in the queue.

Another reason I suspect the memory is because I stripped down my onMessage() method. I simply logged into a file. I haven't lost any message even If there were 1000 threads that sent the jms messages concurrently.

Here's my ejb-jar.xml


Here's my jboss.xml


My threads are set to send the message with the following settings:
priority=1
timeout=30000ms

My queue settings:
redelivery=3
redeliverywait=3000ms

I'm on a development pc:
P4 3.06GHz
512RAM
WinXP Home
using JBoss 4.0.2, MySQL 4.1

Is this a tweaking issue or a programming issue?
How do I tweak JBoss so JMS will behave as expected?
Any help is appreciated.

Thank you very much.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Curious problem. What is your JMS provider? You mentioned the messages are backed by a database ... is that a "persistant queue" setting?

Are your queues and the database fully transactional? A committed put should be on queue and persisted for assured delivery. You mentioned in the 500 thread test that some messages were not picked up or left in queue which makes me wonder if the put worked. Make sure you commit somehow & check results.

Items left in queue sound buggy for sure. JMS should trigger onMessage for all messages unless something isn't really thread safe in there somwhere.
 
Raymond Ong
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
Curious problem. What is your JMS provider? You mentioned the messages are backed by a database ... is that a "persistant queue" setting?

Are your queues and the database fully transactional? A committed put should be on queue and persisted for assured delivery. You mentioned in the 500 thread test that some messages were not picked up or left in queue which makes me wonder if the put worked. Make sure you commit somehow & check results.

Items left in queue sound buggy for sure. JMS should trigger onMessage for all messages unless something isn't really thread safe in there somwhere.


I have set JBoss JMS to persist the messages to MySQL. The JMS message tables are InnoDB so it supports transactions. In the 12 times that I've created 500 threads to simultaneously sent JMS messages, only 1 failed. For the failed test around 50 messages of the total 500 were lost. It's pretty weird since the destination specified in the JMS message table is my original queue name, which means I messages are not being pulled by the MDBs which I am certain are alive. If the messages had been processed previously and the number of resending attempts has lapsed then the destination would have been my dead letter queue.

I will try to integrate JBoss with ActiveMQ and see how it goes.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic