use of org.apache.rocketmq.jms.domain.JmsBaseMessageConsumer in project rocketmq-externals by apache.
the class JmsConsumerIT method testStartIdempotency.
@Test
public void testStartIdempotency() throws Exception {
JmsBaseConnectionFactory connectionFactory = new JmsBaseConnectionFactory(new URI("rocketmq://xxx?consumerId=" + consumerId + "&nameServer=" + nameServer));
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
checkConsumerState(consumerId, true, false);
try {
Destination destination = session.createTopic(topic + ":" + messageType);
MessageConsumer consumer = session.createConsumer(destination);
consumer.setMessageListener(listener);
checkConsumerState(consumerId, false, false);
((JmsBaseMessageConsumer) consumer).startConsumer();
checkConsumerState(consumerId, false, true);
Destination destination1 = session.createTopic(topic2 + ":" + messageType);
MessageConsumer consumer1 = session.createConsumer(destination1);
consumer1.setMessageListener(listener);
((JmsBaseMessageConsumer) consumer1).startConsumer();
checkConsumerState(consumerId, false, true);
// the start is idempotent
connection.start();
connection.start();
Thread.sleep(5000);
} finally {
connection.close();
}
}
Aggregations