public void remove() { List<Integer> ids = new ArrayList<Integer>(2); if (syncListenerId != 0) { ids.add(syncListenerId); } if (reconnectionListenerId != 0) { ids.add(reconnectionListenerId); } invalidationTopic.removeListenerAsync(ids.toArray(new Integer[ids.size()])); }
public void remove() { List<Integer> ids = new ArrayList<Integer>(2); if (syncListenerId != 0) { ids.add(syncListenerId); } if (reconnectionListenerId != 0) { ids.add(reconnectionListenerId); } invalidationTopic.removeListenerAsync(ids.toArray(new Integer[ids.size()])); }
public void remove() { List<Integer> ids = new ArrayList<Integer>(2); if (syncListenerId != 0) { ids.add(syncListenerId); } if (reconnectionListenerId != 0) { ids.add(reconnectionListenerId); } invalidationTopic.removeListenerAsync(ids.toArray(new Integer[ids.size()])); }
public <M> Flux<M> getMessages(Class<M> type) { return Flux.<M>create(emitter -> { emitter.onRequest(n -> { AtomicLong counter = new AtomicLong(n); RFuture<Integer> t = topic.addListenerAsync(type, new MessageListener<M>() { @Override public void onMessage(CharSequence channel, M msg) { emitter.next(msg); if (counter.decrementAndGet() == 0) { topic.removeListenerAsync(this); emitter.complete(); } } }); t.whenComplete((id, e) -> { if (e != null) { emitter.error(e); return; } emitter.onDispose(() -> { topic.removeListenerAsync(id); }); }); }); }); }