Re-establishing JMS connection

Toni <[email protected]> Wed, 7 Nov 2007 20:09:40 +0200
Newsgroups gmane.comp.java.openjms.user
Message-ID <[email protected]>
--===============1389951480==
Content-Type: multipart/alternative; boundary=Apple-Mail-4--744067461


--Apple-Mail-4--744067461
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed;
	delsp=yes
Content-Transfer-Encoding: 7bit

Shortly, how do I properly re-establish the JMS connection?

As a test case of my solution, I restart the server with startup.sh  
and shutdown.sh and see if my client application will work as espected  
in each state (before, middle and after).
Right now it only works before the restart and that's the problem.

Here's how I connect to the server using RMI (same code is used when  
reconnecting):

TopicConnectionFactory tcf; 	
jndi = new InitialContext();
tcf = (TopicConnectionFactory)jndi.lookup("JmsTopicConnectionFactory");
tc = tcf.createTopicConnection();
tc.setExceptionListener(listener);
pubSession = tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
subSession = tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
tc.start();

So pretty basic.

Every variable not introduced there is a class variable of  
JMSConnection class. The exceptionlistener is a class that hosts the  
JMSConnection object. On exception it will launch a thread that tries  
to recreate the JMSConnection object. When JMSConnection instance is  
succesfully recreated using the above code, things should go back to  
normal.. except the don't.

When subscribing or publishing, I get an exception:

javax.jms.JMSException
	at  
org 
.exolab 
.jms.client.net.JMSExceptionAdapter.adapt(JMSExceptionAdapter.java:79)
	at  
org 
.exolab 
.jms 
.server 
.net.RemoteServerSession__Proxy.send(RemoteServerSession__Proxy.java: 
393)
	at  
org 
.exolab.jms.client.net.JmsSessionStubImpl.send(JmsSessionStubImpl.java: 
153)
	at org.exolab.jms.client.JmsSession.sendMessage(JmsSession.java:1164)
	at  
org.exolab.jms.client.JmsMessageProducer.send(JmsMessageProducer.java: 
359)
	at  
org.exolab.jms.client.JmsTopicPublisher.publish(JmsTopicPublisher.java: 
137)
	at  
org.exolab.jms.client.JmsTopicPublisher.publish(JmsTopicPublisher.java: 
105)
	at valkky.JMSConnection.publish(JMSConnection.java:88)

Should I re-establish the connection somehow else?

Any advice is greatly appreciated.
--Apple-Mail-4--744067461
Content-Type: text/html;
	charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

<html><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; ">Shortly, how do I properly =
re-establish the JMS connection?&nbsp;<div><br =
class=3D"webkit-block-placeholder"></div><div>As a test case of my =
solution, I restart the server with startup.sh and shutdown.sh and see =
if my client application will work as espected in each state (before, =
middle and after).</div><div>Right now it only works before the restart =
and that's the problem.&nbsp;</div><div><br =
class=3D"webkit-block-placeholder"></div><div>Here's how I connect to =
the server using RMI (same code is used when =
reconnecting):&nbsp;</div><div><br =
class=3D"webkit-block-placeholder"></div><div><div style=3D"margin-top: =
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: =
normal normal normal 11px/normal Monaco; "><div>TopicConnectionFactory =
tcf;&nbsp;<span class=3D"Apple-tab-span" style=3D"white-space: pre; ">	=
</span></div><div>jndi =3D new InitialContext();</div><div>tcf =3D =
(TopicConnectionFactory)jndi.lookup("JmsTopicConnectionFactory");</div><di=
v>tc =3D =
tcf.createTopicConnection();</div><div>tc.setExceptionListener(listener);<=
/div><div>pubSession =3D tc.createTopicSession(false, =
Session.AUTO_ACKNOWLEDGE);</div><div>subSession =3D =
tc.createTopicSession(false, =
Session.AUTO_ACKNOWLEDGE);</div><div>tc.start();</div><div><br =
class=3D"webkit-block-placeholder"></div><div>So pretty =
basic.</div><div><br class=3D"webkit-block-placeholder"></div><div>Every =
variable not introduced there is a class variable of JMSConnection =
class. The exceptionlistener is a class that hosts the JMSConnection =
object. On exception it will launch a thread that tries to recreate the =
JMSConnection object. When JMSConnection instance is succesfully =
recreated using the above code, things should go back to normal.. except =
the don't.&nbsp;</div><div><br></div><div>When subscribing or =
publishing, I get an exception:</div><div><div><br =
class=3D"webkit-block-placeholder"></div><div>javax.jms.JMSException</div>=
<div><span class=3D"Apple-tab-span" style=3D"white-space: pre; ">	=
</span>at =
org.exolab.jms.client.net.JMSExceptionAdapter.adapt(JMSExceptionAdapter.ja=
va:79)</div><div><span class=3D"Apple-tab-span" style=3D"white-space: =
pre; ">	</span>at =
org.exolab.jms.server.net.RemoteServerSession__Proxy.send(RemoteServerSess=
ion__Proxy.java:393)</div><div><span class=3D"Apple-tab-span" =
style=3D"white-space: pre; ">	</span>at =
org.exolab.jms.client.net.JmsSessionStubImpl.send(JmsSessionStubImpl.java:=
153)</div><div><span class=3D"Apple-tab-span" style=3D"white-space: pre; =
">	</span>at =
org.exolab.jms.client.JmsSession.sendMessage(JmsSession.java:1164)</div><d=
iv><span class=3D"Apple-tab-span" style=3D"white-space: pre; ">	=
</span>at =
org.exolab.jms.client.JmsMessageProducer.send(JmsMessageProducer.java:359)=
</div><div><span class=3D"Apple-tab-span" style=3D"white-space: pre; ">	=
</span>at =
org.exolab.jms.client.JmsTopicPublisher.publish(JmsTopicPublisher.java:137=
)</div><div><span class=3D"Apple-tab-span" style=3D"white-space: pre; ">	=
</span>at =
org.exolab.jms.client.JmsTopicPublisher.publish(JmsTopicPublisher.java:105=
)</div><div><span class=3D"Apple-tab-span" style=3D"white-space: pre; ">	=
</span>at =
valkky.JMSConnection.publish(JMSConnection.java:88)</div><div><br =
class=3D"webkit-block-placeholder"></div><div>Should I re-establish the =
connection somehow else?</div><div><br =
class=3D"webkit-block-placeholder"></div><div>Any advice is greatly =
appreciated.</div></div></div></div></body></html>=

--Apple-Mail-4--744067461--


--===============1389951480==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
--===============1389951480==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
openjms-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openjms-user

--===============1389951480==--