@Test public void testWithTopicConnection() throws JMSException { Connection con = mock(TopicConnection.class); SingleConnectionFactory scf = new SingleConnectionFactory(con); TopicConnection con1 = scf.createTopicConnection(); con1.start(); con1.stop(); con1.close(); TopicConnection con2 = scf.createTopicConnection(); con2.start(); con2.stop(); con2.close(); scf.destroy(); // should trigger actual close verify(con, times(2)).start(); verify(con, times(2)).stop(); verify(con).close(); verifyNoMoreInteractions(con); }
@Test public void testWithTopicConnectionFactoryAndJms11Usage() throws JMSException { TopicConnectionFactory cf = mock(TopicConnectionFactory.class); TopicConnection con = mock(TopicConnection.class); given(cf.createConnection()).willReturn(con); SingleConnectionFactory scf = new SingleConnectionFactory(cf); Connection con1 = scf.createConnection(); Connection con2 = scf.createConnection(); con1.start(); con2.start(); con1.close(); con2.close(); scf.destroy(); // should trigger actual close verify(con).start(); verify(con).stop(); verify(con).close(); verifyNoMoreInteractions(con); }
@Test public void testWithTopicConnectionFactoryAndJms102Usage() throws JMSException { TopicConnectionFactory cf = mock(TopicConnectionFactory.class); TopicConnection con = mock(TopicConnection.class); given(cf.createTopicConnection()).willReturn(con); SingleConnectionFactory scf = new SingleConnectionFactory(cf); Connection con1 = scf.createTopicConnection(); Connection con2 = scf.createTopicConnection(); con1.start(); con2.start(); con1.close(); con2.close(); scf.destroy(); // should trigger actual close verify(con).start(); verify(con).stop(); verify(con).close(); verifyNoMoreInteractions(con); }
verify(nonTxSession).close(); verify(con).start(); verify(con).stop(); verify(con).close();
@Override public void run() { try { topicConnection.stop(); producer.close(); session.close(); topicConnection.close(); } catch (final JMSException e) { System.err.println("Cannot stop the synchro service, probably already stopped?"); } } });
@Override public void run() { try { topicConnection.stop(); producer.close(); session.close(); topicConnection.close(); } catch (final JMSException e) { System.err.println("Cannot stop the synchro service, probably already stopped?"); } } });
@Destroy public void destroy() throws JMSException { topicConnection.stop(); topicConnection.close(); }
/** * Stops the work of the JMS protocol. This method closes JMS session and * connection and deregisters itself from the message notification. */ public void stop() { if(log.isInfoEnabled()) log.info("finishing JMS transport layer."); try { connection.stop(); subscriber.setMessageListener(null); session.close(); connection.close(); } catch(Throwable ex) { if(log.isErrorEnabled()) log.error("exception is " + ex); } }
@Override public void stop() { logger.info("stopping " + toString()); stopped = true; try { connection.stop(); } catch (JMSException e) { logger.error("could not stop connection", e); } try { connection.close(); } catch (JMSException e) { logger.error("could not close connection", e); } super.stop(); }
@Override public void stop() { logger.info("stopping " + toString()); stopped = true; try { connection.stop(); } catch (JMSException e) { logger.error("could not stop connection", e); } try { connection.close(); } catch (JMSException e) { logger.error("could not close connection", e); } super.stop(); }
protected void stopService () { log.info ("Stoping JMS cache invalidation bridge"); try { if (this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_OUT_BRIDGE_PROPAGATION || this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_ONLY_BRIDGE_PROPAGATION) { subscriber.close(); } if (this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_OUT_BRIDGE_PROPAGATION || this.propagationMode == JMSCacheInvalidationBridgeMBean.OUT_ONLY_BRIDGE_PROPAGATION) { this.publishingAuthorized = false; pub.close(); } conn.stop(); session.close(); conn.close(); } catch (Exception ex) { log.warn("Failed to stop JMS resources associated with the JMS bridge: ", ex); } }
public void close() throws EventBrokerException { try { this.topicSubscriber.close(); this.topicSession.close(); this.topicConnection.stop(); this.topicConnection.close(); } catch (JMSException e) { throw new EventBrokerException("Can not close connections ", e); } }
if (jmsProducer.topicConnection != null) { try { jmsProducer.topicConnection.stop(); } catch (JMSException ex) { ex.printStackTrace();
if (jmsProducer.topicConnection != null) { try { jmsProducer.topicConnection.stop(); } catch (JMSException ex) { ex.printStackTrace();
/** * Providers may be doing all sorts of exotic things and need to be able to clean up on dispose. * * @throws CacheException */ public void dispose() throws CacheException { LOG.fine("JMSCacheManagerPeerProvider for CacheManager " + cacheManager.getName() + " being disposed."); try { cachePeer.dispose(); topicPublisher.close(); if (listenToTopic) { topicSubscriber.close(); replicationTopicConnection.stop(); } topicPublisherSession.close(); replicationTopicConnection.close(); getQueueRequestReceiver.close(); getQueueSession.close(); getQueueConnection.close(); } catch (JMSException e) { LOG.severe(e.getMessage()); throw new CacheException(e.getMessage(), e); } }
/** * Providers may be doing all sorts of exotic things and need to be able to clean up on dispose. * * @throws CacheException */ public void dispose() throws CacheException { LOG.fine("JMSCacheManagerPeerProvider for CacheManager " + cacheManager.getName() + " being disposed."); try { cachePeer.dispose(); topicPublisher.close(); if (listenToTopic) { topicSubscriber.close(); replicationTopicConnection.stop(); } topicPublisherSession.close(); replicationTopicConnection.close(); getQueueRequestReceiver.close(); getQueueSession.close(); getQueueConnection.close(); } catch (JMSException e) { LOG.severe(e.getMessage()); throw new CacheException(e.getMessage(), e); } }