Package org.apache.activemq.command

Examples of org.apache.activemq.command.Response


    }

  private Response doSyncSendPacket(Command command, int timeout)
      throws JMSException {
    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 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: {" + command + "}for command id: " + response.getCorrelationId());
                }
            }
        } else {
            getTransportListener().onCommand(command);
        }
View Full Code Here

        connection.send(consumerInfo);

        // Since prepared but not committed.. they should not get delivered.
        assertNoMessagesLeft(connection);

        Response response = connection.request(new TransactionInfo(connectionInfo.getConnectionId(), null, TransactionInfo.RECOVER));
        assertNotNull(response);
        DataArrayResponse dar = (DataArrayResponse)response;
        assertEquals(4, dar.getData().length);

        // Commit the prepared transactions.
View Full Code Here

                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

            public void onCommand(Object o) {
                serviceLock.readLock().lock();
                try {
                    Command command = (Command)o;
                    Response response = service(command);
                    if (response != null) {
                        dispatchSync(response);
                    }
                } finally {
                    serviceLock.readLock().unlock();
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

     */
    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 {
                // Pass down any unexpected errors. Should this close the connection?
                if (response.isException()) {
                    Throwable exception = ((ExceptionResponse)response).getException();
                    handleException(exception, null);
                }
            }
        } else if (command.isMessageDispatch()) {
View Full Code Here

                        // Skipping send of ShutdownInfo command when not connected.
                        return;
                    }
                    if(command instanceof RemoveInfo) {
                        // Simulate response to RemoveInfo command
                        Response response = new Response();
                        response.setCorrelationId(command.getCommandId());
                        myTransportListener.onCommand(response);
                        return;
                    }
                }                     
                // Keep trying until the message is sent.
View Full Code Here

                            ActiveMQMessage message = (ActiveMQMessage)command;
                            if (AdvisorySupport.isConsumerAdvisoryTopic(message.getDestination())) {
                                serviceRemoteConsumerAdvisory(message.getDataStructure());
                            } else {
                                if (message.isResponseRequired()) {
                                    Response reply = new Response();
                                    reply.setCorrelationId(message.getCommandId());
                                    localBroker.oneway(message);
                                    remoteBroker.oneway(reply);
                                } else {
                                    localBroker.oneway(message);
                                }
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.