• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

MDB and RuntimeException

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Andrew.
    -Sainudheen
     
    Ranch Hand
    Posts: 1066
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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?
     
    Ranch Hand
    Posts: 8945
    Firefox Browser Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
    We need your help - Coderanch server fundraiser
    https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    reply
      Bookmark Topic Watch Topic
    • New Topic