Package org.apache.activemq.command

Examples of org.apache.activemq.command.Command


            }

            // Run the MessageDispatch callbacks so that message references get
            // cleaned up.
            for (Iterator<Command> iter = dispatchQueue.iterator(); iter.hasNext();) {
                Command command = iter.next();
                if (command.isMessageDispatch()) {
                    MessageDispatch md = (MessageDispatch)command;
                    Runnable sub = md.getTransmitCallback();
                    broker.postProcessDispatch(md);
                    if (sub != null) {
                        sub.run();
View Full Code Here


    /**
     * @param o - the command to consume
     */
    public void onCommand(final Object o) {
        final Command command = (Command)o;
        if (!closed.get() && command != null) {
            try {
                command.visit(new CommandVisitorAdapter() {
                    @Override
                    public Response processMessageDispatch(MessageDispatch md) throws Exception {
                        ActiveMQDispatcher dispatcher = dispatchers.get(md.getConsumerId());
                        if (dispatcher != null) {
                            // Copy in case a embedded broker is dispatching via
View Full Code Here

        this.protocolConverter = new ProtocolConverter(this, translator);
    }

    public void oneway(Object o) throws IOException {
        try {
            final Command command = (Command)o;
            protocolConverter.onActiveMQCommad(command);
        } catch (JMSException e) {
            throw IOExceptionSupport.create(e);
        }
    }
View Full Code Here

    private void restoreTransactions(Transport transport, ConnectionState connectionState) throws IOException {
        for (Iterator iter = connectionState.getTransactionStates().iterator(); iter.hasNext();) {
            TransactionState transactionState = (TransactionState)iter.next();
            for (Iterator iterator = transactionState.getCommands().iterator(); iterator.hasNext();) {
                Command command = (Command)iterator.next();
                transport.oneway(command);
            }
        }
    }
View Full Code Here

    public void setMaxReconnectAttempts(int maxReconnectAttempts) {
        this.maxReconnectAttempts = maxReconnectAttempts;
    }

    public void oneway(Object o) throws IOException {
        final Command command = (Command)o;
        try {
            synchronized (reconnectMutex) {

                // Wait for transport to be connected.
                while (connectedCount < minAckCount && !disposed && connectionFailure == null) {
                    LOG.debug("Waiting for at least " + minAckCount + " transports to be connected.");
                    reconnectMutex.wait(1000);
                }

                // Still not fully connected.
                if (connectedCount < minAckCount) {

                    Exception error;

                    // Throw the right kind of error..
                    if (disposed) {
                        error = new IOException("Transport disposed.");
                    } else if (connectionFailure != null) {
                        error = connectionFailure;
                    } else {
                        error = new IOException("Unexpected failure.");
                    }

                    if (error instanceof IOException) {
                        throw (IOException)error;
                    }
                    throw IOExceptionSupport.create(error);
                }

                // If it was a request and it was not being tracked by
                // the state tracker,
                // then hold it in the requestMap so that we can replay
                // it later.
                boolean fanout = isFanoutCommand(command);
                if (stateTracker.track(command) == null && command.isResponseRequired()) {
                    int size = fanout ? minAckCount : 1;
                    requestMap.put(new Integer(command.getCommandId()), new RequestCounter(command, size));
                }
               
                // Send the message.
                if (fanout) {
                    for (Iterator<FanoutTransportHandler> iter = transports.iterator(); iter.hasNext();) {
View Full Code Here

        public FanoutTransportHandler(URI uri) {
            this.uri = uri;
        }

        public void onCommand(Object o) {
            Command command = (Command)o;
            if (command.isResponse()) {
                Integer id = new Integer(((Response)command).getCorrelationId());
                RequestCounter rc = requestMap.get(id);
                if (rc != null) {
                    if (rc.ackCount.decrementAndGet() <= 0) {
                        requestMap.remove(id);
View Full Code Here

        }
        super.oneway(command);
    }

    public void onCommand(Object o) {
        Command command = (Command)o;
        if (command.isWireFormatInfo()) {
            WireFormatInfo info = (WireFormatInfo)command;
            if (LOG.isDebugEnabled()) {
                LOG.debug("Received WireFormat: " + info);
            }
View Full Code Here

    /**
     * @param o - the command to consume
     */
    public void onCommand(final Object o) {
        final Command command = (Command)o;
        if (!closed.get() && command != null) {
            try {
                command.visit(new CommandVisitorAdapter() {
                    @Override
                    public Response processMessageDispatch(MessageDispatch md) throws Exception {
                        waitForTransportInterruptionProcessingToComplete();
                        ActiveMQDispatcher dispatcher = dispatchers.get(md.getConsumerId());
                        if (dispatcher != null) {
View Full Code Here

        super(wireFormat, remoteUrl);
        url = new URL(remoteUrl.toString());
    }

    public void oneway(Object o) throws IOException {
        final Command command = (Command)o;
        try {
            if (command.getDataStructureType() == ConnectionInfo.DATA_STRUCTURE_TYPE) {
                boolean startGetThread = clientID == null;
                clientID = ((ConnectionInfo)command).getClientId();
                if (startGetThread && isStarted()) {
                    try {
                        super.doStart();
View Full Code Here

                        baos.write(c);
                    }
                    ByteSequence sequence = baos.toByteSequence();
                    String data = new String(sequence.data, sequence.offset, sequence.length, "UTF-8");

                    Command command = (Command)getTextWireFormat().unmarshalText(data);

                    if (command == null) {
                        LOG.warn("Received null packet from url: " + remoteUrl);
                    } else {
                        doConsume(command);
View Full Code Here

TOP

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

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.