use of com.yahoo.pulsar.client.impl.ConsumerBase in project pulsar by yahoo.
the class ResendRequestTest method printIncomingMessageQueue.
private BlockingQueue<Message> printIncomingMessageQueue(Consumer consumer) throws Exception {
BlockingQueue<Message> imq = null;
ConsumerBase c = (ConsumerBase) consumer;
Field field = ConsumerBase.class.getDeclaredField("incomingMessages");
field.setAccessible(true);
imq = (BlockingQueue<Message>) field.get(c);
log.info("Incoming MEssage Queue: {}", imq);
return imq;
}
use of com.yahoo.pulsar.client.impl.ConsumerBase in project pulsar by yahoo.
the class ClientErrorsTest method subscribeFailDoesNotFailOtherConsumer.
private void subscribeFailDoesNotFailOtherConsumer(String topic1, String topic2) throws Exception {
PulsarClient client = PulsarClient.create("http://127.0.0.1:" + WEB_SERVICE_PORT);
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()));
});
ConsumerConfiguration conf = new ConsumerConfiguration();
conf.setSubscriptionType(SubscriptionType.Exclusive);
ConsumerBase consumer1 = (ConsumerBase) client.subscribe(topic1, "sub1", conf);
ConsumerBase consumer2 = null;
try {
consumer2 = (ConsumerBase) client.subscribe(topic2, "sub1", conf);
fail("Should have failed");
} catch (Exception e) {
// ok
}
assertTrue(consumer1.isConnected());
assertFalse(consumer2 != null && consumer2.isConnected());
mockBrokerService.resetHandleSubscribe();
client.close();
}
Aggregations