• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TransportListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: createFailoverConnection

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
protected StubConnection createFailoverConnection(TransportListener listener) throws Exception {
   URI failoverURI = new URI("failover://" + newURI(0) + "," + newURI(1) + "");
   Transport transport = TransportFactory.connect(failoverURI);
   StubConnection connection = new StubConnection(transport, listener);
   connections.add(connection);
   return connection;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:8,代码来源:FailoverTransportBrokerTest.java


示例17: Worker

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
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() {
      @Override
      public void onCommand(Object command) {
      }

      @Override
      public void onException(IOException error) {
         setError(error);
      }

      @Override
      public void transportInterupted() {
         LOG.info("Worker " + name + " was interrupted...");
         interruptedCount.incrementAndGet();
      }

      @Override
      public void transportResumed() {
         LOG.info("Worker " + name + " was resummed...");
         resumedCount.incrementAndGet();
      }
   });
   connection.start();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:30,代码来源:ReconnectTest.java


示例18: testReconnectUnlimited

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Test(timeout = 30000)
@Ignore("Test fails on windows")
public void testReconnectUnlimited() throws Exception {

   Transport transport = TransportFactory.connect(new URI("failover://(tcp://0.0.0.0:61616)?useExponentialBackOff=false&reconnectDelay=0&initialReconnectDelay=0"));

   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);

   assertTrue("no implicit limit of 1000", Wait.waitFor(new Wait.Condition() {
      @Override
      public boolean isSatisified() throws Exception {
         return failoverTransport.getConnectFailures() > 1002;
      }
   }));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:36,代码来源:FailoverTransportTest.java


示例19: testLocalhostPortSyntax

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
@Test
public void testLocalhostPortSyntax() throws Exception {
   transport = TransportFactory.connect(new URI("failover://(tcp://localhost:1111/localhost:2111)"));

   transport.setTransportListener(new TransportListener() {

      @Override
      public void onCommand(Object command) {
      }

      @Override
      public void onException(IOException error) {
      }

      @Override
      public void transportInterupted() {
      }

      @Override
      public void transportResumed() {
      }
   });

   failoverTransport = transport.narrow(FailoverTransport.class);

   transport.start();

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


示例20: getConnection

import org.apache.activemq.transport.TransportListener; //导入依赖的package包/类
/**
 * Get the current connection or create one using the connectionSupplier.
 *
 * @return JMS Connection
 */
private Connection getConnection() {

    if (!connectionOption.isPresent()) {
        final Connection connection = connectionSupplier.get();

        if (connection instanceof ActiveMQConnection) {
            ((ActiveMQConnection) connection).addTransportListener(new TransportListener() {
                @Override
                public void onCommand(Object command) {

                }

                @Override
                public void onException(IOException error) {
                }

                @Override
                public void transportInterupted() {
                    connected.set(false);
                }

                @Override
                public void transportResumed() {
                    connected.set(true);
                }
            });
        }


        connected.set(true);

        if (startConnection) {
            try {
                connection.start();
            } catch (JMSException e) {
                throw new JmsException("Unable to start JMS connection", e);
            }
        }
        connectionOption = Optional.of(connection);
    }
    return connectionOption.get();
}
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:48,代码来源:JmsService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BeanDeserializer类代码示例发布时间:2022-05-22
下一篇:
Java Name类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap