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;
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations