当前位置: 首页>>代码示例>>Java>>正文


Java TransportListener类代码示例

本文整理汇总了Java中org.apache.activemq.transport.TransportListener的典型用法代码示例。如果您正苦于以下问题:Java TransportListener类的具体用法?Java TransportListener怎么用?Java TransportListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransportListener类属于org.apache.activemq.transport包,在下文中一共展示了TransportListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doStart

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
    LOG.info("Starting " + this);

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

        @Override
        public void onException(IOException error) {
            LOG.error("Caught: " + error, error);
        }

        @Override
        public void transportInterupted() {
        }

        @Override
        public void transportResumed() {
        }
    });
    configuredTransport.start();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:27,代码来源:UdpTransportServer.java

示例2: dispatch

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
public void dispatch(VMTransport transport, BlockingQueue<Object> pending, Object command) {
    TransportListener transportListener = transport.getTransportListener();
    if (transportListener != null) {
        // Lock here on the target transport's started since we want to wait for its start()
        // method to finish dispatching out of the queue before we do our own.
        synchronized (transport.started) {

            // Ensure that no additional commands entered the queue in the small time window
            // before the start method locks the dispatch lock and the oneway method was in
            // an put operation.
            while(pending != null && !pending.isEmpty() && !transport.isDisposed()) {
                doDispatch(transport, transportListener, pending.poll());
            }

            // We are now in sync mode and won't enqueue any more commands to the target
            // transport so lets clean up its resources.
            transport.messageQueue = null;

            // Don't dispatch if either end was disposed already.
            if (command != null && !this.disposed.get() && !transport.isDisposed()) {
                doDispatch(transport, transportListener, command);
            }
        }
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:26,代码来源:VMTransport.java

示例3: onException

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Override
public void onException(final IOException error) {
    onAsyncException(error);
    if (!closing.get() && !closed.get()) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                transportFailed(error);
                ServiceSupport.dispose(ActiveMQConnection.this.transport);
                brokerInfoReceived.countDown();
                try {
                    cleanup();
                } catch (JMSException e) {
                    LOG.warn("Exception during connection cleanup, " + e, e);
                }
                for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) {
                    TransportListener listener = iter.next();
                    listener.onException(error);
                }
            }
        });
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:24,代码来源:ActiveMQConnection.java

示例4: transportInterupted

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Override
public void transportInterupted() {
    transportInterruptionProcessingComplete.set(1);
    for (Iterator<ActiveMQSession> i = this.sessions.iterator(); i.hasNext();) {
        ActiveMQSession s = i.next();
        s.clearMessagesInProgress(transportInterruptionProcessingComplete);
    }

    for (ActiveMQConnectionConsumer connectionConsumer : this.connectionConsumers) {
        connectionConsumer.clearMessagesInProgress(transportInterruptionProcessingComplete);
    }

    if (transportInterruptionProcessingComplete.decrementAndGet() > 0) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("transport interrupted - processing required, dispatchers: " + transportInterruptionProcessingComplete.get());
        }
        signalInterruptionProcessingNeeded();
    }

    for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) {
        TransportListener listener = iter.next();
        listener.transportInterupted();
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:25,代码来源:ActiveMQConnection.java

示例5: createTransport

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
protected Transport createTransport() throws Exception {
   Transport transport = TransportFactory.connect(new URI("failover://(tcp://localhost:1234?transport.connectTimeout=10000)"));
   transport.setTransportListener(new TransportListener() {

      @Override
      public void onCommand(Object command) {
      }

      @Override
      public void onException(IOException error) {
      }

      @Override
      public void transportInterupted() {
      }

      @Override
      public void transportResumed() {
      }
   });
   transport.start();

   this.failoverTransport = transport.narrow(FailoverTransport.class);

   return transport;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:FailoverTransportTest.java

示例6: doDispatch

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
public void doDispatch(VMTransport transport, TransportListener transportListener, Object command) {
    if (command == DISCONNECT) {
        transportListener.onException(new TransportDisposedIOException("Peer (" + peer.toString() + ") disposed."));
    } else {
        transport.receiveCounter++;
        transportListener.onCommand(command);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:9,代码来源:VMTransport.java

示例7: iterate

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
/**
 * @see org.apache.activemq.thread.Task#iterate()
 */
public boolean iterate() {

    final TransportListener tl = transportListener;

    LinkedBlockingQueue<Object> mq;
    try {
        mq = getMessageQueue();
    } catch (TransportDisposedIOException e) {
        return false;
    }

    Object command = mq.poll();
    if (command != null && !disposed.get()) {
        if( command == DISCONNECT ) {
            tl.onException(new TransportDisposedIOException("Peer (" + peer.toString() + ") disposed."));
        } else {
            tl.onCommand(command);
        }
        return !mq.isEmpty() && !disposed.get();
    } else {
        if(disposed.get()) {
            mq.clear();
        }
        return false;
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:30,代码来源:VMTransport.java

示例8: setTransportListener

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
/**
 */
public synchronized void setTransportListener(TransportListener channelListener) {
    this.transportListener = channelListener;
    if (channelListener == null) {
        getNext().setTransportListener(null);
    } else {
        getNext().setTransportListener(this);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:11,代码来源:MockTransport.java

示例9: sendToActiveMQ

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Override
public void sendToActiveMQ(Command command) {
    TransportListener l = transportListener;
    if (l != null) {
        l.onCommand(command);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:8,代码来源:StompTransportFilter.java

示例10: setTransportListener

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Override
public void setTransportListener(TransportListener commandListener) {
    synchronized (listenerMutex) {
        this.transportListener = commandListener;
        listenerMutex.notifyAll();
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:8,代码来源:FailoverTransport.java

示例11: transportResumed

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Override
public void transportResumed() {
    for (Iterator<TransportListener> iter = transportListeners.iterator(); iter.hasNext();) {
        TransportListener listener = iter.next();
        listener.transportResumed();
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:8,代码来源:ActiveMQConnection.java

示例12: startClient

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
/**
 * @throws Exception
 * @throws URISyntaxException
 */
private void startClient(String uri) throws Exception, URISyntaxException {
   clientTransport = TransportFactory.connect(new URI(uri));
   clientTransport.setTransportListener(new TransportListener() {
      @Override
      public void onCommand(Object command) {
         if (command instanceof WireFormatInfo) {
            clientWF.set((WireFormatInfo) command);
            negotiationCounter.countDown();
         }
      }

      @Override
      public void onException(IOException error) {
         if (!ignoreAsycError.get()) {
            LOG.info("Client transport error: ", error);
            asyncError.set(error);
            negotiationCounter.countDown();
         }
      }

      @Override
      public void transportInterupted() {
      }

      @Override
      public void transportResumed() {
      }
   });
   clientTransport.start();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:35,代码来源:WireformatNegociationTest.java

示例13: startClient

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
/**
 * @throws Exception
 * @throws URISyntaxException
 */
private void startClient() throws Exception, URISyntaxException {
   clientTransport = TransportFactory.connect(new URI("tcp://localhost:" + serverPort + "?trace=true&wireFormat.maxInactivityDuration=1000"));
   clientTransport.setTransportListener(new TransportListener() {
      @Override
      public void onCommand(Object command) {
         clientReceiveCount.incrementAndGet();
         if (clientRunOnCommand != null) {
            clientRunOnCommand.run();
         }
      }

      @Override
      public void onException(IOException error) {
         if (!ignoreClientError.get()) {
            LOG.info("Client transport error:");
            error.printStackTrace();
            clientErrorCount.incrementAndGet();
         }
      }

      @Override
      public void transportInterupted() {
      }

      @Override
      public void transportResumed() {
      }
   });
   clientTransport.start();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:35,代码来源:InactivityMonitorTest.java

示例14: onAccept

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Override
public void onAccept(Transport transport) {
   try {
      LOG.info("[" + getName() + "] Server Accepted a Connection");
      serverTransport = transport;
      serverTransport.setTransportListener(new TransportListener() {
         @Override
         public void onCommand(Object command) {
            serverReceiveCount.incrementAndGet();
            if (serverRunOnCommand != null) {
               serverRunOnCommand.run();
            }
         }

         @Override
         public void onException(IOException error) {
            if (!ignoreClientError.get()) {
               LOG.info("Server transport error:", error);
               serverErrorCount.incrementAndGet();
            }
         }

         @Override
         public void transportInterupted() {
         }

         @Override
         public void transportResumed() {
         }
      });
      serverTransport.start();
   } catch (Exception e) {
      e.printStackTrace();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:36,代码来源:InactivityMonitorTest.java

示例15: testNoBrokersInBrokerInfo

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
public void testNoBrokersInBrokerInfo() throws Exception {
   final BrokerInfo info[] = new BrokerInfo[1];
   TransportListener listener = new TransportListener() {
      @Override
      public void onCommand(Object command) {
         LOG.info("Got command: " + command);
         if (command instanceof BrokerInfo) {
            info[0] = (BrokerInfo) command;
         }
      }

      @Override
      public void onException(IOException error) {
         //To change body of implemented methods use File | Settings | File Templates.
      }

      @Override
      public void transportInterupted() {
         //To change body of implemented methods use File | Settings | File Templates.
      }

      @Override
      public void transportResumed() {
         //To change body of implemented methods use File | Settings | File Templates.
      }
   };
   @SuppressWarnings("unused")
   StubConnection c = createFailoverConnection(listener);
   int count = 0;
   while (count++ < 20 && info[0] == null) {
      TimeUnit.SECONDS.sleep(1);
   }
   Assert.assertNotNull("got a valid brokerInfo after 20 secs", info[0]);
   Assert.assertNull("no peer brokers present", info[0].getPeerBrokerInfos());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:36,代码来源:FailoverTransportBrokerTest.java


注:本文中的org.apache.activemq.transport.TransportListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。