use of org.apache.rocketmq.jms.domain.RMQPushConsumerExt in project rocketmq-externals by apache.
the class JmsTestUtil method checkConsumerState.
public static void checkConsumerState(String consumerId, boolean isNull, boolean isStarted) throws Exception {
RMQPushConsumerExt rmqPushConsumerExt = getRMQPushConsumerExt(consumerId);
if (isNull) {
Assert.assertNull(rmqPushConsumerExt);
} else {
Assert.assertNotNull(rmqPushConsumerExt);
Assert.assertEquals(isStarted, rmqPushConsumerExt.isStarted());
}
}
use of org.apache.rocketmq.jms.domain.RMQPushConsumerExt in project rocketmq-externals by apache.
the class JmsConsumerIT method testReferenceCount.
@Test
public void testReferenceCount() 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);
connection.start();
try {
Destination destination = session.createTopic(topic + ":" + messageType);
MessageConsumer consumer = session.createConsumer(destination);
consumer.setMessageListener(listener);
RMQPushConsumerExt rmqPushConsumerExt = getRMQPushConsumerExt(consumerId);
Assert.assertNotNull(rmqPushConsumerExt);
Assert.assertEquals(1, rmqPushConsumerExt.getReferenceCount());
MessageConsumer consumer2 = session.createConsumer(destination);
Assert.assertEquals(2, rmqPushConsumerExt.getReferenceCount());
MessageConsumer consumer3 = session.createConsumer(session.createTopic(topic + ":" + messageType));
Assert.assertEquals(3, rmqPushConsumerExt.getReferenceCount());
session.close();
Assert.assertEquals(0, rmqPushConsumerExt.getReferenceCount());
Assert.assertEquals(false, rmqPushConsumerExt.isStarted());
Assert.assertNull(getRMQPushConsumerExt(consumerId));
Thread.sleep(5000);
} finally {
connection.close();
}
}
use of org.apache.rocketmq.jms.domain.RMQPushConsumerExt in project rocketmq-externals by apache.
the class JmsTestUtil method getRMQPushConsumerExt.
public static RMQPushConsumerExt getRMQPushConsumerExt(String consumerId) throws Exception {
Assert.assertNotNull(consumerId);
Field field = JmsBaseMessageConsumer.class.getDeclaredField("consumerMap");
field.setAccessible(true);
ConcurrentMap<String, RMQPushConsumerExt> consumerMap = (ConcurrentMap<String, RMQPushConsumerExt>) field.get(null);
return consumerMap.get(consumerId);
}
Aggregations