<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    JMS Queue/Topic Issue (JBoss SOA 4.3 - JBoss AS 4.2.2)
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/jbossuseruseruser">J H</a> in <i>JBoss Messaging</i> - <a href="http://community.jboss.org/message/549085#549085">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I have tried this with both a Queue and Topic. Within the destinations-service.xml file, I have configured a new Queue or Topic, simply by copying and pasting the example one and changing the name (testTopic &gt; newTopic). I have a class that sends simple text messages to the topic and then another class that receieves them. The receiving class is used within a very simple GUI to get the message and display it in a text area. This all works 'fine'.</p><p>The problem is after a certain amount of time (there is no regularity in the time this happens...) messages stop being received. Whilst using a topic I have seen the subscription in the JMX-Console and noticed that it is no longer there when messages are not being received. I have tried leaving sessions open - I've tried closing them and then making a new subscription every time - but no matter what I try it never seems to 'stay alive'. I then turned to Queues, thinking that the same problem couldn't possibly apply, but I was wrong, my GUI client stops receiving messages after an arbitrary amount of time. So my question is: Does JBoss have configuration settings for a subscription? Or something along those lines. Or is it something that I am doing wrong:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>destinations-service.xml</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;mbean code="org.jboss.jms.server.destination.TopicService"
&#160;&#160;&#160;&#160;&#160; name="jboss.messaging.destination:service=Topic,name=newTopic"
&#160;&#160;&#160;&#160;&#160; xmbean-dd="xmdesc/Topic-xmbean.xml"&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;depends optional-attribute-name="ServerPeer"&gt;</span>jboss.messaging:service=ServerPeer<span class="jive-xml-tag">&lt;/depends&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;depends&gt;</span>jboss.messaging:service=PostOffice<span class="jive-xml-tag">&lt;/depends&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;attribute name="SecurityConfig"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;security&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;role name="guest" read="true" write="true"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;role name="publisher" read="true" write="true" create="true"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/security&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/attribute&gt;</span>
 <span class="jive-xml-tag">&lt;/mbean&gt;</span>&#160; 
</code></pre><p><br/>TopicReceiver.java:</p><pre class="jive-pre"><code class="jive-code jive-java">&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_TOPIC_NAME = <font color="red">"topic/newTopic"</font>;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_JNDI_CONNECTION_FACTORY = <font color="red">"ConnectionFactory"</font>;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_JNDI_PACKAGE = <font color="red">"org.jboss.naming:org.jnp.interfaces"</font>;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_JNDI_DRIVER = <font color="red">"org.jnp.interfaces.NamingContextFactory"</font>;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_URL = <font color="red">"jnp://localhost:1099"</font>;
&#160;&#160;&#160; <font color="darkgreen">//The topic to which we will be publishing messages</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> Topic testTopic;
&#160;&#160;&#160; <font color="darkgreen">//The factory that will build us JMS connections</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> TopicConnectionFactory topicFactory;
&#160;&#160;&#160; <font color="darkgreen">//The connection to the JMS server</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> TopicConnection connection;
&#160;&#160;&#160; <font color="darkgreen">//The subscriber object</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> TopicSubscriber subscriber;
&#160;&#160;&#160; <font color="darkgreen">//The session for receiving</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> TopicSession subscribeSession;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> String messageText = <font color="red">""</font>;
&#160;
&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Calls the incomingMessage() method on instantiation
&#160;&#160;&#160;&#160; * to get the message from the subscribed Topic.
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> TopicReceiver() <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.setup();
&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Gets the message that has been stored from the subscribed
&#160;&#160;&#160;&#160; * topic.
&#160;&#160;&#160;&#160; * @return The newest incoming message.
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> String getMessage()<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> messageText;
&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Sets up the connection to JBoss and the Subscriber, who will
&#160;&#160;&#160;&#160; * listen for incoming messages.
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> setup()<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Properties prop = <font color="navy"><b>new</b></font> Properties();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.put(<font color="red">"java.naming.factory.initial"</font>,JBOSS_JNDI_DRIVER);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.put(<font color="red">"java.naming.provider.url"</font>,JBOSS_URL);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.put(<font color="red">"java.naming.factory.url.pkgs"</font>,JBOSS_JNDI_PACKAGE);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InitialContext context;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>try</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; context = <font color="navy"><b>new</b></font> InitialContext(prop);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">//Lookup the JMS connection factory and topic</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; topicFactory = (TopicConnectionFactory)context.lookup(JBOSS_JNDI_CONNECTION_FACTORY);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection = topicFactory.createTopicConnection();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; testTopic = (Topic)context.lookup(JBOSS_TOPIC_NAME);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; subscribeSession = connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; subscriber = subscribeSession.createSubscriber(testTopic);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection.start();
&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>catch</b></font> (NamingException e) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>catch</b></font> (JMSException jms)<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jms.printStackTrace();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Provides a user friendly view of the message - as a String.
&#160;&#160;&#160;&#160; * @return The Message contained within the JMS Message object.
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> String receiveMessage()<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; String msg = <font color="red">""</font>;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>try</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Message message = subscriber.receive();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; msg = ((TextMessage)message).getText();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println(msg);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">//stop();</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>catch</b></font> (JMSException e) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> msg;
&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> stop()<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>try</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; subscribeSession.close();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; subscriber.close();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection.stop();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection.close();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>catch</b></font> (JMSException e) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>TopicSender.java:</p><pre ___default_attr="java" jivemacro="code"><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_TOPIC_NAME = <font color="red">"topic/newTopic"</font>;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_JNDI_CONNECTION_FACTORY = <font color="red">"ConnectionFactory"</font>;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_JNDI_PACKAGE = <font color="red">"org.jboss.naming:org.jnp.interfaces"</font>;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_JNDI_DRIVER = <font color="red">"org.jnp.interfaces.NamingContextFactory"</font>;
&#160;&#160;&#160; <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> String JBOSS_URL = <font color="red">"jnp://localhost:1099"</font>;
&#160;&#160;&#160; <font color="darkgreen">//The topic to which we will be publishing messages</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> Topic jbossTopic;
&#160;&#160;&#160; <font color="darkgreen">//The factory that will build us JMS connections</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> TopicConnectionFactory topicFactory;
&#160;&#160;&#160; <font color="darkgreen">//The connection to the JMS server</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> TopicConnection connection;
&#160;&#160;&#160; <font color="darkgreen">//The publisher object</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> TopicPublisher publisher;
&#160;&#160;&#160; <font color="darkgreen">//The session for sending</font>
&#160;&#160;&#160; <font color="navy"><b>private</b></font> TopicSession publishSession;
&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Default Constructor
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> TopicSender()<font color="navy">{</font>
&#160;
&#160;
&#160;
&#160;
&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Prepares the connection to the Topic on the Server.
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> setup()<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>try</b></font><font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Properties prop = <font color="navy"><b>new</b></font> Properties();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.put(<font color="red">"java.naming.factory.initial"</font>,JBOSS_JNDI_DRIVER);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.put(<font color="red">"java.naming.provider.url"</font>,JBOSS_URL);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; prop.put(<font color="red">"java.naming.factory.url.pkgs"</font>,JBOSS_JNDI_PACKAGE);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; InitialContext context = <font color="navy"><b>new</b></font> InitialContext(prop);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">//Lookup the JMS connection factory and topic</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; topicFactory = (TopicConnectionFactory)context.lookup(JBOSS_JNDI_CONNECTION_FACTORY);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection = topicFactory.createTopicConnection();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jbossTopic = (Topic)context.lookup(JBOSS_TOPIC_NAME);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="darkgreen">//to send messages we create a session and a publisher</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; publishSession = connection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection.start();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>catch</b></font>(Exception e)<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Sends the message passed through the parameter to a topic named
&#160;&#160;&#160;&#160; * 'topic/testTopic' 
&#160;&#160;&#160;&#160; * @param text - The message that is to be published to the topic.
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> sendMessage(String text)<font color="navy">{</font> 
&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>try</b></font> <font color="navy">{</font>&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.setup();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; publisher = publishSession.createPublisher(jbossTopic);
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TextMessage tm = publishSession.createTextMessage(text); 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; publisher.publish(tm); 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; publisher.close();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.stop();
&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> 
&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>catch</b></font> (Exception e) <font color="navy">{</font>&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace(); 
&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160; <font color="navy">}</font>
&#160;
&#160;
&#160;&#160;&#160; <font color="darkgreen">/**
&#160;&#160;&#160;&#160; * Closes the connection and resources in use.
&#160;&#160;&#160;&#160; */</font>
&#160;&#160;&#160; <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> stop()<font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>try</b></font> <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection.stop();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; publishSession.close();
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; connection.close();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font> <font color="navy"><b>catch</b></font> (JMSException e) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.printStackTrace();
&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160; <font color="navy">}</font>
</code></pre>
<p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p>
<p><span style="font-family: arial,helvetica,sans-serif;">Please let me know if you require more information - any feedback is appreciated,<br/><br/>Thanks,<br/><br/>J</span></p>
</pre></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/549085#549085">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Messaging at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>