Package org.apache.activemq.transport

Examples of org.apache.activemq.transport.TransportListener


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

                public void onCommand(Object o) {
                    Command command = (Command) o;
                    serviceRemoteCommand(command);
                }
View Full Code Here


        public Worker(final String name) throws URISyntaxException, JMSException {
            this.name=name;
            URI uri = new URI("failover://(mock://(" + tcpUri + "))?updateURIsSupported=false");
            ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(uri);
            connection = (ActiveMQConnection)factory.createConnection();
            connection.addTransportListener(new TransportListener() {
                public void onCommand(Object command) {
                }

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

    public ConnectionPool(ActiveMQConnection connection, ObjectPoolFactory poolFactory) {
        this(connection, new HashMap<SessionKey, SessionPool>(), poolFactory);
        // Add a transport Listener so that we can notice if this connection
        // should be expired due to
        // a connection failure.
        connection.addTransportListener(new TransportListener() {
            public void onCommand(Object command) {
            }

            public void onException(IOException error) {
                synchronized (ConnectionPool.this) {
View Full Code Here

    public void testEviction() throws Exception {
        PooledConnection connection = (PooledConnection) pooledFactory.createConnection();
        ActiveMQConnection amqC = connection.getConnection();
        final CountDownLatch gotExceptionEvent = new CountDownLatch(1);
        amqC.addTransportListener(new TransportListener() {
            public void onCommand(Object command) {
            }
            public void onException(IOException error) {
                // we know connection is dead...
                // listeners are fired async
View Full Code Here

            onException(IOExceptionSupport.create(e));
        }
    }

    public void sendToActiveMQ(Command command) {
        TransportListener l = transportListener;
        if (l!=null) {
            l.onCommand(command);
        }
    }
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);
            }
View Full Code Here

        }, "ActiveMQ Failover Worker: " + System.identityHashCode(this));
    }

    TransportListener createTransportListener() {
        return new TransportListener() {
            public void onCommand(Object o) {
                Command command = (Command) o;
                if (command == null) {
                    return;
                }
View Full Code Here

        if (peer == null) {
            throw new IOException("Peer not connected.");
        }

       
        TransportListener transportListener=null;
        try {
            // Disable the peer from changing his state while we try to enqueue onto him.
            peer.enqueueValve.increment();
       
            if (peer.disposed || peer.stopping.get()) {
View Full Code Here

    /**
     * @see org.apache.activemq.thread.Task#iterate()
     */
    public boolean iterate() {
       
        final TransportListener tl;
        try {
            // Disable changing the state variables while we are running...
            enqueueValve.increment();
            tl = transportListener;
            if (!started || disposed || tl == null || stopping.get()) {
                if( stopping.get() ) {
                    // drain the queue it since folks could be blocked putting on to
                    // it and that would not allow the stop() method for finishing up.
                    getMessageQueue().clear()
                }
                return false;
            }
        } catch (InterruptedException e) {
            return false;
        } finally {
            enqueueValve.decrement();
        }

        LinkedBlockingQueue<Object> mq = getMessageQueue();
        Object command = mq.poll();
        if (command != null) {
            if( command == DISCONNECT ) {
                tl.onException(new TransportDisposedIOException("Peer (" + peer.toString() + ") disposed."));
            } else {
                tl.onCommand(command);
            }
            return !mq.isEmpty();
        } else {
            return false;
        }
View Full Code Here

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

                public void onCommand(Object o) {
                    Command command = (Command) o;
                    serviceRemoteCommand(command);
                }
View Full Code Here

TOP

Related Classes of org.apache.activemq.transport.TransportListener

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.