public void onCompletion(FutureResponse future) { try { Response response = future.getResult(); if (response.isException()) { ExceptionResponse er = (ExceptionResponse)response; serviceLocalException(er.getException()); } else { dequeueCounter.incrementAndGet(); localBroker.oneway(new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1)); } } catch (IOException e) { serviceLocalException(e); } } };
MDC.put("activemq.connector", connector.getUri().toString()); Response response = null; boolean responseRequired = command.isResponseRequired(); int commandId = command.getCommandId(); try { if (status.get() != PENDING_STOP) { response = command.visit(this); } else { response = new ExceptionResponse(transportException.get()); if (e instanceof SecurityException || e.getCause() instanceof SecurityException) { SERVICELOG.warn("Security Error occurred on connection to: {}, {}", transport.getRemoteAddress(), e.getMessage()); response = new ExceptionResponse(e); } else { forceRollbackOnlyOnFailedAsyncTransactionOp(e, command); response = new Response(); response.setCorrelationId(commandId);
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); ExceptionResponse info = (ExceptionResponse)o; info.setException((java.lang.Throwable) tightUnmarsalThrowable(wireFormat, dataIn, bs)); }
if (command.isResponse()) { ResponseHandler rh = resposeHandlers.remove(Integer.valueOf(response.getCorrelationId())); if (rh != null) { rh.onResponse(this, response); } else { if (response.isException()) { Throwable exception = ((ExceptionResponse)response).getException(); handleException(exception, null); } else if (command.isMessageDispatch()) { sub.onMessageDispatch(md); } else if (command.getDataStructureType() == ConnectionError.DATA_STRUCTURE_TYPE) {
public FutureResponse asyncRequest(Object o, ResponseCallback responseCallback) throws IOException { Command command = (Command) o; command.setCommandId(sequenceGenerator.getNextSequenceId()); command.setResponseRequired(true); FutureResponse future = new FutureResponse(responseCallback, this); IOException priorError = null; synchronized (requestMap) { priorError = this.error; if (priorError == null) { requestMap.put(new Integer(command.getCommandId()), future); } } if (priorError != null) { future.set(new ExceptionResponse(priorError)); throw priorError; } next.oneway(command); return future; }
@Override public void run() { try { // While waiting for space to free up... the // message may have expired. if (message.isExpired()) { broker.messageExpired(context, message, null); getDestinationStatistics().getExpired().increment(); } else { doMessageSend(producerExchange, message); } if (sendProducerAck) { ProducerAck ack = new ProducerAck(producerInfo.getProducerId(), message .getSize()); context.getConnection().dispatchAsync(ack); } else { Response response = new Response(); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } catch (Exception e) { if (!sendProducerAck && !context.isInRecoveryMode()) { ExceptionResponse response = new ExceptionResponse(e); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } } } });
protected void process(MultiplexerInput input, int realCorrelationId, Response response) throws IOException { if (response.isException()) { ExceptionResponse er = (ExceptionResponse) response; onFailure(er.getException()); } else { Response copy = new Response(); response.copy(copy); copy.setCorrelationId(realCorrelationId); input.oneway(copy); } }
? this.transport.request(command, timeout) : this.transport.request(command)); if (response.isException()) { ExceptionResponse er = (ExceptionResponse)response; if (er.getException() instanceof JMSException) { throw (JMSException)er.getException(); } else { if (isClosed() || closing.get()) { jmsEx = JMSExceptionSupport.create(er.getException()); } catch(Throwable e) { LOG.error("Caught an exception trying to create a JMSException for " +er.getException(),e); if (er.getException() instanceof SecurityException && command instanceof ConnectionInfo){ try { forceCloseOnSecurityException(er.getException()); } catch (Throwable t) {
try { response = resp.getResult(); if (response.isException()) { ExceptionResponse er = (ExceptionResponse)response; exception = er.getException();
LOG.debug("tx replay producer :" + producerState.getInfo()); transport.oneway(producerState.getInfo()); LOG.debug("tx replay: " + command); transport.oneway(command); LOG.debug("tx remove replayed producer :" + producerState.getInfo()); transport.oneway(producerState.getInfo().createRemoveCommand()); ExceptionResponse response = new ExceptionResponse(); response.setException(new TransactionRolledBackException("Transaction completion in doubt due to failover. Forcing rollback of " + command.getTransactionId())); response.setCorrelationId(command.getCommandId()); transport.getTransportListener().onCommand(response);
/** * Write a object instance to data output stream * * @param o the instance to be marshaled * @param dataOut the output stream * @throws IOException thrown if an error occurs */ public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException { super.tightMarshal2(wireFormat, o, dataOut, bs); ExceptionResponse info = (ExceptionResponse)o; tightMarshalThrowable2(wireFormat, info.getException(), dataOut, bs); }
X509Certificate[] peerCerts = originalTransport.getPeerCertificates(); localConnectionInfo.setTransportContext(peerCerts); Object resp = localBroker.request(localConnectionInfo); if (resp instanceof ExceptionResponse) { throw ((ExceptionResponse) resp).getException(); localBroker.oneway(localSessionInfo); resp = duplexInboundLocalBroker.request(duplexLocalConnectionInfo); if (resp instanceof ExceptionResponse) { throw ((ExceptionResponse) resp).getException();
@Override public void run() { TimeoutMessage timeout; try { while (true) { timeout = flowControlTimeoutMessages.take(); if (timeout != null) { synchronized (messagesWaitingForSpace) { if (messagesWaitingForSpace.remove(timeout.message.getMessageId()) != null) { ExceptionResponse response = new ExceptionResponse( new ResourceAllocationException( "Usage Manager Memory Limit Wait Timeout. Stopping producer (" + timeout.message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info")); response.setCorrelationId(timeout.message.getCommandId()); timeout.context.getConnection().dispatchAsync(response); } } } } } catch (InterruptedException e) { LOG.debug(getName() + "Producer Flow Control Timeout Task is stopping"); } } }
/** * @return a new object instance */ public DataStructure createObject() { return new ExceptionResponse(); }
@Override public void onActiveMQCommand(Command command) throws Exception { if (command.isResponse()) { Response response = (Response) command; ResponseHandler rh = resposeHandlers.remove(Integer.valueOf(response.getCorrelationId())); if (rh != null) { rh.onResponse(this, response); } else { if (response.isException()) { Throwable exception = ((ExceptionResponse) response).getException(); handleException(exception); } else if (command.isMessageDispatch()) { MessageDispatch dispatch = (MessageDispatch) command; AmqpSender sender = subscriptionsByConsumerId.get(dispatch.getConsumerId()); } else if (command.getDataStructureType() == ConnectionError.DATA_STRUCTURE_TYPE) {
public FutureResponse asyncRequest(Object o, ResponseCallback responseCallback) throws IOException { Command command = (Command) o; command.setCommandId(sequenceGenerator.getNextSequenceId()); command.setResponseRequired(true); FutureResponse future = new FutureResponse(responseCallback, this); IOException priorError = null; synchronized (requestMap) { priorError = this.error; if (priorError == null) { requestMap.put(new Integer(command.getCommandId()), future); } } if (priorError != null) { future.set(new ExceptionResponse(priorError)); throw priorError; } next.oneway(command); return future; }
context.getConnection().dispatchAsync(ack); } else { Response response = new Response(); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); ExceptionResponse response = new ExceptionResponse(e); response.setCorrelationId(message.getCommandId()); context.getConnection().dispatchAsync(response); } else {
protected void process(MultiplexerInput input, int realCorrelationId, Response response) throws IOException { if (response.isException()) { ExceptionResponse er = (ExceptionResponse) response; onFailure(er.getException()); } else { Response copy = new Response(); response.copy(copy); copy.setCorrelationId(realCorrelationId); input.oneway(copy); } }
protected void sendSyncToSlave(Command command) { try { Response response = (Response)slave.request(command); if (response.isException()) { ExceptionResponse er = (ExceptionResponse)response; LOG.error("Slave Failed", er.getException()); } } catch (Throwable e) { LOG.error("Slave Failed", e); } } }
@Override public void onResponse(AmqpProtocolConverter converter, Response response) throws IOException { if (response.isException()) { Throwable exception = ((ExceptionResponse) response).getException(); LOG.debug("Error during temp destination removeal: {}", exception.getMessage()); } } });