/** Close this JMSAppender. Closing releases all resources used by the appender. A closed appender cannot be re-opened. */ public synchronized void close() { // The synchronized modifier avoids concurrent append and close operations if(this.closed) return; LogLog.debug("Closing appender ["+name+"]."); this.closed = true; try { if(topicSession != null) topicSession.close(); if(topicConnection != null) topicConnection.close(); } catch(JMSException e) { LogLog.error("Error while closing JMSAppender ["+name+"].", e); } catch(RuntimeException e) { LogLog.error("Error while closing JMSAppender ["+name+"].", e); } // Help garbage collection topicPublisher = null; topicSession = null; topicConnection = null; }
@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); }
@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); }
if (newConnection != null) { try { newConnection.close(); } catch (Exception ignore) {}
if (newConnection != null) { try { newConnection.close(); } catch (Exception ignore) {}
/** * Close this JMSAppender. Closing releases all resources used by the * appender. A closed appender cannot be re-opened. */ public synchronized void stop() { // The synchronized modifier avoids concurrent append and close operations if (!this.started) { return; } this.started = false; try { if (topicSession != null) { topicSession.close(); } if (topicConnection != null) { topicConnection.close(); } } catch (Exception e) { addError("Error while closing JMSAppender [" + name + "].", e); } // Help garbage collection topicPublisher = null; topicSession = null; topicConnection = null; }
/** Close this JMSAppender. Closing releases all resources used by the appender. A closed appender cannot be re-opened. */ public synchronized void close() { // The synchronized modifier avoids concurrent append and close operations if(this.closed) { return; } LogLog.debug("Closing appender ["+name+"]."); this.closed = true; try { if(topicSession != null) { topicSession.close(); } if(topicConnection != null) { topicConnection.close(); } } catch(JMSException e) { LogLog.error("Error while closing JMSAppender ["+name+"].", e); } catch(RuntimeException e) { LogLog.error("Error while closing JMSAppender ["+name+"].", e); } // Help garbage collection topicPublisher = null; topicSession = null; topicConnection = null; }
@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?"); } } });
/** * INTERNAL: * This method is called by close method. * This method usually * (but not always see comment to areAllResourcesFreedOnClose method) * frees all the resources. */ protected void closeInternal() throws JMSException { if(areAllResourcesFreedOnClose()) { // There is no need to close the sessions, producers, and consumers of a closed TopicConnection. topicConnection.close(); } }
@Destroy public void destroy() throws JMSException { topicConnection.stop(); topicConnection.close(); }
private static void closeResources(TopicConnection pConn, TopicSession pSession, TopicPublisher pPublisher) throws JMSException { if (pPublisher != null) { pPublisher.close(); } if (pSession != null) { pSession.close(); } if (pConn != null) { pConn.close(); } }
public void close() throws GenericServiceException { try { if (session != null) session.close(); if (con != null) con.close(); } catch (JMSException e) { throw new GenericServiceException("Cannot close connection(s).", e); } }
protected void tearDown() throws Exception { session.close(); connection.close(); }
protected void tearDown() throws Exception { session.close(); connection.close(); }
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); } }
/** * Test that ConnectionFactory can be cast to TopicConnectionFactory and TopicConnection can be * created. */ @Test public void testTopicConnectionFactory() throws Exception { deployConnectionFactory(0, JMSFactoryType.TOPIC_CF, "CF_TOPIC_XA_FALSE", "/CF_TOPIC_XA_FALSE"); TopicConnectionFactory qcf = (TopicConnectionFactory) ic.lookup("/CF_TOPIC_XA_FALSE"); TopicConnection tc = qcf.createTopicConnection(); tc.close(); undeployConnectionFactory("CF_TOPIC_XA_FALSE"); }
@Test public void testCreateQueueOnATopicSession() throws Exception { TopicConnection c = (TopicConnection) getConnectionFactory().createConnection(); TopicSession s = c.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); try { s.createQueue("TestQueue"); ProxyAssertSupport.fail("should throw IllegalStateException"); } catch (javax.jms.IllegalStateException e) { // OK } c.close(); }