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();
}
}
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);
}
}
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"));
}
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;
}
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"));
}
Aggregations