  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Regarding JMS | Regarding JMS 2004-07-06 - By Michael Marson
Back
With respect to the answer to #4 below, I respectfully disagree that the answer is "No". It is true that there is no standard "client" as such, but an MDB can participate in a transaction, and if the transaction is rolled back the message will be retained on the queue for redelivery, if configured as such. I believe this is part of the JMS spec not a vendor-specific extension (we are using Weblogic 8.1), but we are relying on the transactional nature of JMS, and the ability to have multiple redelivery attempts, heavily in the project I am currently working on. WLS also has error destinations where you can place "failed" messages, so that you never truly discard messages, unless you choose to. Again, I am not sure if this is part of the spec or vendor-specific, so other servers may offer comparable functionality.
Hard-won side note on MDB drawbacks: if your MDB does any type of db work (such as save message content to a database), you need to use an XA transaction because a JMS provider is always its own resource manager, even if the JMS store is a (the same) database.
-- --Original Message-- -- From: ashraf galal [mailto:ashrafwg@(protected)] Sent: Sunday, July 04, 2004 5:33 PM Subject: Re: Regarding JMS
K.Pushparaj wrote: We are using weblogic JMS Queue and MDB in our system. I am having some questions on the same 1) Is there any pattern available for using message beans. &nbs
p; The implementation of MDB uses some sort of the observer pattern 2) Where can I get the details about drawbacks of using MDB. J2EE specification (section 17 of EJB 2.0 specification ) or any J2EE book, I recommend the expert one by one by Rod Johnson 3) Can I use MDB as a normal stateless session bean including database transaction. MDB does not have either a home interface nor remote interface, so it is not visible to the client, Whereas the session beans are. MDB is a message consumers, it does not have a client view. Transaction in MDB have to be committed before the OnMessage() method returns. I don't think that possible since that means the instances of a message driven bean are equivalent.
4) If any exception happens can the message will be retained so that it will be served next time
MDB can throw system exception upon which the container discards the bean instance. However, the exceptions are not propagated to the client, since there are no clients. So, MDB cannot throw application exception. The answer is No. Ashraf Galal
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML xmlns:o = "urn:schemas-microsoft-com:office:office"><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"> <TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD> <BODY> <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV> <DIV><SPAN class=969450805-06072004><FONT face=Arial color=#0000ff size=2>With respect to the answer to #4 below, I respectfully disagree that the answer is "No". It is true that there is no standard "client" as such, but an MDB can participate in a transaction, and if the transaction is rolled back the message will be retained on the queue for redelivery, if configured as such. I believe this is part of the JMS spec not a vendor-specific extension (we are using Weblogic 8.1), but we are relying on the transactional nature of JMS, and the ability to have multiple redelivery attempts, heavily in the project I am currently working on. WLS also has error destinations where you can place "failed" messages, so that you never truly discard messages, unless you choose to. Again, I am not sure if this is part of the spec or vendor-specific, so other servers may offer comparable functionality.</FONT></SPAN></DIV> <DIV><SPAN class=969450805-06072004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=969450805-06072004><FONT face=Arial color=#0000ff size=2>Hard-won side note on MDB drawbacks: if your MDB does any type of db work (such as save message content to a database), you need to use an XA transaction because a JMS provider is always its own resource manager, even if the JMS store is a (the same) database. </FONT></SPAN></DIV> <DIV><SPAN class=969450805-06072004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><SPAN class=969450805-06072004><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV><FONT face=Tahoma size=2>-- --Original Message-- --<BR><B>From:</B> ashraf galal [mailto:ashrafwg@(protected)] <BR><B>Sent:</B> Sunday, July 04, 2004 5:33 PM<BR><B>Subject:</B> Re: Regarding JMS<BR><BR></FONT></DIV> <BLOCKQUOTE style="MARGIN-RIGHT: 0px"> <DIV><PRE><SPAN style="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS">K.Pushparaj wrote:<o:p></o:p></FONT></FONT></SPAN></PRE><PRE><SPAN style= "COLOR: black"><FONT size=2><FONT face="Arial Unicode MS"> We are using weblogic JMS Queue and MDB in our system. I am having<o:p></o:p></FONT></FONT></SPAN></PRE><PRE><SPAN style="COLOR: black "><FONT size=2><FONT face="Arial Unicode MS">some questions on the same<o:p></o :p></FONT></FONT></SPAN></PRE><PRE><SPAN style="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS"> 1) Is there any pattern available for using message beans.<o:p></o:p></FONT></FONT></SPAN>< /PRE><PRE><FONT size=2><FONT face="Arial Unicode MS"><SPAN style="COLOR: black"> <SPAN style="mso-spacerun: yes"> &nbs p; </SPAN></SPAN><SPAN style="COLOR: blue">The implementation of MDB</SPAN> <SPAN style="COLOR: black"> </SPAN><SPAN style="COLOR: blue"><SPAN style="mso -spacerun: yes"> </SPAN>uses some sort of the observer pattern<o:p></o:p>< /SPAN></FONT></FONT></PRE><PRE><SPAN style="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS"> 2) Where can I get the details about drawbacks of using MDB.<o:p></o:p></FONT></FONT></SPAN> </PRE><PRE><SPAN style="COLOR: blue"><FONT size=2><FONT face="Arial Unicode MS"> <SPAN style="mso-spacerun: yes"> </SPAN>J2EE specification (section 17 of EJB 2.0 specification ) or any J2EE book, </FONT></FONT></SPAN></PRE><PRE><SPAN style= "COLOR: blue"><FONT size=2><FONT face="Arial Unicode MS">I recommend the expert one by one by Rod Johnson<o:p></o:p></FONT></FONT></SPAN></PRE><PRE><SPAN style ="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS "> 3) Can I use MDB as a normal stateless session bean including<o:p></o:p></FONT></FONT></SPAN></PRE><PRE><SPAN style= "COLOR: black"><FONT size=2><FONT face="Arial Unicode MS">database transaction. <o:p></o:p></FONT></FONT></SPAN></PRE><PRE><FONT size=2><FONT face="Arial Unicode MS"><SPAN style="COLOR: black"><SPAN style="mso-tab-count: 1"> < /SPAN></SPAN><SPAN style="COLOR: blue">MDB does not have either a home interface nor remote interface, so it is not visible </SPAN></FONT></FONT></PRE><PRE> <FONT size=2><FONT face="Arial Unicode MS"><SPAN style="COLOR: blue">to the client, Whereas the session beans are. MDB is a message consumers, </SPAN>< /FONT></FONT></PRE><PRE><FONT size=2><FONT face="Arial Unicode MS"><SPAN style= "COLOR: blue">it does not have a client view. </SPAN></FONT></FONT></PRE><PRE> <FONT size=2><FONT face="Arial Unicode MS"><SPAN style="COLOR: blue">Transaction in MDB have to be committed before the OnMessage() method returns. </SPAN>< /FONT></FONT></PRE><PRE><FONT size=2><FONT face="Arial Unicode MS"><SPAN style= "COLOR: blue">I don’t think that possible since that means the instances of a message driven bean </SPAN></FONT></FONT></PRE><PRE><FONT size=2><FONT face="Arial Unicode MS"><SPAN style="COLOR: blue">are equivalent. <SPAN style= "mso-spacerun: yes"> </SPAN><o:p></o:p></SPAN></FONT></FONT></PRE><PRE> <SPAN style="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS"><SPAN style="mso-spacerun: yes"> </SPAN><o:p></o:p></FONT></FONT></SPAN></PRE> <PRE><SPAN style="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS">  ; 4) If any exception happens can the message will be retained so that<o:p></o:p></FONT></FONT></SPAN></PRE><PRE> <SPAN style="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS">it will be served next time<o:p></o:p></FONT></FONT> </SPAN></PRE><PRE><SPAN style="COLOR: blue"><FONT size=2><FONT face="Arial Unicode MS">MDB can throw system exception upon which the container discards the bean instance. </FONT></FONT></SPAN></PRE><PRE><SPAN style="COLOR: blue"> <FONT size=2><FONT face="Arial Unicode MS">However, the exceptions are not propagated to the client, since there are no clients.<SPAN style="mso-spacerun: yes"> </SPAN></FONT></FONT></SPAN></PRE><PRE><SPAN style="COLOR: blue"> <FONT size=2><FONT face="Arial Unicode MS"><SPAN style="mso-spacerun: yes">< /SPAN>So, MDB cannot throw application exception. The answer is No. <o:p></o:p>< /FONT></FONT></SPAN></PRE><PRE><SPAN style="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS"> Ashraf Galal<o:p></o:p></FONT></FONT></SPAN></PRE ><PRE><SPAN style="COLOR: black"><FONT size=2><FONT face="Arial Unicode MS"> <o:p></o:p></FONT></FONT></SPAN></PRE><PRE><SPAN style="COLOR: black"> <FONT size=2><FONT face="Arial Unicode MS"></FONT></SPAN></PRE></DIV></FONT>< /BLOCKQUOTE></BODY></HTML> ==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|
 |