Search in sources :

Example 1 with MQIllegalStateRuntimeException

use of com.sun.messaging.jms.MQIllegalStateRuntimeException in project openmq by eclipse-ee4j.

the class JMSContextImpl method close.

@Override
public void close() {
    contextLogger.log(Level.FINE, "JMSContext@" + this.hashCode() + ".close(): connection@" + (connection == null ? "null" : connection.hashCode()));
    if (closed) {
        return;
    }
    closed = true;
    // close all JMSConsumer objects associated with this JMSContext
    for (JMSConsumer consumer : consumers) {
        consumer.close();
    }
    if (!consumers.isEmpty()) {
        throw new RuntimeException("Debug: consumers not empty");
    }
    // close the anonymous MessageProducer associated with this JMSContext
    if (messageProducer != null) {
        try {
            messageProducer.close();
            messageProducer = null;
        } catch (IllegalStateException e) {
            throw new MQIllegalStateRuntimeException(e);
        } catch (JMSException e) {
            throw new MQRuntimeException(e);
        }
    }
    // close the Session
    try {
        session.close();
    } catch (IllegalStateException e) {
        throw new MQIllegalStateRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
    // if this is the only JMSContext using the connection, close it
    synchronized (contextSet) {
        // debug
        if (!contextSet.contains(this)) {
            throw new RuntimeException("I am not in the context set");
        }
        contextSet.remove(this);
        if (contextSet.contains(this)) {
            throw new RuntimeException("I am not in the context set");
        }
        if (contextSet.isEmpty()) {
            try {
                connection.close();
            } catch (IllegalStateException e) {
                throw new MQIllegalStateRuntimeException(e);
            } catch (JMSException e) {
                throw new MQRuntimeException(e);
            }
        }
    }
    closed = true;
}
Also used : IllegalStateException(jakarta.jms.IllegalStateException) JMSConsumer(jakarta.jms.JMSConsumer) MQInvalidDestinationRuntimeException(com.sun.messaging.jms.MQInvalidDestinationRuntimeException) JMSRuntimeException(jakarta.jms.JMSRuntimeException) MQTransactionRolledBackRuntimeException(com.sun.messaging.jms.MQTransactionRolledBackRuntimeException) JMSSecurityRuntimeException(jakarta.jms.JMSSecurityRuntimeException) MQInvalidSelectorRuntimeException(com.sun.messaging.jms.MQInvalidSelectorRuntimeException) MQTransactionInProgressRuntimeException(com.sun.messaging.jms.MQTransactionInProgressRuntimeException) IllegalStateRuntimeException(jakarta.jms.IllegalStateRuntimeException) InvalidClientIDRuntimeException(jakarta.jms.InvalidClientIDRuntimeException) MQIllegalStateRuntimeException(com.sun.messaging.jms.MQIllegalStateRuntimeException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException) MQSecurityRuntimeException(com.sun.messaging.jms.MQSecurityRuntimeException) JMSException(jakarta.jms.JMSException) MQIllegalStateRuntimeException(com.sun.messaging.jms.MQIllegalStateRuntimeException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 2 with MQIllegalStateRuntimeException

use of com.sun.messaging.jms.MQIllegalStateRuntimeException in project openmq by eclipse-ee4j.

the class JMSContextImpl method stop.

@Override
public void stop() {
    checkNotClosed();
    disallowSetClientID();
    try {
        connection.stop();
    } catch (IllegalStateException e) {
        throw new MQIllegalStateRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
}
Also used : IllegalStateException(jakarta.jms.IllegalStateException) JMSException(jakarta.jms.JMSException) MQIllegalStateRuntimeException(com.sun.messaging.jms.MQIllegalStateRuntimeException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 3 with MQIllegalStateRuntimeException

use of com.sun.messaging.jms.MQIllegalStateRuntimeException in project openmq by eclipse-ee4j.

the class JMSContextImpl method commit.

@Override
public void commit() {
    checkNotClosed();
    disallowSetClientID();
    try {
        session.commit();
    } catch (TransactionRolledBackException e) {
        throw new MQTransactionRolledBackRuntimeException(e);
    } catch (TransactionInProgressException e) {
        throw new MQTransactionInProgressRuntimeException(e);
    } catch (IllegalStateException e) {
        throw new MQIllegalStateRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
}
Also used : IllegalStateException(jakarta.jms.IllegalStateException) MQTransactionInProgressRuntimeException(com.sun.messaging.jms.MQTransactionInProgressRuntimeException) TransactionRolledBackException(jakarta.jms.TransactionRolledBackException) TransactionInProgressException(jakarta.jms.TransactionInProgressException) JMSException(jakarta.jms.JMSException) MQIllegalStateRuntimeException(com.sun.messaging.jms.MQIllegalStateRuntimeException) MQTransactionRolledBackRuntimeException(com.sun.messaging.jms.MQTransactionRolledBackRuntimeException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 4 with MQIllegalStateRuntimeException

use of com.sun.messaging.jms.MQIllegalStateRuntimeException in project openmq by eclipse-ee4j.

the class JMSContextImpl method recover.

@Override
public void recover() {
    checkNotClosed();
    disallowSetClientID();
    try {
        session.recover();
    } catch (IllegalStateException e) {
        throw new MQIllegalStateRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
}
Also used : IllegalStateException(jakarta.jms.IllegalStateException) JMSException(jakarta.jms.JMSException) MQIllegalStateRuntimeException(com.sun.messaging.jms.MQIllegalStateRuntimeException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 5 with MQIllegalStateRuntimeException

use of com.sun.messaging.jms.MQIllegalStateRuntimeException in project openmq by eclipse-ee4j.

the class JMSContextImpl method rollback.

@Override
public void rollback() {
    checkNotClosed();
    disallowSetClientID();
    try {
        session.rollback();
    } catch (IllegalStateException e) {
        throw new MQIllegalStateRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
}
Also used : IllegalStateException(jakarta.jms.IllegalStateException) JMSException(jakarta.jms.JMSException) MQIllegalStateRuntimeException(com.sun.messaging.jms.MQIllegalStateRuntimeException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Aggregations

MQIllegalStateRuntimeException (com.sun.messaging.jms.MQIllegalStateRuntimeException)5 MQRuntimeException (com.sun.messaging.jms.MQRuntimeException)5 IllegalStateException (jakarta.jms.IllegalStateException)5 JMSException (jakarta.jms.JMSException)5 MQTransactionInProgressRuntimeException (com.sun.messaging.jms.MQTransactionInProgressRuntimeException)2 MQTransactionRolledBackRuntimeException (com.sun.messaging.jms.MQTransactionRolledBackRuntimeException)2 MQInvalidDestinationRuntimeException (com.sun.messaging.jms.MQInvalidDestinationRuntimeException)1 MQInvalidSelectorRuntimeException (com.sun.messaging.jms.MQInvalidSelectorRuntimeException)1 MQSecurityRuntimeException (com.sun.messaging.jms.MQSecurityRuntimeException)1 IllegalStateRuntimeException (jakarta.jms.IllegalStateRuntimeException)1 InvalidClientIDRuntimeException (jakarta.jms.InvalidClientIDRuntimeException)1 JMSConsumer (jakarta.jms.JMSConsumer)1 JMSRuntimeException (jakarta.jms.JMSRuntimeException)1 JMSSecurityRuntimeException (jakarta.jms.JMSSecurityRuntimeException)1 TransactionInProgressException (jakarta.jms.TransactionInProgressException)1 TransactionRolledBackException (jakarta.jms.TransactionRolledBackException)1