Search in sources :

Example 1 with TemporaryTopic

use of javax.jms.TemporaryTopic in project camel by apache.

the class DefaultDestinationCreationStrategyTest method testTemporaryTopicCreation.

@Test
public void testTemporaryTopicCreation() throws Exception {
    TemporaryTopic destination = (TemporaryTopic) strategy.createTemporaryDestination(getSession(), true);
    assertNotNull(destination);
    assertNotNull(destination.getTopicName());
}
Also used : TemporaryTopic(javax.jms.TemporaryTopic) Test(org.junit.Test)

Example 2 with TemporaryTopic

use of javax.jms.TemporaryTopic in project karaf by apache.

the class PooledConnection method cleanupConnectionTemporaryDestinations.

/**
     * Remove all of the temporary destinations created for this connection.
     * This is important since the underlying connection may be reused over a
     * long period of time, accumulating all of the temporary destinations from
     * each use. However, from the perspective of the lifecycle from the
     * client's view, close() closes the connection and, therefore, deletes all
     * of the temporary destinations created.
     */
protected void cleanupConnectionTemporaryDestinations() {
    for (TemporaryQueue tempQueue : connTempQueues) {
        try {
            tempQueue.delete();
        } catch (JMSException ex) {
            LOG.info("failed to delete Temporary Queue \"" + tempQueue.toString() + "\" on closing pooled connection: " + ex.getMessage());
        }
    }
    connTempQueues.clear();
    for (TemporaryTopic tempTopic : connTempTopics) {
        try {
            tempTopic.delete();
        } catch (JMSException ex) {
            LOG.info("failed to delete Temporary Topic \"" + tempTopic.toString() + "\" on closing pooled connection: " + ex.getMessage());
        }
    }
    connTempTopics.clear();
}
Also used : TemporaryQueue(javax.jms.TemporaryQueue) JMSException(javax.jms.JMSException) TemporaryTopic(javax.jms.TemporaryTopic)

Example 3 with TemporaryTopic

use of javax.jms.TemporaryTopic in project karaf by apache.

the class PooledSession method createTemporaryTopic.

@Override
public TemporaryTopic createTemporaryTopic() throws JMSException {
    TemporaryTopic result;
    result = getInternalSession().createTemporaryTopic();
    // Notify all of the listeners of the created temporary Topic.
    for (PooledSessionEventListener listener : this.sessionEventListeners) {
        listener.onTemporaryTopicCreate(result);
    }
    return result;
}
Also used : TemporaryTopic(javax.jms.TemporaryTopic)

Example 4 with TemporaryTopic

use of javax.jms.TemporaryTopic in project aries by apache.

the class XaConnectionPool method createSession.

@Override
public Session createSession(boolean transacted, int ackMode) throws JMSException {
    try {
        boolean isXa = (transactionManager != null && transactionManager.getStatus() != Status.STATUS_NO_TRANSACTION);
        if (isXa) {
            // if the xa tx aborts inflight we don't want to auto create a
            // local transaction or auto ack
            transacted = false;
            ackMode = Session.CLIENT_ACKNOWLEDGE;
        } else if (transactionManager != null) {
            // cmt or transactionManager managed
            transacted = false;
            if (ackMode == Session.SESSION_TRANSACTED) {
                ackMode = Session.AUTO_ACKNOWLEDGE;
            }
        }
        PooledSession session = (PooledSession) super.createSession(transacted, ackMode);
        if (isXa) {
            session.addSessionEventListener(new PooledSessionEventListener() {

                @Override
                public void onTemporaryQueueCreate(TemporaryQueue tempQueue) {
                }

                @Override
                public void onTemporaryTopicCreate(TemporaryTopic tempTopic) {
                }

                @Override
                public void onSessionClosed(PooledSession session) {
                    session.setIgnoreClose(true);
                    session.setIsXa(false);
                }
            });
            session.setIgnoreClose(true);
            session.setIsXa(true);
            transactionManager.getTransaction().registerSynchronization(new Synchronization(session));
            incrementReferenceCount();
            transactionManager.getTransaction().enlistResource(createXaResource(session));
        } else {
            session.setIgnoreClose(false);
        }
        return session;
    } catch (RollbackException e) {
        final JMSException jmsException = new JMSException("Rollback Exception");
        jmsException.initCause(e);
        throw jmsException;
    } catch (SystemException e) {
        final JMSException jmsException = new JMSException("System Exception");
        jmsException.initCause(e);
        throw jmsException;
    }
}
Also used : SystemException(javax.transaction.SystemException) TemporaryQueue(javax.jms.TemporaryQueue) JMSException(javax.jms.JMSException) RollbackException(javax.transaction.RollbackException) TemporaryTopic(javax.jms.TemporaryTopic)

Aggregations

TemporaryTopic (javax.jms.TemporaryTopic)4 JMSException (javax.jms.JMSException)2 TemporaryQueue (javax.jms.TemporaryQueue)2 RollbackException (javax.transaction.RollbackException)1 SystemException (javax.transaction.SystemException)1 Test (org.junit.Test)1