use of jakarta.resource.ResourceException in project openmq by eclipse-ee4j.
the class DirectLocalTransaction method begin.
/**
* Begin a local transaction
*/
@Override
public synchronized void begin() throws ResourceException {
// System.out.println("MQRA:LT:begin()");
try {
if (!dc.isClosed()) {
transactionID = this.dc._startTransaction("DirectLocalTransaction.begin()");
} 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);
}
use of jakarta.resource.ResourceException in project openmq by eclipse-ee4j.
the class ResourceAdapter method endpointActivation.
/**
* Activate a message endpoint. Called by the Application Server when a message-driven bean is deployed.
*
* {@inheritDoc}
*/
@Override
public void endpointActivation(MessageEndpointFactory endpointFactory, jakarta.resource.spi.ActivationSpec spec) throws ResourceException {
Object[] params = new Object[2];
params[0] = endpointFactory;
params[1] = spec;
_loggerIM.entering(_className, "endpointActivation()", params);
if (!started) {
_loggerIM.logp(Level.SEVERE, _className, "endpointActivation()", _lgrMID_EXC + "MQJMSRA not started:Aborting:", params);
NotSupportedException nse = new NotSupportedException("MQJMSRA-endpointActivation:Error:RA not started:aborting");
_loggerIM.throwing(_className, "endpointActivation()", nse);
throw nse;
}
EndpointConsumer ec;
if ((System.getProperty("imq.jmsra.endpoint.concurrent", "false")).equals("true")) {
ec = new ConcurrentEndpointConsumer(this, endpointFactory, spec);
} else {
ec = new EndpointConsumer(this, endpointFactory, spec);
}
try {
ec.startMessageConsumer();
// }
if (_loggerIM.isLoggable(Level.FINER)) {
_loggerIM.finer(_lgrMID_INF + "endpointActivation:createMessageConsumer:DONE:" + "fID=" + ec.getFactoryID() + " cID=" + ec.getConsumerID());
}
} catch (Exception ex) {
_loggerIM.logp(Level.SEVERE, _className, "endpointActivation()", _lgrMID_EXC + ":Failed due to:" + ex.getMessage(), params);
NotSupportedException nse = new NotSupportedException("MQJMSRA-endpointActivation:Exception on createMessageConsumer:");
nse.initCause(ex);
_loggerIM.throwing(_className, "endpointActivation()", nse);
throw nse;
}
_loggerIM.exiting(_className, "endpointActivation()");
}
use of jakarta.resource.ResourceException in project spring-framework by spring-projects.
the class GenericMessageEndpointManager method start.
/**
* Activates the configured message endpoint.
*/
@Override
public void start() {
synchronized (this.lifecycleMonitor) {
if (!this.running) {
ResourceAdapter resourceAdapter = getResourceAdapter();
Assert.state(resourceAdapter != null, "No ResourceAdapter set");
try {
resourceAdapter.endpointActivation(getMessageEndpointFactory(), getActivationSpec());
} catch (ResourceException ex) {
throw new IllegalStateException("Could not activate message endpoint", ex);
}
this.running = true;
}
}
}
use of jakarta.resource.ResourceException in project openmq by eclipse-ee4j.
the class DirectMessageListener method onMessage.
/**
*/
@Override
public void onMessage(jakarta.jms.Message jmsMsg) {
DirectPacket dpMsg = (DirectPacket) jmsMsg;
// boolean delivered = false;
// boolean acknowledged = false;
boolean redeliver = true;
int redeliverCount = 0;
while (redeliver == true) {
if (this.isDeliveryTransacted) {
try {
this.msgEndpoint.beforeDelivery(this.onMessageMethod);
} catch (ResourceException | NoSuchMethodException ex) {
ex.printStackTrace();
}
}
try {
((jakarta.jms.MessageListener) this.msgEndpoint).onMessage(jmsMsg);
// delivered = true;
redeliver = false;
try {
dpMsg._acknowledgeThisMessageForMDB(this.dxar);
// acknowledged = true;
this.dxar.setRollback(false, null);
} catch (JMSException ex) {
ex.printStackTrace();
}
} catch (Exception rte) {
// Here if onMessage threw any kind of Exception
if (redeliverCount > this.maxRedeliverCount) {
// Turn off redelivery and set cause for rollback if in txn
redeliver = false;
this.dxar.setRollback(true, rte);
} else {
redeliverCount++;
}
}
if (this.isDeliveryTransacted) {
try {
this.msgEndpoint.afterDelivery();
} catch (ResourceException ex) {
ex.printStackTrace();
}
}
}
// if (acknowledged != true){
// //Need to acknowledge as Dead
// }
}
use of jakarta.resource.ResourceException in project openmq by eclipse-ee4j.
the class DirectLocalTransaction method commit.
/**
* Commit a local transaction
*/
@Override
public synchronized void commit() throws ResourceException {
// System.out.println("MQRA:LT:commit()");
try {
if (!dc.isClosed()) {
this.dc._commitTransaction("DirectLocalTransaction.commit()", this.transactionID);
} else {
ResourceException re = new EISSystemException("MQRA:LT:commitTransaction exception:Connection is closed");
throw re;
}
} catch (Exception ex) {
ResourceException re = new EISSystemException("MQRA:LT:commit exception:" + ex.getMessage());
re.initCause(ex);
throw re;
} finally {
mc.setLTActive(false);
started = false;
active = false;
}
}
Aggregations