Equivalent to {@link #unsubscribe(ClientSessionChannel.MessageListener,ClientSessionChannel.MessageListener) unsubscribe(listener, null)}.
332333334335336337338339340341342
final ClientSessionChannel.MessageListener listener = listenerMap.remove(consumer); if (listener != null) { LOG.info("Unsubscribing from channel {}...", channelName); final ClientSessionChannel clientChannel = client.getChannel(channelName); clientChannel.unsubscribe(listener); // confirm unsubscribe try { if (!latch.await(CHANNEL_TIMEOUT, SECONDS)) { String message;
99100101102103104105106107108109
channel.publish("test"); Assert.assertFalse(messageLatch.await(1, TimeUnit.SECONDS)); final CountDownLatch unsubscribeLatch = new CountDownLatch(1); channel.unsubscribe(listener, new ClientSessionChannel.MessageListener() { @Override public void onMessage(ClientSessionChannel channel, Message message) { Assert.assertTrue(message.isSuccessful());
200201202203204205206207208209210
String data = "data"; aChannel.publish(data); message = messages.poll(5, TimeUnit.SECONDS); Assert.assertEquals(data, message.getData()); aChannel.unsubscribe(subscriber); message = metaMessages.poll(5, TimeUnit.SECONDS); Assert.assertEquals(Channel.META_UNSUBSCRIBE, message.getChannel()); Assert.assertTrue(message.isSuccessful()); disconnectBayeuxClient(client);
192193194195196197198199200201202
public void onMessage(ClientSessionChannel channel, Message message) { unsubscribe.countDown(); } }); channel.unsubscribe(listener); Assert.assertTrue(unsubscribe.await(5, TimeUnit.SECONDS)); Assert.assertTrue(channel.getSubscribers().isEmpty()); released = channel.release(); Assert.assertTrue(released);
284285286287288289290291292293294
{ } try { channel.unsubscribe(listener); Assert.fail(); } catch (IllegalStateException expected) { }
293294295296297298299300301302303
{ } try { channel.unsubscribe(); Assert.fail(); } catch (IllegalStateException expected) { }
143144145146147148149150151152153
client.batch(new Runnable() { public void run() { channel.subscribe(listener); channel.unsubscribe(listener); } }); Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); Assert.assertEquals(0, extension.rcvs.size());
126127128129130131132133134135136
assertTrue(subscribeLatch.await(5, TimeUnit.SECONDS)); channel.publish(new HashMap<>()); assertTrue(publishLatch.await(5, TimeUnit.SECONDS)); channel.unsubscribe(); assertTrue(unsubscribeLatch.await(5, TimeUnit.SECONDS)); disconnectBayeuxClient(client); }
464465466467468469470471472473474
String data = "data"; aChannel.publish(data); Assert.assertTrue(publishLatch.await(5, TimeUnit.SECONDS)); aChannel.unsubscribe(subscriber); Assert.assertTrue(unsubscribeLatch.await(5, TimeUnit.SECONDS)); disconnectBayeuxClient(client); }
203204205206207208209210211212213
Assert.assertEquals("hello",events.poll()); Assert.assertEquals(session1.getId(),events.poll()); Assert.assertEquals("hello",events.poll()); Assert.assertEquals(session2.getId(),events.poll()); Assert.assertEquals("hello",events.poll()); foostar0.unsubscribe(listener); session1.batch(new Runnable() { public void run() {