Search in sources :

Example 6 with ResourceException

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);
}
Also used : EISSystemException(jakarta.resource.spi.EISSystemException) ResourceException(jakarta.resource.ResourceException) EISSystemException(jakarta.resource.spi.EISSystemException) ResourceException(jakarta.resource.ResourceException)

Example 7 with ResourceException

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()");
}
Also used : NotSupportedException(jakarta.resource.NotSupportedException) ResourceAdapterInternalException(jakarta.resource.spi.ResourceAdapterInternalException) JMSException(jakarta.jms.JMSException) ResourceException(jakarta.resource.ResourceException) NotSupportedException(jakarta.resource.NotSupportedException)

Example 8 with ResourceException

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;
        }
    }
}
Also used : ResourceAdapter(jakarta.resource.spi.ResourceAdapter) ResourceException(jakarta.resource.ResourceException)

Example 9 with ResourceException

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
// }
}
Also used : ResourceException(jakarta.resource.ResourceException) JMSException(jakarta.jms.JMSException) MessageEndpoint(jakarta.resource.spi.endpoint.MessageEndpoint) UnavailableException(jakarta.resource.spi.UnavailableException) JMSException(jakarta.jms.JMSException) ResourceException(jakarta.resource.ResourceException)

Example 10 with ResourceException

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;
    }
}
Also used : EISSystemException(jakarta.resource.spi.EISSystemException) ResourceException(jakarta.resource.ResourceException) EISSystemException(jakarta.resource.spi.EISSystemException) ResourceException(jakarta.resource.ResourceException)

Aggregations

ResourceException (jakarta.resource.ResourceException)14 EISSystemException (jakarta.resource.spi.EISSystemException)6 NotSupportedException (jakarta.resource.NotSupportedException)4 JMSException (jakarta.jms.JMSException)2 NamingException (javax.naming.NamingException)2 JMSService (com.sun.messaging.jmq.jmsservice.JMSService)1 jakarta.jms (jakarta.jms)1 InvalidPropertyException (jakarta.resource.spi.InvalidPropertyException)1 ResourceAdapter (jakarta.resource.spi.ResourceAdapter)1 ResourceAdapterInternalException (jakarta.resource.spi.ResourceAdapterInternalException)1 UnavailableException (jakarta.resource.spi.UnavailableException)1 MessageEndpoint (jakarta.resource.spi.endpoint.MessageEndpoint)1