Search in sources :

Example 1 with ExceptionResponse

use of org.apache.activemq.command.ExceptionResponse in project activemq-artemis by apache.

the class OpenWireConnection method bufferReceived.

@Override
public void bufferReceived(Object connectionID, ActiveMQBuffer buffer) {
    super.bufferReceived(connectionID, buffer);
    try {
        recoverOperationContext();
        Command command = (Command) inWireFormat.unmarshal(buffer);
        // log the openwire command
        if (logger.isTraceEnabled()) {
            traceBufferReceived(connectionID, command);
        }
        boolean responseRequired = command.isResponseRequired();
        int commandId = command.getCommandId();
        // ignore pings
        if (command.getClass() != KeepAliveInfo.class) {
            Response response = null;
            try {
                setLastCommand(command);
                response = command.visit(commandProcessorInstance);
            } catch (Exception e) {
                ActiveMQServerLogger.LOGGER.warn("Errors occurred during the buffering operation ", e);
                if (responseRequired) {
                    response = convertException(e);
                }
            } finally {
                setLastCommand(null);
            }
            if (response instanceof ExceptionResponse) {
                Throwable cause = ((ExceptionResponse) response).getException();
                if (!responseRequired) {
                    serviceException(cause);
                    response = null;
                }
                // stop the connection to prevent dangling sockets
                if (command instanceof ConnectionInfo) {
                    delayedStop(2000, cause.getMessage(), cause);
                }
            }
            if (responseRequired) {
                if (response == null) {
                    response = new Response();
                    response.setCorrelationId(commandId);
                }
            }
            // sent.
            if (context != null) {
                if (context.isDontSendReponse()) {
                    context.setDontSendReponse(false);
                    response = null;
                }
            }
            sendAsyncResponse(commandId, response);
        }
    } catch (Exception e) {
        ActiveMQServerLogger.LOGGER.debug(e);
        sendException(e);
    } finally {
        clearupOperationContext();
    }
}
Also used : DataArrayResponse(org.apache.activemq.command.DataArrayResponse) Response(org.apache.activemq.command.Response) IntegerResponse(org.apache.activemq.command.IntegerResponse) ExceptionResponse(org.apache.activemq.command.ExceptionResponse) ExceptionResponse(org.apache.activemq.command.ExceptionResponse) ControlCommand(org.apache.activemq.command.ControlCommand) FlushCommand(org.apache.activemq.command.FlushCommand) Command(org.apache.activemq.command.Command) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQRemoteDisconnectException(org.apache.activemq.artemis.api.core.ActiveMQRemoteDisconnectException) IllegalStateException(javax.jms.IllegalStateException) XAException(javax.transaction.xa.XAException) InvalidDestinationException(javax.jms.InvalidDestinationException) ActiveMQNonExistentQueueException(org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException) IOException(java.io.IOException) ActiveMQAddressExistsException(org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException) ActiveMQSecurityException(org.apache.activemq.artemis.api.core.ActiveMQSecurityException) JMSSecurityException(javax.jms.JMSSecurityException) ActiveMQQueueExistsException(org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException) InvalidClientIDException(javax.jms.InvalidClientIDException)

Example 2 with ExceptionResponse

use of org.apache.activemq.command.ExceptionResponse in project activemq-artemis by apache.

the class StubConnection method send.

public void send(Command command) throws Exception {
    if (command instanceof Message) {
        Message message = (Message) command;
        message.setProducerId(message.getMessageId().getProducerId());
    }
    command.setResponseRequired(false);
    if (connection != null) {
        Response response = connection.service(command);
        if (response != null && response.isException()) {
            ExceptionResponse er = (ExceptionResponse) response;
            throw JMSExceptionSupport.create(er.getException());
        }
    } else if (transport != null) {
        transport.oneway(command);
    }
}
Also used : Response(org.apache.activemq.command.Response) ExceptionResponse(org.apache.activemq.command.ExceptionResponse) ExceptionResponse(org.apache.activemq.command.ExceptionResponse) Message(org.apache.activemq.command.Message)

Example 3 with ExceptionResponse

use of org.apache.activemq.command.ExceptionResponse in project activemq-artemis by apache.

the class ExceptionResponseTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ExceptionResponse info = (ExceptionResponse) object;
    info.setException(createThrowable("Exception:1"));
}
Also used : ExceptionResponse(org.apache.activemq.command.ExceptionResponse)

Example 4 with ExceptionResponse

use of org.apache.activemq.command.ExceptionResponse in project activemq-artemis by apache.

the class ExceptionResponseTest method createObject.

@Override
public Object createObject() throws Exception {
    ExceptionResponse info = new ExceptionResponse();
    populateObject(info);
    return info;
}
Also used : ExceptionResponse(org.apache.activemq.command.ExceptionResponse)

Example 5 with ExceptionResponse

use of org.apache.activemq.command.ExceptionResponse in project activemq-artemis by apache.

the class ExceptionResponseTest method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ExceptionResponse info = (ExceptionResponse) object;
    info.setException(createThrowable("Exception:1"));
}
Also used : ExceptionResponse(org.apache.activemq.command.ExceptionResponse)

Aggregations

ExceptionResponse (org.apache.activemq.command.ExceptionResponse)22 Response (org.apache.activemq.command.Response)3 Message (org.apache.activemq.command.Message)2 IOException (java.io.IOException)1 IllegalStateException (javax.jms.IllegalStateException)1 InvalidClientIDException (javax.jms.InvalidClientIDException)1 InvalidDestinationException (javax.jms.InvalidDestinationException)1 JMSSecurityException (javax.jms.JMSSecurityException)1 Session (javax.jms.Session)1 XAException (javax.transaction.xa.XAException)1 ActiveMQAddressExistsException (org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException)1 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)1 ActiveMQNonExistentQueueException (org.apache.activemq.artemis.api.core.ActiveMQNonExistentQueueException)1 ActiveMQQueueExistsException (org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException)1 ActiveMQRemoteDisconnectException (org.apache.activemq.artemis.api.core.ActiveMQRemoteDisconnectException)1 ActiveMQSecurityException (org.apache.activemq.artemis.api.core.ActiveMQSecurityException)1 Command (org.apache.activemq.command.Command)1 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)1 ConsumerControl (org.apache.activemq.command.ConsumerControl)1 ControlCommand (org.apache.activemq.command.ControlCommand)1