Java Mailing List Archive

http://www.junlu.com/

Google
Google
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
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
JSP - A mailing list about Java Server Pages specification and reference
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Spam:Re: Using JMS in a session bean

Spam:Re: Using JMS in a session bean

2004-10-30       - By Partha Ranjan Das

 Back
It is not right to have a synchronous approach for a solution that is designed
to be asynchronous. Your session bean should not be made to wait as it is not
designed for such a scenario. Session beans should used and immediatly released
. The bean that fits your scenario is a message-driven bean approach where you
receive the message in the onMessage() method of an MDB and do the processing
for that message. Send the messgae form your present session bean and let the
MDB take care of the receiving and follow-up action in the other end. I think
it will not harm your logic and you will be able to segregate the sending and
receiving parts into two different beans.

Regards,
Partha

> -- ---- --
> From:         A mailing list for Java(tm) 2 Platform, Enterprise Edition[SMTP
:J2EE-INTEREST@(protected)] on behalf of Singla, Munish K.[SMTP:MSingla@(protected)
.COM]
> Sent:         Saturday, October 30, 2004 12:51 AM
> To:   J2EE-INTEREST@(protected)
> Subject:      Spam:Re: Using JMS in a session bean
>
> You might want to try out with a higher value for timeout in receive
> call before assuming it is something else.
>
> -- --Original Message-- --
> From: John Lohr [mailto:johnlohr12@(protected)]
> Sent: Friday, October 15, 2004 12:35 AM
> To: J2EE-INTEREST@(protected)
> Subject: Using JMS in a session bean
>
> Hello,
>
> Please would you know if I can send a message and then receive a
> response message in one method from stateless session bean. Seems to me
> that the messages that the bean is sending are placed on the queue when
> the execution of the bean method is finished thus it can never receive
> the response. If it is so how can that be resolved. Any pattern .. ? The
> code below works fine in a servlet but in a session bean it always
> timeouts. I am using Embeded messaging in WebSphere and there is a plain
> Java receiver of messages from the bean and it is sending responses
> back.
>
> Thank you,
> John
>
> sessionBeanMethod() {
>    ....
>     ....
>     connection = factory.createQueueConnection();
>     QueueSession session = connection.createQueueSession(false,
> Session.AUTO_ACKNOWLEDGE);
>     QueueSender sender = session.createSender(requestQueue);
>     QueueReceiver receiver = session.createReceiver(responseQueue,
> selector);
>     connection.start();
>     TextMessage requestMessage = session.createTextMessage("message");
>     requestMessage.setJMSCorrelationID(messageID);
>     sender.send(requestMessage);
>     Message responseMessage = receiver.receive(5000);
>   ....
> }
>
> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
> On the road to retirement? Check out MSN Life Events for advice on how
> to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
>
> ========================================================================
> ===
> To unsubscribe, send email to listserv@(protected) and include in the
> body of the message "signoff J2EE-INTEREST".  For general help, send
> email to listserv@(protected) and include in the body of the message
> "help".
>
> ===========================================================================
> To unsubscribe, send email to listserv@(protected) and include in the body
> of the message "signoff J2EE-INTEREST".  For general help, send email to
> listserv@(protected) and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>RE: Spam:Re: Using JMS in a session bean</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT COLOR="#0000FF" SIZE=2>It is not right to have a synchronous approach
for a solution that is designed to be asynchronous. Your session bean should
not be made to wait as it is not designed for such a scenario. Session beans
should used and immediatly released. The bean that fits your scenario is a
message-driven bean approach where you receive the message in the onMessage()
method of an MDB and do the processing for that message. Send the messgae form
your present session bean and let the MDB take care of the receiving and follow
-up action in the other end. I think it will not harm your logic and you will be
able to segregate the sending and receiving parts into two different beans.<
/FONT></P>

<P><FONT COLOR="#0000FF" SIZE=2>Regards,</FONT>

<BR><FONT COLOR="#0000FF" SIZE=2>Partha</FONT>
</P>
<UL>
<P><FONT SIZE=1 FACE="MS Sans Serif">-- ---- --</FONT>

<BR><B><FONT SIZE=1 FACE="MS Sans Serif">From:</FONT></B> &nbsp; <FONT SIZE=1
FACE="MS Sans Serif">A mailing list for Java(tm) 2 Platform, Enterprise Edition
[SMTP:J2EE-INTEREST@(protected)] on behalf of Singla, Munish K.[SMTP:MSingla
@(protected)]</FONT></P>

<P><B><FONT SIZE=1 FACE="MS Sans Serif">Sent:</FONT></B> &nbsp; <FONT SIZE=1
FACE="MS Sans Serif">Saturday, October 30, 2004 12:51 AM</FONT>

<BR><B><FONT SIZE=1 FACE="MS Sans Serif">To:</FONT></B> &nbsp;&nbsp;&nbsp;
<FONT SIZE=1 FACE="MS Sans Serif">J2EE-INTEREST@(protected)</FONT>

<BR><B><FONT SIZE=1 FACE="MS Sans Serif">Subject:</FONT></B> &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; <FONT SIZE=1 FACE="MS Sans Serif">Spam:Re: Using JMS in a
session bean</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">You might want to try out with a higher value for
timeout in receive</FONT>

<BR><FONT SIZE=2 FACE="Arial">call before assuming it is something else. </FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">-- --Original Message-- --</FONT>

<BR><FONT SIZE=2 FACE="Arial">From: John Lohr [<U></U></FONT><U><FONT COLOR="
#0000FF" SIZE=2 FACE="Arial"><A HREF="mailto:johnlohr12@(protected)">mailto
:johnlohr12@(protected)</A></FONT></U><FONT SIZE=2 FACE="Arial">] </FONT>

<BR><FONT SIZE=2 FACE="Arial">Sent: Friday, October 15, 2004 12:35 AM</FONT>

<BR><FONT SIZE=2 FACE="Arial">To: J2EE-INTEREST@(protected)</FONT>

<BR><FONT SIZE=2 FACE="Arial">Subject: Using JMS in a session bean</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Hello,</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Please would you know if I can send a message and
then receive a</FONT>

<BR><FONT SIZE=2 FACE="Arial">response message in one method from stateless
session bean. Seems to me</FONT>

<BR><FONT SIZE=2 FACE="Arial">that the messages that the bean is sending are
placed on the queue when</FONT>

<BR><FONT SIZE=2 FACE="Arial">the execution of the bean method is finished thus
it can never receive</FONT>

<BR><FONT SIZE=2 FACE="Arial">the response. If it is so how can that be
resolved. Any pattern .. ? The</FONT>

<BR><FONT SIZE=2 FACE="Arial">code below works fine in a servlet but in a
session bean it always</FONT>

<BR><FONT SIZE=2 FACE="Arial">timeouts. I am using Embeded messaging in
WebSphere and there is a plain</FONT>

<BR><FONT SIZE=2 FACE="Arial">Java receiver of messages from the bean and it is
sending responses</FONT>

<BR><FONT SIZE=2 FACE="Arial">back.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Thank you,</FONT>

<BR><FONT SIZE=2 FACE="Arial">John</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">sessionBeanMethod() {</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp; ....</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; ....</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; connection = factory
.createQueueConnection();</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; QueueSession session =
connection.createQueueSession(false,</FONT>

<BR><FONT SIZE=2 FACE="Arial">Session.AUTO_ACKNOWLEDGE);</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; QueueSender sender = session
.createSender(requestQueue);</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; QueueReceiver receiver =
session.createReceiver(responseQueue,</FONT>

<BR><FONT SIZE=2 FACE="Arial">selector);</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; connection.start();</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; TextMessage requestMessage =
session.createTextMessage(&quot;message&quot;);</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; requestMessage
.setJMSCorrelationID(messageID);</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; sender.send(requestMessage);<
/FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; Message responseMessage =
receiver.receive(5000);</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp; ....</FONT>

<BR><FONT SIZE=2 FACE="Arial">}</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">__ ____ ____ ____ ____ ____ ____ ____ ____ ____ __
__ ____ ____ __</FONT>

<BR><FONT SIZE=2 FACE="Arial">On the road to retirement? Check out MSN Life
Events for advice on how</FONT>

<BR><FONT SIZE=2 FACE="Arial">to get there!</FONT><U> <FONT COLOR="#0000FF"
SIZE=2 FACE="Arial"><A HREF="http://lifeevents.msn.com/category.aspx?cid
=Retirement">http://lifeevents.msn.com/category.aspx?cid=Retirement</A></FONT><
/U>
</P>

<P><FONT SIZE=2 FACE="Arial">==================================================
======================</FONT>

<BR><FONT SIZE=2 FACE="Arial">===</FONT>

<BR><FONT SIZE=2 FACE="Arial">To unsubscribe, send email to listserv@(protected)
.com and include in the</FONT>

<BR><FONT SIZE=2 FACE="Arial">body of the message &quot;signoff J2EE-INTEREST
&quot;.&nbsp; For general help, send</FONT>

<BR><FONT SIZE=2 FACE="Arial">email to listserv@(protected) and include in the
body of the message</FONT>

<BR><FONT SIZE=2 FACE="Arial">&quot;help&quot;.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">==================================================
=========================</FONT>

<BR><FONT SIZE=2 FACE="Arial">To unsubscribe, send email to listserv@(protected)
.com and include in the body</FONT>

<BR><FONT SIZE=2 FACE="Arial">of the message &quot;signoff J2EE-INTEREST&quot;.
&nbsp; For general help, send email to</FONT>

<BR><FONT SIZE=2 FACE="Arial">listserv@(protected) and include in the body of
the message &quot;help&quot;.</FONT>
</P>
</UL>
</BODY>
</HTML>
===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".
<p>

©2008 junlu.com - Jax Systems, LLC, U.S.A.