• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MDB and RuntimeException

 
Sainudheen Mydeen
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
If onMessage method of a MDB throws RuntimeException, What will be effect on the client who sent the message? Does that client get any notification?
Thanks
-Sainudheen
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sainudheen,
The MDB has no client context, so there will be no client notification.
Section 18.3.2 of the specification covers this - basically for any system exception, the exception is logged, the transaction (if any) is marked for rollback, and the bean instance is discarded.
Regards, Andrew
 
Sainudheen Mydeen
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andrew.
In the above context, can you tell me which one of the following option is correct?
a) The client is not able to send messages since the RuntimeException
causes the EJB container to crash.
b) The client looses the JMS connection.
c) The client does not notice anything; the EJB container passes messages
from the JMS server to a different bean instance.
d) The client is not able to send messages since the bean instance is in
the "Does not exist" state.
e) The client receives a special RuntimeException message that acknowledges
that the exception happened.
Thanks
-Sainudheen
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sainudheen,
Only c is correct.
  • The client is not able to send messages since the RuntimeException causes the EJB container to crash.
    Nope - the RuntimeException caused the bean instance to crash, not the container.
    Even if the container was unavailable, this would still not be true - one of the reasons for having messaging systems like JMS is that the producer and the consumer of messages do not have to be online simultaneously. So if the container crashes then the messages should just be queued until the container is restarted.
  • The client looses the JMS connection.
    Nope - the client has a connection to the queue, not to the container or the bean instance. So the client should be unaware of any problems server side.
  • The client does not notice anything; the EJB container passes messages from the JMS server to a different bean instance.
  • The client is not able to send messages since the bean instance is in the "Does not exist" state.
    The client never sends messages to a bean instance - it sends messages to the queue. So this answer is wrong.
  • The client receives a special RuntimeException message that acknowledges that the exception happened.
    Nope - as mentioned before, MDBs do not have a client context, so there is no way that the client can be notified.


  • Regards, Andrew
     
    Sainudheen Mydeen
    Ranch Hand
    Posts: 218
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Andrew.
    -Sainudheen
     
    Vishwa Kumba
    Ranch Hand
    Posts: 1066
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    "The client does not notice anything; the EJB container passes messages from the JMS server to a different bean instance"
    Say, if the onMessage() method of the bean always produces a runtime exception even it is passed to another bean instance.
    Will it go into an infinite loop or will it give up after trying "n" number of times?
     
    Pradeep bhatt
    Ranch Hand
    Posts: 8933
    Firefox Browser Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It will be infinite loop unless the message is removed from the JMS server.
    It is also possible that the JMS server server may provide the option to remove a message which may not be successfully delivered after n retries.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic