@After
  public void removeTopic() throws Exception {

    if (conn != null) {
      conn.stop();
    }
    if (session != null) {
      session.close();
    }
    if (conn != null) {
      conn.close();
    }

    if (consumerConn != null) {
      consumerConn.stop();
    }
    if (consumerSession != null) {
      consumerSession.close();
    }
    if (consumerConn != null) {
      consumerConn.close();
    }

    adminSupport.removeJmsQueue(getQueueName());
    adminSupport.removeJmsQueue(getOtherQueueName());
  }
  public void testWithQueueConnection() throws JMSException {
    MockControl conControl = MockControl.createControl(QueueConnection.class);
    Connection con = (QueueConnection) conControl.getMock();

    con.start();
    conControl.setVoidCallable(1);
    con.stop();
    conControl.setVoidCallable(1);
    con.close();
    conControl.setVoidCallable(1);

    conControl.replay();

    SingleConnectionFactory scf = new SingleConnectionFactory(con);
    QueueConnection con1 = scf.createQueueConnection();
    con1.start();
    con1.stop(); // should be ignored
    con1.close(); // should be ignored
    QueueConnection con2 = scf.createQueueConnection();
    con2.start();
    con2.stop(); // should be ignored
    con2.close(); // should be ignored
    scf.destroy(); // should trigger actual close

    conControl.verify();
  }
Ejemplo n.º 3
0
 public void cerrarConexion() {
   try {
     conexionCola.stop();
     conexionCola.close();
   } catch (JMSException ex) {
     System.out.println("Excepcion");
   }
 }
Ejemplo n.º 4
0
 public void stop() throws JMSException {
   connection.stop();
   session.close();
   connection.close();
 }
  public void testCachingConnectionFactoryWithQueueConnectionFactoryAndJms102Usage()
      throws JMSException {
    MockControl cfControl = MockControl.createControl(QueueConnectionFactory.class);
    QueueConnectionFactory cf = (QueueConnectionFactory) cfControl.getMock();
    MockControl conControl = MockControl.createControl(QueueConnection.class);
    QueueConnection con = (QueueConnection) conControl.getMock();
    MockControl txSessionControl = MockControl.createControl(QueueSession.class);
    QueueSession txSession = (QueueSession) txSessionControl.getMock();
    MockControl nonTxSessionControl = MockControl.createControl(QueueSession.class);
    QueueSession nonTxSession = (QueueSession) nonTxSessionControl.getMock();

    cf.createQueueConnection();
    cfControl.setReturnValue(con, 1);
    con.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
    conControl.setReturnValue(txSession, 1);
    txSession.getTransacted();
    txSessionControl.setReturnValue(true, 1);
    txSession.rollback();
    txSessionControl.setVoidCallable(1);
    txSession.close();
    txSessionControl.setVoidCallable(1);
    con.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
    conControl.setReturnValue(nonTxSession, 1);
    nonTxSession.close();
    nonTxSessionControl.setVoidCallable(1);
    con.start();
    conControl.setVoidCallable(1);
    con.stop();
    conControl.setVoidCallable(1);
    con.close();
    conControl.setVoidCallable(1);

    cfControl.replay();
    conControl.replay();
    txSessionControl.replay();
    nonTxSessionControl.replay();

    CachingConnectionFactory scf = new CachingConnectionFactory(cf);
    scf.setReconnectOnException(false);
    Connection con1 = scf.createQueueConnection();
    Session session1 = con1.createSession(true, Session.AUTO_ACKNOWLEDGE);
    session1.rollback();
    session1.close(); // should be ignored
    session1 = con1.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    session1.close(); // should be ignored
    con1.start();
    con1.close(); // should be ignored
    QueueConnection con2 = scf.createQueueConnection();
    Session session2 = con2.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
    session2.close(); // should be ignored
    session2 = con2.createSession(true, Session.AUTO_ACKNOWLEDGE);
    session2.getTransacted();
    session2.close(); // should lead to rollback
    con2.start();
    con2.close(); // should be ignored
    scf.destroy(); // should trigger actual close

    cfControl.verify();
    conControl.verify();
    txSessionControl.verify();
    nonTxSessionControl.verify();
  }
 public void stop() throws JMSException {
   conn.stop();
   queueSession.close();
   conn.close();
 }