Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JBoss User Help »

[jboss-user] [Messaging,
 JMS & JBossMQ] - DLQ and caught exception in onMessage

scott.stark@jboss.org

2007-06-13


Hi, I have the following problem: I have a MDB (EJB 3.0 on AS: 4.0.5.GA) that consumes messages from a queue. In the onMessage method I am calling the method of a Stateless Session Bean (injected with SEAM-mechanism).


| public void onMessage( Message msg )
| {
|
|  // extract userId and type from msg - both string variable
|  try{
|  this.requestManager.insert(userId, type) // stateless session bean injected with seam
|  catch ( JMSException e ){
|  e.printStackTrace();
|  }
| }
|

The insert Method is as follows:

| public void insertPemRequest( String userId, String type )
| {
| Person person = new Person( userId, type );
| try
| {
|  this.entityManager.persist( examRequest );
|  this.entityManager.flush();
|
|  // create business process in jbpm
| }
| catch ( ConstraintViolationException exp ){
|   // do nothing, i.e do not kick off new business process
| }
| catch ( EntityExistsException entityEx ) {
|   // do nothing, i.e do not kick off new business process
| }
| }
|

The Person Bean has unique constraint on userId and type: i.e:

| @Entity
| @Table( uniqueConstraints= {@(protected)"}) } )
| public class Person {
| // ---- getter/setter for id, name, type
| }
|

By catching the EntityExistsException I want to avoid that a business process is kicked off twice for the same person and type. As there might be many messages send and consumed in parallel all requesting to kick off a business process for one person and type combination - this is a good way to control that a business process is kicked off once and once only for a name/type combination.

Now my problem: The message is still redelivered and send to the DLQ, altough I caught the EntityExistsException. All other exceptions should lead to sending the message to DLQ. But not the EntityExistsException as this is a "tolerated" exception. I know from FAQ

anonymous wrote :
| What type of Exceptions should an MDB throw?
| The quick answer is none.
|

But I am catching the exception. right? Or is this correct behaviour and I have to change my design that no EntityExistsException is thrown?

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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4053862
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.