當前位置: 首頁>>代碼示例>>Java>>正文


Java FailoverTransport類代碼示例

本文整理匯總了Java中org.apache.activemq.transport.failover.FailoverTransport的典型用法代碼示例。如果您正苦於以下問題:Java FailoverTransport類的具體用法?Java FailoverTransport怎麽用?Java FailoverTransport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FailoverTransport類屬於org.apache.activemq.transport.failover包,在下文中一共展示了FailoverTransport類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: signalInterruptionProcessingComplete

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
private void signalInterruptionProcessingComplete() {
        if (LOG.isDebugEnabled()) {
            LOG.debug("transportInterruptionProcessingComplete: " + transportInterruptionProcessingComplete.get()
                    + " for:" + this.getConnectionInfo().getConnectionId());
        }

        FailoverTransport failoverTransport = transport.narrow(FailoverTransport.class);
        if (failoverTransport != null) {
            failoverTransport.connectionInterruptProcessingComplete(this.getConnectionInfo().getConnectionId());
            if (LOG.isDebugEnabled()) {
                LOG.debug("notified failover transport (" + failoverTransport
                        + ") of interruption completion for: " + this.getConnectionInfo().getConnectionId());
            }
        }
        transportInterruptionProcessingComplete.set(0);
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:17,代碼來源:ActiveMQConnection.java

示例2: signalInterruptionProcessingNeeded

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
private void signalInterruptionProcessingNeeded() {
    FailoverTransport failoverTransport = transport.narrow(FailoverTransport.class);
    if (failoverTransport != null) {
        failoverTransport.getStateTracker().transportInterrupted(this.getConnectionInfo().getConnectionId());
        if (LOG.isDebugEnabled()) {
            LOG.debug("notified failover transport (" + failoverTransport
                    + ") of pending interruption processing for: " + this.getConnectionInfo().getConnectionId());
        }
    }
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:11,代碼來源:ActiveMQConnection.java

示例3: testDurableSubRedeliveryFlagAfterRestartNotSupported

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
@org.junit.Test
public void testDurableSubRedeliveryFlagAfterRestartNotSupported() throws Exception {

   ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getPublishableConnectString() + ")?jms.prefetchPolicy.all=0");
   connection = (ActiveMQConnection) connectionFactory.createConnection();
   connection.setClientID("id");
   connection.start();

   Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
   ActiveMQTopic destination = new ActiveMQTopic(queueName);

   TopicSubscriber durableSub = session.createDurableSubscriber(destination, "id");

   populateDestination(10, destination, connection);

   TextMessage msg = null;
   for (int i = 0; i < 5; i++) {
      msg = (TextMessage) durableSub.receive(20000);
      LOG.info("not redelivered? got: " + msg);
      assertNotNull("got the message", msg);
      assertEquals("first delivery", 1, msg.getLongProperty("JMSXDeliveryCount"));
      assertEquals("not a redelivery", false, msg.getJMSRedelivered());
   }
   durableSub.close();

   restartBroker();

   // make failover aware of the restarted auto assigned port
   connection.getTransport().narrow(FailoverTransport.class).add(true, broker.getTransportConnectors().get(0).getPublishableConnectString());

   durableSub = session.createDurableSubscriber(destination, "id");
   for (int i = 0; i < 10; i++) {
      msg = (TextMessage) durableSub.receive(4000);
      LOG.info("redelivered? got: " + msg);
      assertNotNull("got the message again", msg);
      assertEquals("no reDelivery flag", false, msg.getJMSRedelivered());
      msg.acknowledge();
   }
   connection.close();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:41,代碼來源:RedeliveryRestartTest.java

示例4: getRootTransport

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
private Transport getRootTransport(Transport transport) {
    Transport possiblyWrappedTransport = transport;
    while (possiblyWrappedTransport instanceof TransportFilter) {
        possiblyWrappedTransport = ((TransportFilter) possiblyWrappedTransport).getNext();
        if (possiblyWrappedTransport instanceof FailoverTransport) {
            possiblyWrappedTransport = ((FailoverTransport) possiblyWrappedTransport).getConnectedTransport();
        }
    }
    return possiblyWrappedTransport;
}
 
開發者ID:naver,項目名稱:pinpoint,代碼行數:11,代碼來源:ActiveMQMessageProducerSendInterceptor.java

示例5: createTransport

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
public Transport createTransport(CompositeData compositeData) throws IOException {
    Map<String, String> parameters = new HashMap<String, String>(compositeData.getParameters());
    FailoverTransport failoverTransport = createTransport(parameters);
    return createTransport(failoverTransport, compositeData, parameters);
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:6,代碼來源:DiscoveryTransportFactory.java

示例6: assertTransactionGoneFromFailoverState

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
private void assertTransactionGoneFromFailoverState(ActiveMQXAConnection connection1, Xid tid) throws Exception {

      FailoverTransport transport = connection1.getTransport().narrow(FailoverTransport.class);
      TransactionInfo info = new TransactionInfo(connection1.getConnectionInfo().getConnectionId(), new XATransactionId(tid), TransactionInfo.COMMIT_ONE_PHASE);
      assertNull("transaction should not exist in the state tracker", transport.getStateTracker().processCommitTransactionOnePhase(info));
   }
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:7,代碼來源:ActiveMQXAConnectionFactoryTest.java

示例7: testValidateRedeliveryFlagAfterRestartNoTx

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
@org.junit.Test
public void testValidateRedeliveryFlagAfterRestartNoTx() throws Exception {

   ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getPublishableConnectString() + ")?jms.prefetchPolicy.all=0");
   connection = (ActiveMQConnection) connectionFactory.createConnection();
   connection.start();

   Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
   Destination destination = session.createQueue(queueName);
   populateDestination(10, destination, connection);

   MessageConsumer consumer = session.createConsumer(destination);
   TextMessage msg = null;
   for (int i = 0; i < 5; i++) {
      msg = (TextMessage) consumer.receive(20000);
      LOG.info("not redelivered? got: " + msg);
      assertNotNull("got the message", msg);
      assertEquals("first delivery", 1, msg.getLongProperty("JMSXDeliveryCount"));
      assertEquals("not a redelivery", false, msg.getJMSRedelivered());
   }
   consumer.close();

   restartBroker();

   // make failover aware of the restarted auto assigned port
   connection.getTransport().narrow(FailoverTransport.class).add(true, broker.getTransportConnectors().get(0).getPublishableConnectString());

   consumer = session.createConsumer(destination);
   for (int i = 0; i < 5; i++) {
      msg = (TextMessage) consumer.receive(4000);
      LOG.info("redelivered? got: " + msg);
      assertNotNull("got the message again", msg);
      assertEquals("re delivery flag", true, msg.getJMSRedelivered());
      assertEquals("redelivery count survives restart", 2, msg.getLongProperty("JMSXDeliveryCount"));
      msg.acknowledge();
   }

   // consume the rest that were not redeliveries
   for (int i = 0; i < 5; i++) {
      msg = (TextMessage) consumer.receive(20000);
      LOG.info("not redelivered? got: " + msg);
      assertNotNull("got the message", msg);
      assertEquals("not a redelivery", false, msg.getJMSRedelivered());
      assertEquals("first delivery", 1, msg.getLongProperty("JMSXDeliveryCount"));
      msg.acknowledge();
   }
   connection.close();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:49,代碼來源:RedeliveryRestartTest.java

示例8: testValidateRedeliveryFlagAfterRestart

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
@org.junit.Test
public void testValidateRedeliveryFlagAfterRestart() throws Exception {

   ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getPublishableConnectString() + ")?jms.prefetchPolicy.all=0");
   connection = (ActiveMQConnection) connectionFactory.createConnection();
   connection.start();

   Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
   Destination destination = session.createQueue(queueName);
   populateDestination(10, destination, connection);

   MessageConsumer consumer = session.createConsumer(destination);
   TextMessage msg = null;
   for (int i = 0; i < 5; i++) {
      msg = (TextMessage) consumer.receive(20000);
      LOG.info("not redelivered? got: " + msg);
      assertNotNull("got the message", msg);
      assertEquals("first delivery", 1, msg.getLongProperty("JMSXDeliveryCount"));
      assertEquals("not a redelivery", false, msg.getJMSRedelivered());
   }
   session.rollback();
   consumer.close();

   restartBroker();

   // make failover aware of the restarted auto assigned port
   connection.getTransport().narrow(FailoverTransport.class).add(true, broker.getTransportConnectors().get(0).getPublishableConnectString());

   consumer = session.createConsumer(destination);
   for (int i = 0; i < 5; i++) {
      msg = (TextMessage) consumer.receive(4000);
      LOG.info("redelivered? got: " + msg);
      assertNotNull("got the message again", msg);
      assertEquals("redelivery count survives restart", 2, msg.getLongProperty("JMSXDeliveryCount"));
      assertEquals("re delivery flag", true, msg.getJMSRedelivered());
   }
   session.commit();

   // consume the rest that were not redeliveries
   for (int i = 0; i < 5; i++) {
      msg = (TextMessage) consumer.receive(20000);
      LOG.info("not redelivered? got: " + msg);
      assertNotNull("got the message", msg);
      assertEquals("first delivery", 1, msg.getLongProperty("JMSXDeliveryCount"));
      assertEquals("not a redelivery", false, msg.getJMSRedelivered());
   }
   session.commit();

   connection.close();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:51,代碼來源:RedeliveryRestartTest.java

示例9: testValidateNoPersistenceForDurableAfterRestart

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
public void testValidateNoPersistenceForDurableAfterRestart() throws Exception {

      ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(" + broker.getTransportConnectors().get(0).getPublishableConnectString() + ")");
      ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
      connection.setClientID("clientId");
      connection.start();

      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

      Topic destination = session.createTopic(queueName);
      MessageConsumer consumer = session.createDurableSubscriber(destination, "subscriberName");

      populateDestination(10, destination, connection);

      restartBroker();

      // make failover aware of the restarted auto assigned port
      connection.getTransport().narrow(FailoverTransport.class).add(true, broker.getTransportConnectors().get(0).getPublishableConnectString());

      TextMessage msg = (TextMessage) consumer.receive(4000);
      assertNull("did not get a message when persistent=false, message: " + msg, msg);

      connection.close();
   }
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:25,代碼來源:DurablePersistentFalseRestartTest.java

示例10: testPublisherFailsOver

import org.apache.activemq.transport.failover.FailoverTransport; //導入依賴的package包/類
public void testPublisherFailsOver() throws Exception {
   ActiveMQDestination destination = new ActiveMQQueue("TEST");
   int deliveryMode = DeliveryMode.NON_PERSISTENT;

   // Start a normal consumer on the local broker
   StubConnection connection1 = createConnection();
   ConnectionInfo connectionInfo1 = createConnectionInfo();
   SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
   ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destination);
   connection1.send(connectionInfo1);
   connection1.send(sessionInfo1);
   connection1.request(consumerInfo1);

   // Start a normal consumer on a remote broker
   StubConnection connection2 = createRemoteConnection();
   ConnectionInfo connectionInfo2 = createConnectionInfo();
   SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
   ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destination);
   connection2.send(connectionInfo2);
   connection2.send(sessionInfo2);
   connection2.request(consumerInfo2);

   // Start a failover publisher.
   StubConnection connection3 = createFailoverConnection();
   ConnectionInfo connectionInfo3 = createConnectionInfo();
   SessionInfo sessionInfo3 = createSessionInfo(connectionInfo3);
   ProducerInfo producerInfo3 = createProducerInfo(sessionInfo3);
   connection3.send(connectionInfo3);
   connection3.send(sessionInfo3);
   connection3.send(producerInfo3);

   // Send the message using the fail over publisher.
   connection3.request(createMessage(producerInfo3, destination, deliveryMode));

   // The message will be sent to one of the brokers.
   FailoverTransport ft = connection3.getTransport().narrow(FailoverTransport.class);

   // See which broker we were connected to.
   StubConnection connectionA;
   StubConnection connectionB;
   TransportConnector serverA;
   if (connector.getServer().getConnectURI().getPort() == ft.getConnectedTransportURI().getPort()) {
      connectionA = connection1;
      connectionB = connection2;
      serverA = connector;
   } else {
      connectionA = connection2;
      connectionB = connection1;
      serverA = remoteConnector;
   }

   assertNotNull(receiveMessage(connectionA));
   assertNoMessagesLeft(connectionB);

   // Dispose the server so that it fails over to the other server.
   LOG.info("Disconnecting active server");
   serverA.stop();

   LOG.info("Sending request that should failover");
   connection3.request(createMessage(producerInfo3, destination, deliveryMode));

   assertNotNull(receiveMessage(connectionB));
   assertNoMessagesLeft(connectionA);

}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:66,代碼來源:DiscoveryTransportBrokerTest.java


注:本文中的org.apache.activemq.transport.failover.FailoverTransport類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。