Search in sources :

Example 6 with MQRuntimeException

use of com.sun.messaging.jms.MQRuntimeException 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 7 with MQRuntimeException

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

the class JMSContextImpl method createTextMessage.

@Override
public TextMessage createTextMessage(String text) {
    checkNotClosed();
    disallowSetClientID();
    try {
        return session.createTextMessage(text);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
}
Also used : JMSException(jakarta.jms.JMSException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 8 with MQRuntimeException

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

the class JMSContextImpl method createBrowser.

@Override
public QueueBrowser createBrowser(Queue queue, String messageSelector) {
    checkNotClosed();
    disallowSetClientID();
    try {
        return session.createBrowser(queue, messageSelector);
    } catch (InvalidDestinationException e) {
        throw new MQInvalidDestinationRuntimeException(e);
    } catch (InvalidSelectorException e) {
        throw new MQInvalidSelectorRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
}
Also used : InvalidSelectorException(jakarta.jms.InvalidSelectorException) MQInvalidDestinationRuntimeException(com.sun.messaging.jms.MQInvalidDestinationRuntimeException) MQInvalidSelectorRuntimeException(com.sun.messaging.jms.MQInvalidSelectorRuntimeException) InvalidDestinationException(jakarta.jms.InvalidDestinationException) JMSException(jakarta.jms.JMSException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 9 with MQRuntimeException

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

the class JMSContextImpl method createTextMessage.

@Override
public TextMessage createTextMessage() {
    checkNotClosed();
    disallowSetClientID();
    try {
        return session.createTextMessage();
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
}
Also used : JMSException(jakarta.jms.JMSException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 10 with MQRuntimeException

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

the class JMSContextImpl method start.

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

Aggregations

MQRuntimeException (com.sun.messaging.jms.MQRuntimeException)29 JMSException (jakarta.jms.JMSException)29 MQInvalidDestinationRuntimeException (com.sun.messaging.jms.MQInvalidDestinationRuntimeException)8 InvalidDestinationException (jakarta.jms.InvalidDestinationException)7 MQMessageFormatRuntimeException (com.sun.messaging.jms.MQMessageFormatRuntimeException)6 MessageFormatException (jakarta.jms.MessageFormatException)6 MQIllegalStateRuntimeException (com.sun.messaging.jms.MQIllegalStateRuntimeException)5 IllegalStateException (jakarta.jms.IllegalStateException)5 MQInvalidSelectorRuntimeException (com.sun.messaging.jms.MQInvalidSelectorRuntimeException)2 MQMessageNotWriteableRuntimeException (com.sun.messaging.jms.MQMessageNotWriteableRuntimeException)2 MQTransactionInProgressRuntimeException (com.sun.messaging.jms.MQTransactionInProgressRuntimeException)2 MQTransactionRolledBackRuntimeException (com.sun.messaging.jms.MQTransactionRolledBackRuntimeException)2 MessageNotWriteableException (jakarta.jms.MessageNotWriteableException)2 AdministeredObject (com.sun.messaging.AdministeredObject)1 MQInvalidClientIDRuntimeException (com.sun.messaging.jms.MQInvalidClientIDRuntimeException)1 MQSecurityRuntimeException (com.sun.messaging.jms.MQSecurityRuntimeException)1 BytesMessage (jakarta.jms.BytesMessage)1 IllegalStateRuntimeException (jakarta.jms.IllegalStateRuntimeException)1 InvalidClientIDException (jakarta.jms.InvalidClientIDException)1 InvalidClientIDRuntimeException (jakarta.jms.InvalidClientIDRuntimeException)1