use of org.apache.pulsar.client.impl.ConsumerBase in project incubator-pulsar by apache.
the class ResendRequestTest method printIncomingMessageQueue.
@SuppressWarnings("unchecked")
private BlockingQueue<Message<byte[]>> printIncomingMessageQueue(Consumer<byte[]> consumer) throws Exception {
BlockingQueue<Message<byte[]>> imq = null;
ConsumerBase<byte[]> c = (ConsumerBase<byte[]>) consumer;
Field field = ConsumerBase.class.getDeclaredField("incomingMessages");
field.setAccessible(true);
imq = (BlockingQueue<Message<byte[]>>) field.get(c);
log.info("Incoming MEssage Queue: {}", imq);
return imq;
}
use of org.apache.pulsar.client.impl.ConsumerBase in project incubator-pulsar by apache.
the class ClientErrorsTest method subscribeFailDoesNotFailOtherConsumer.
private void subscribeFailDoesNotFailOtherConsumer(String topic1, String topic2) throws Exception {
PulsarClient client = PulsarClient.builder().serviceUrl("http://127.0.0.1:" + WEB_SERVICE_PORT).build();
final AtomicInteger counter = new AtomicInteger(0);
mockBrokerService.setHandleSubscribe((ctx, subscribe) -> {
if (counter.incrementAndGet() == 2) {
// fail second producer
ctx.writeAndFlush(Commands.newError(subscribe.getRequestId(), ServerError.AuthenticationError, "msg"));
return;
}
ctx.writeAndFlush(Commands.newSuccess(subscribe.getRequestId()));
});
ConsumerBase<byte[]> consumer1 = (ConsumerBase<byte[]>) client.newConsumer().topic(topic1).subscriptionName("sub1").subscribe();
ConsumerBase<byte[]> consumer2 = null;
try {
consumer2 = (ConsumerBase<byte[]>) client.newConsumer().topic(topic2).subscriptionName("sub1").subscribe();
fail("Should have failed");
} catch (Exception e) {
// ok
}
assertTrue(consumer1.isConnected());
assertFalse(consumer2 != null && consumer2.isConnected());
mockBrokerService.resetHandleSubscribe();
client.close();
}
Aggregations