本文整理汇总了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);
}
示例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());
}
}
}
示例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();
}
示例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;
}
示例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);
}
示例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));
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}