Message Bean and JMS - messages not disappearing from queue

C

Chris

Hi,

I've written a message bean that monitors a JMS queue and successfully runs.
I made changes to the onMessage method to include a new piece of code which
due to another error threw an exception. When I wasn't catching this
exception the onMessage method didn't complete and so the message wasn't
removed from the queue. As a result there were endless calls to onMesssage.

Why did this mean the message was left on the queue? Is there any way to
force the message to be removed?

When I swallowed the exception the method completed and the bean was
removed. However I then introduced a new piece of code (call to a stateless
session bean) which threw an exception. However this time while attempting
to swallow that exception in it's originating class (I was catching
Throwable) the bean wasn't removed and again there were endless calls to
onMessage.

Any ideas why this could be. I thought by catching Throwable and not
propagating the exception there would be no reason for the onMessage method
to not complete.

Thanks for any suggestions

Chris
 
C

Chris

I've written a message bean that monitors a JMS queue and successfully
runs.
I made changes to the onMessage method to include a new piece of code which
due to another error threw an exception. When I wasn't catching this
exception the onMessage method didn't complete and so the message wasn't
removed from the queue. As a result there were endless calls to onMesssage.

Why did this mean the message was left on the queue? Is there any way to
force the message to be removed?

When I swallowed the exception the method completed and the bean was
removed. However I then introduced a new piece of code (call to a stateless
session bean) which threw an exception. However this time while attempting
to swallow that exception in it's originating class (I was catching
Throwable) the bean wasn't removed and again there were endless calls to
onMessage.

Any ideas why this could be. I thought by catching Throwable and not
propagating the exception there would be no reason for the onMessage method
to not complete.

I found a solution now in case anyone's interested - I started my call to
the session bean in a new thread

It seemed the time it was taking to call the session bean interrupted the
onMessage method
 
R

Raymond DeCampo

Chris said:
I found a solution now in case anyone's interested - I started my call to
the session bean in a new thread

It seemed the time it was taking to call the session bean interrupted the
onMessage method

Am I to understand that you started a new thread in your MDB onMessage()
method? This is a violation of the EJB specification which prohibits
EJBs from creating threads. I'd encourage you to look for a better
solution as your current one may be fragile.

HTH,
Ray
 
C

Chris

Am I to understand that you started a new thread in your MDB onMessage()
method? This is a violation of the EJB specification which prohibits
EJBs from creating threads. I'd encourage you to look for a better
solution as your current one may be fragile.
Yeah good point, threads in EJBs is a big no no.

I found a better solution. The problem was due to a deep level exception
thrown by a database driver which wasn't being propagated up the call stack.
It was however forcing the transaction on the message bean to roll back. I
therefore fixed this by making my bean non-transactional.

Also changing the redelivery tries from infinite to 0 on the JMS queue
stopped the continuous redelivery of the message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top