Search in sources :

Example 6 with ActiveMQXAException

use of org.apache.activemq.artemis.core.exception.ActiveMQXAException in project activemq-artemis by apache.

the class ServerSessionImpl method xaResume.

@Override
public synchronized void xaResume(final Xid xid) throws Exception {
    if (tx != null) {
        final String msg = "Cannot resume, session is currently doing work in a transaction " + tx.getXid();
        throw new ActiveMQXAException(XAException.XAER_PROTO, msg);
    } else {
        Transaction theTx = resourceManager.getTransaction(xid);
        if (theTx == null) {
            final String msg = "Cannot find xid in resource manager: " + xid;
            throw new ActiveMQXAException(XAException.XAER_NOTA, msg);
        } else {
            if (theTx.getState() != Transaction.State.SUSPENDED) {
                throw new ActiveMQXAException(XAException.XAER_PROTO, "Cannot resume transaction, it is not suspended " + xid);
            } else {
                tx = theTx;
                tx.resume();
            }
        }
    }
}
Also used : Transaction(org.apache.activemq.artemis.core.transaction.Transaction) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQXAException(org.apache.activemq.artemis.core.exception.ActiveMQXAException)

Example 7 with ActiveMQXAException

use of org.apache.activemq.artemis.core.exception.ActiveMQXAException in project activemq-artemis by apache.

the class ServerSessionPacketHandler method onSessionSend.

private void onSessionSend(Packet packet) {
    this.storageManager.setContext(session.getSessionContext());
    try {
        Packet response = null;
        boolean requiresResponse = false;
        try {
            final SessionSendMessage message = (SessionSendMessage) packet;
            requiresResponse = message.isRequiresResponse();
            this.session.send(EmbedMessageUtil.extractEmbedded(message.getMessage()), this.direct);
            if (requiresResponse) {
                response = new NullResponseMessage();
            }
        } catch (ActiveMQIOErrorException e) {
            response = onActiveMQIOErrorExceptionWhileHandlePacket(e, requiresResponse, response, this.session);
        } catch (ActiveMQXAException e) {
            response = onActiveMQXAExceptionWhileHandlePacket(e, requiresResponse, response);
        } catch (ActiveMQQueueMaxConsumerLimitReached e) {
            response = onActiveMQQueueMaxConsumerLimitReachedWhileHandlePacket(e, requiresResponse, response);
        } catch (ActiveMQException e) {
            response = onActiveMQExceptionWhileHandlePacket(e, requiresResponse, response);
        } catch (Throwable t) {
            response = onCatchThrowableWhileHandlePacket(t, requiresResponse, response, this.session);
        }
        sendResponse(packet, response, false, false);
    } finally {
        this.storageManager.clearContext();
    }
}
Also used : ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) NullResponseMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NullResponseMessage) SessionSendMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage) ActiveMQXAException(org.apache.activemq.artemis.core.exception.ActiveMQXAException) ActiveMQQueueMaxConsumerLimitReached(org.apache.activemq.artemis.api.core.ActiveMQQueueMaxConsumerLimitReached)

Example 8 with ActiveMQXAException

use of org.apache.activemq.artemis.core.exception.ActiveMQXAException in project activemq-artemis by apache.

the class ServerSessionPacketHandler method onSessionConsumerFlowCredit.

private void onSessionConsumerFlowCredit(Packet packet) {
    this.storageManager.setContext(session.getSessionContext());
    try {
        Packet response = null;
        boolean requiresResponse = false;
        try {
            SessionConsumerFlowCreditMessage message = (SessionConsumerFlowCreditMessage) packet;
            session.receiveConsumerCredits(message.getConsumerID(), message.getCredits());
        } catch (ActiveMQIOErrorException e) {
            response = onActiveMQIOErrorExceptionWhileHandlePacket(e, requiresResponse, response, this.session);
        } catch (ActiveMQXAException e) {
            response = onActiveMQXAExceptionWhileHandlePacket(e, requiresResponse, response);
        } catch (ActiveMQQueueMaxConsumerLimitReached e) {
            response = onActiveMQQueueMaxConsumerLimitReachedWhileHandlePacket(e, requiresResponse, response);
        } catch (ActiveMQException e) {
            response = onActiveMQExceptionWhileHandlePacket(e, requiresResponse, response);
        } catch (Throwable t) {
            response = onCatchThrowableWhileHandlePacket(t, requiresResponse, response, this.session);
        }
        sendResponse(packet, response, false, false);
    } finally {
        this.storageManager.clearContext();
    }
}
Also used : ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) SessionConsumerFlowCreditMessage(org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage) ActiveMQXAException(org.apache.activemq.artemis.core.exception.ActiveMQXAException) ActiveMQQueueMaxConsumerLimitReached(org.apache.activemq.artemis.api.core.ActiveMQQueueMaxConsumerLimitReached)

Aggregations

ActiveMQXAException (org.apache.activemq.artemis.core.exception.ActiveMQXAException)8 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)6 ActiveMQIOErrorException (org.apache.activemq.artemis.api.core.ActiveMQIOErrorException)6 ActiveMQQueueMaxConsumerLimitReached (org.apache.activemq.artemis.api.core.ActiveMQQueueMaxConsumerLimitReached)5 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 NullResponseMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.NullResponseMessage)3 List (java.util.List)1 XAException (javax.transaction.xa.XAException)1 ActiveMQIllegalStateException (org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException)1 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)1 ActiveMQExceptionMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.ActiveMQExceptionMessage)1 CreateAddressMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateAddressMessage)1 CreateQueueMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage)1 CreateQueueMessage_V2 (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateQueueMessage_V2)1 CreateSharedQueueMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage)1 CreateSharedQueueMessage_V2 (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.CreateSharedQueueMessage_V2)1 RollbackMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.RollbackMessage)1 SessionAcknowledgeMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionAcknowledgeMessage)1 SessionAddMetaDataMessage (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionAddMetaDataMessage)1 SessionAddMetaDataMessageV2 (org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionAddMetaDataMessageV2)1