Package org.apache.activemq.command

Examples of org.apache.activemq.command.Command


                serviceLock.readLock().lock();
                try {
                    if (!(o instanceof Command)) {
                        throw new RuntimeException("Protocol violation - Command corrupted: " + o.toString());
                    }
                    Command command = (Command) o;
                    Response response = service(command);
                    if (response != null) {
                        dispatchSync(response);
                    }
                } finally {
View Full Code Here


                    dispatchStoppedLatch.countDown();
                }
                return false;
            }
            if (!dispatchStopped.get()) {
                Command command = null;
                synchronized (dispatchQueue) {
                    if (dispatchQueue.isEmpty()) {
                        return false;
                    }
                    command = dispatchQueue.remove(0);
View Full Code Here

        active = false;
        // Run the MessageDispatch callbacks so that message references get
        // cleaned up.
        synchronized (dispatchQueue) {
            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

        if (started.compareAndSet(false, true)) {
            localBroker.setTransportListener(new DefaultTransportListener() {

                @Override
                public void onCommand(Object o) {
                    Command command = (Command) o;
                    serviceLocalCommand(command);
                }

                @Override
                public void onException(IOException error) {
                    serviceLocalException(error);
                }
            });
            remoteBroker.setTransportListener(new TransportListener() {

                public void onCommand(Object o) {
                    Command command = (Command) o;
                    serviceRemoteCommand(command);
                }

                public void onException(IOException error) {
                    serviceRemoteException(error);
View Full Code Here

    protected void doStart() throws Exception {
        log.info("Starting " + this);

        configuredTransport.setTransportListener(new TransportListener() {
            public void onCommand(Object o) {
              final Command command = (Command) o;
                processInboundConnection(command);
            }

            public void onException(IOException error) {
                log.error("Caught: " + error, error);
View Full Code Here

        started=true;
        if(transportListener==null)
            throw new IOException("TransportListener not set.");
        if(!async){
            for(Iterator iter=prePeerSetQueue.iterator();iter.hasNext();){
                Command command=(Command) iter.next();
                transportListener.onCommand(command);
                iter.remove();
            }
        }else{
            wakeup();
View Full Code Here

     * @see org.apache.activemq.thread.Task#iterate()
     */
    public boolean iterate(){
        final TransportListener tl=peer.transportListener;
        if(!messageQueue.isEmpty()&&!peer.disposed&&tl!=null){
            final Command command=(Command) messageQueue.poll();
            tl.onCommand(command);
        }
        return !messageQueue.isEmpty()&&!peer.disposed&&!(peer.transportListener==null);
    }
View Full Code Here

    }

    public void start() throws Exception {
        localBroker.setTransportListener(new DefaultTransportListener(){
            public void onCommand(Object o){
              Command command = (Command) o;
                serviceLocalCommand(command);
            }
   
            public void onException(IOException error){
                serviceLocalException(error);
            }
        });
        remoteBroker.setTransportListener(new TransportListener(){
            public void onCommand(Object o){
              Command command = (Command) o;
                serviceRemoteCommand(command);
            }
   
            public void onException(IOException error){
                serviceRemoteException(error);
View Full Code Here

     */
    public void run() {
        log.trace("Consumer thread starting for: " + toString());
        while (!isStopped()) {
            try {
                Command command = commandChannel.read();
                doConsume(command);
            }
            catch (AsynchronousCloseException e) {
                // DatagramChannel closed
                try {
View Full Code Here

    public void stop() throws Exception {
        bufferPool.stop();
    }

    public Command read() throws IOException {
        Command answer = null;
        Endpoint from = null;
        synchronized (readLock) {
            while (true) {
                readBuffer.clear();
                SocketAddress address = channel.receive(readBuffer);

                readBuffer.flip();

                if (readBuffer.limit() == 0) {
                    continue;
                }
                from = headerMarshaller.createEndpoint(readBuffer, address);

                int remaining = readBuffer.remaining();
                byte[] data = new byte[remaining];
                readBuffer.get(data);

                // TODO could use a DataInput implementation that talks direct
                // to
                // the ByteBuffer to avoid object allocation and unnecessary
                // buffering?
                DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(data));
                answer = (Command) wireFormat.unmarshal(dataIn);
                break;
            }
        }
        if (answer != null) {
            answer.setFrom(from);

            if (log.isDebugEnabled()) {
                log.debug("Channel: " + name + " received from: " + from + " about to process: " + answer);
            }
        }
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.