use of jakarta.resource.ResourceException in project openmq by eclipse-ee4j.
the class EndpointConsumer method setDestinationType.
/**
* Sets destinationType from the ActivationSpec instance passed in and validates related configs
*/
private void setDestinationType() throws ResourceException {
String destName = aSpec.getDestination();
String destinationLookup = aSpec.getDestinationLookup();
Object destObj = null;
if (destinationLookup != null) {
try {
destObj = Util.jndiLookup(destinationLookup);
} catch (NamingException e) {
String errorMessage = "MQRA:EC:Invalid destinationLookup " + destinationLookup + " configured in ActivationSpec of MDB for no JNDI name found";
throw new ResourceException(errorMessage, e);
}
if (destObj != null) {
if (destObj instanceof com.sun.messaging.Destination) {
destName = ((com.sun.messaging.Destination) destObj).getName();
} else {
String errorMessage = "MQRA:EC:Invalid destinationLookup " + destinationLookup + " configured in ActivationSpec of MDB, The JNDI object is required to be a Destination";
throw new NotSupportedException(errorMessage);
}
} else {
String errorMessage = "MQRA:EC:Invalid destinationLookup " + destinationLookup + " configured in ActivationSpec of MDB for JNDI object is null";
throw new NotSupportedException(errorMessage);
}
}
try {
if (destObj != null) {
if (destObj instanceof com.sun.messaging.Queue) {
if (aSpec._isDestTypeTopicSet())
throw new InvalidPropertyException("MQRA:EC:Inconsistent destinationType is set for destinationLookup " + destinationLookup);
this.destination = new com.sun.messaging.Queue(destName);
this.destinationType = ClientConstants.DESTINATION_TYPE_QUEUE;
} else {
if (destObj instanceof com.sun.messaging.Topic) {
if (aSpec._isDestTypeQueueSet())
throw new InvalidPropertyException("MQRA:EC:Inconsistent destinationType is set for destinationLookup " + destinationLookup);
this.destination = new com.sun.messaging.Topic(destName);
this.destinationType = ClientConstants.DESTINATION_TYPE_TOPIC;
}
}
} else if (aSpec._isDestTypeQueueSet()) {
this.destination = new com.sun.messaging.Queue(destName);
this.destinationType = ClientConstants.DESTINATION_TYPE_QUEUE;
} else {
// destinationType is TOPIC by default
this.destination = new com.sun.messaging.Topic(destName);
this.destinationType = ClientConstants.DESTINATION_TYPE_TOPIC;
}
} catch (JMSException jmse) {
String errorMessage;
if (destName == null) {
errorMessage = "MQRA:EC:No destination configured in ActivationSpec of MDB";
} else {
errorMessage = "MQRA:EC:Invalid destination " + destName + " configured in ActivationSpec of MDB";
}
NotSupportedException nse = new NotSupportedException(errorMessage);
nse.initCause(jmse);
throw nse;
}
// XXX:Does MDB Deployment need physical dest to exist?
// If so need Admin API to check
// XXX:Can MDB depoyment handle destname as resource-ref vs. physical dest name?
// If so, need to handle in ActivationSpec (how will AS handle this?)
}
use of jakarta.resource.ResourceException in project openmq by eclipse-ee4j.
the class EndpointConsumer method stopDirectMessageConsumer.
/**
* Stop the Direct MessageConsumer
*/
protected void stopDirectMessageConsumer() throws Exception {
stopping = true;
synchronized (this) {
if (this.msgConsumer != null) {
try {
if (this.msgListener != null) {
this.ds._stop();
msgListener.waitForAllOnMessageRunners();
msgListener.releaseOnMessageRunners();
// this.ds._close(); //Will be done by dc.close
}
} catch (JMSException jmse) {
ResourceException re = new ResourceException("MQRA:EC:Error on closing Direct MessageConsumer");
re.initCause(jmse);
throw re;
}
}
if (this.dc != null) {
try {
this.dc.close();
} catch (JMSException jmse) {
ResourceException re = new ResourceException("MQRA:EC:Error closing DircetConnection");
re.initCause(jmse);
throw re;
}
}
}
}
use of jakarta.resource.ResourceException in project openmq by eclipse-ee4j.
the class LocalTransaction method rollback.
/**
* Rollback a local transaction
*/
@Override
public synchronized void rollback() throws ResourceException {
// System.out.println("MQRA:LT:rollback()");
try {
if (!xac._isClosed()) {
xac.getProtocolHandler().rollback(transactionID, null);
} else {
ResourceException re = new EISSystemException("MQRA:LT:rollbackTransaction exception:Connection is closed");
throw re;
}
} catch (Exception ex) {
ResourceException re = new EISSystemException("MQRA:LT:rollback exception:" + ex.getMessage());
re.initCause(ex);
throw re;
} finally {
mc.setLTActive(false);
started = false;
active = false;
}
}
use of jakarta.resource.ResourceException in project openmq by eclipse-ee4j.
the class LocalTransaction method begin.
/**
* Begin a local transaction
*/
@Override
public synchronized void begin() throws ResourceException {
// System.out.println("MQRA:LT:begin()");
try {
if (!xac._isClosed()) {
transactionID = xac.getProtocolHandler().startTransaction(transactionID, -1, null);
} else {
ResourceException re = new EISSystemException("MQRA:LT:startTransaction exception:Connection is closed");
throw re;
}
// mc.getConnectionAdapter().getSessionAdapter().startLocalTransaction();
} catch (Exception ex) {
ResourceException re = new EISSystemException("MQRA:LT:startTransaction exception:" + ex.getMessage());
re.initCause(ex);
throw re;
}
started = true;
active = true;
mc.setLTActive(true);
}
Aggregations