Package org.apache.activemq.command

Examples of org.apache.activemq.command.Response


                shutDown();
            } else {
                boolean responseRequired = command.isResponseRequired();
                int commandId = command.getCommandId();
                if (responseRequired) {
                    Response response = (Response)localBroker.request(command);
                    response.setCorrelationId(commandId);
                    remoteBroker.oneway(response);
                } else {
                    localBroker.oneway(command);
                }
            }
View Full Code Here


        }
    }

    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);
View Full Code Here

                                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);
                                }
                            }
                        }
                    });
View Full Code Here

                            // broker when we get confirmation that the remote
                            // broker has received the message.
                            ResponseCallback callback = new ResponseCallback() {
                                public void onCompletion(FutureResponse future) {
                                    try {
                                        Response response = future.getResult();
                                        if (response.isException()) {
                                            ExceptionResponse er = (ExceptionResponse)response;
                                            serviceLocalException(er.getException());
                                        } else {
                                            localBroker.oneway(new MessageAck(md, MessageAck.STANDARD_ACK_TYPE, 1));
                                            dequeueCounter.incrementAndGet();
View Full Code Here

    }

    public void onCommand(Object o) {
        Command command = (Command)o;
        if (command.isResponse()) {
            Response response = (Response)command;
            FutureResponse future = null;
            synchronized (requestMap) {
                future = requestMap.remove(Integer.valueOf(response.getCorrelationId()));
            }
            if (future != null) {
                future.set(response);
            } else {
                if (debug) {
                    LOG.debug("Received unexpected response for command id: " + response.getCorrelationId());
                }
            }
        } else {
            getTransportListener().onCommand(command);
        }
View Full Code Here

        this.transport = transport;
        this.transport.setTransportListener(new DefaultTransportListener() {

            public void onCommand(Object o) {
                Command command = (Command)o;
                Response response = service(command);
                if (response != null) {
                    dispatchSync(response);
                }
            }
View Full Code Here

            }
        }
    }

    public Response service(Command command) {
        Response response = null;
        boolean responseRequired = command.isResponseRequired();
        int commandId = command.getCommandId();
        try {
            response = command.visit(this);
        } catch (Throwable e) {
            if (responseRequired) {
                if (SERVICELOG.isDebugEnabled() && e.getClass() != BrokerStoppedException.class) {
                    SERVICELOG.debug("Error occured while processing sync command: " + e, e);
                }
                response = new ExceptionResponse(e);
            } else {
                serviceException(e);
            }
        }
        if (responseRequired) {
            if (response == null) {
                response = new Response();
            }
            response.setCorrelationId(commandId);
        }
        // The context may have been flagged so that the response is not
        // sent.
        if (context != null) {
            if (context.isDontSendReponse()) {
View Full Code Here

        if (isClosed()) {
            throw new ConnectionClosedException();
        } else {

            try {
                Response response = (Response)this.transport.request(command);
                if (response.isException()) {
                    ExceptionResponse er = (ExceptionResponse)response;
                    if (er.getException() instanceof JMSException) {
                        throw (JMSException)er.getException();
                    } else {
                        throw JMSExceptionSupport.create(er.getException());
View Full Code Here

        if (isClosed()) {
            throw new ConnectionClosedException();
        } else {

            try {
                Response response = (Response)this.transport.request(command, timeout);
                if (response != null && response.isException()) {
                    ExceptionResponse er = (ExceptionResponse)response;
                    if (er.getException() instanceof JMSException) {
                        throw (JMSException)er.getException();
                    } else {
                        throw JMSExceptionSupport.create(er.getException());
View Full Code Here

     */
    public void onActiveMQCommad(Command command) throws IOException, JMSException {

        if (command.isResponse()) {

            Response response = (Response)command;
            ResponseHandler rh = resposeHandlers.remove(Integer.valueOf(response.getCorrelationId()));
            if (rh != null) {
                rh.onResponse(this, response);
            }

        } else if (command.isMessageDispatch()) {
View Full Code Here

TOP

Related Classes of org.apache.activemq.command.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.