@Override public void destroy() throws Exception { listenerContainer.removeMessageListener(this); }
/** * Removes the given message listener completely (from all topics). If the container is running, the listener stops * receiving (matching) messages as soon as possible. Similarly a null listener will unsubscribe all listeners from * the given topic. * * @param listener message listener */ public void removeMessageListener(MessageListener listener) { removeMessageListener(listener, Collections.<Topic> emptySet()); }
/** * Removes a message listener from the from the given topic. If the container is running, the listener stops receiving * (matching) messages as soon as possible. * <p> * Note that this method obeys the Redis (p)unsubscribe semantics - meaning an empty/null collection will remove * listener from all channels. Similarly a null listener will unsubscribe all listeners from the given topic. * * @param listener message listener * @param topic message topic */ public void removeMessageListener(MessageListener listener, Topic topic) { removeMessageListener(listener, Collections.singleton(topic)); }
private void unsubscribeConfig(MessageListenerAdapter messageListenerAdapter, boolean globalConfig) { String groupKey = pluginContextAware.getGroupKey(); String group = pluginAdapter.getGroup(); String serviceId = pluginAdapter.getServiceId(); LOG.info("Unsubscribe {} config from {} server, {}={}, serviceId={}", getConfigScope(globalConfig), getConfigType(), groupKey, group, serviceId); redisMessageListenerContainer.removeMessageListener(messageListenerAdapter, new PatternTopic(group + "-" + (globalConfig ? group : serviceId))); }
@Override public void destroy() throws Exception { listenerContainer.removeMessageListener(this); }
@Override public void destroy() throws Exception { listenerContainer.removeMessageListener(this); }
/** * Removes a message listener from the from the given topic. If the container is running, the listener stops receiving * (matching) messages as soon as possible. * <p> * Note that this method obeys the Redis (p)unsubscribe semantics - meaning an empty/null collection will remove * listener from all channels. Similarly a null listener will unsubscribe all listeners from the given topic. * * @param listener message listener * @param topic message topic */ public void removeMessageListener(MessageListener listener, Topic topic) { removeMessageListener(listener, Collections.singleton(topic)); }
/** * Removes the given message listener completely (from all topics). If the container is running, the listener stops * receiving (matching) messages as soon as possible. Similarly a null listener will unsubscribe all listeners from * the given topic. * * @param listener message listener */ public void removeMessageListener(MessageListener listener) { removeMessageListener(listener, Collections.<Topic> emptySet()); }
/** * Removes a message listener from the from the given topic. If the container is running, the listener stops receiving * (matching) messages as soon as possible. * <p> * Note that this method obeys the Redis (p)unsubscribe semantics - meaning an empty/null collection will remove * listener from all channels. Similarly a null listener will unsubscribe all listeners from the given topic. * * @param listener message listener * @param topic message topic */ public void removeMessageListener(MessageListener listener, Topic topic) { removeMessageListener(listener, Collections.singleton(topic)); }
/** * Removes the given message listener completely (from all topics). If the container is running, the listener stops * receiving (matching) messages as soon as possible. Similarly a null listener will unsubscribe all listeners from * the given topic. * * @param listener message listener */ public void removeMessageListener(MessageListener listener) { removeMessageListener(listener, Collections.<Topic> emptySet()); }
private void removeDeprecatedListeners(final List<String> listenersToRemove) { for (final String listenerName : listenersToRemove) { LOGGER.debug("Removing listener to topic {}", listenerName); listenerContainer.removeMessageListener(currentListeners.get(listenerName)); currentListeners.remove(listenerName); } }
private boolean unsubscribeMonitor() { boolean unsubscriptionDone = true; try { LOGGER.debug("Removing subscription from topic {}", monitorTopic.getTopic()); listenerContainer.removeMessageListener(monitorListener, monitorTopic); } catch (final RedisInvalidSubscriptionException rise) { LOGGER.error("An error occurred while unsubscribing from topic {}", monitorTopic.getTopic(), rise); unsubscriptionDone = false; } return unsubscriptionDone; }
private void removeAllSubscriptions(final Subscription subscription) { LOGGER.debug("Removing all subscriptions for listener {}", subscription.getSourceEntityId()); final MessageListenerImpl listener = listeners.get(subscription.getSourceEntityId()); if (listener != null) { listenerContainer.removeMessageListener(listener); // listener is removed from the active listeners list listeners.remove(subscription.getSourceEntityId()); } // Finally, the subscription is removed from Redis jedisTemplate.del(keysBuilder.getSubscriptionKey(subscription.getSourceEntityId())); LOGGER.debug("Subscriptions removed for listener {} ", subscription.getSourceEntityId()); }
private void removeSubscription(final Subscription subscription) { final Topic topic = ChannelUtils.getChannel(subscription); LOGGER.debug("Removing subscription to channel {} for listener {} ", topic.getTopic(), subscription.getSourceEntityId()); final MessageListenerImpl listener = listeners.get(subscription.getSourceEntityId()); if (listener != null) { listenerContainer.removeMessageListener(listener, topic); listener.removeSubscription(topic); } // Finally, the subscription to the topic is removed from Redis jedisTemplate.hDel(keysBuilder.getSubscriptionKey(subscription.getSourceEntityId()), topic.getTopic()); LOGGER.debug("Removed subscription from listener {} to channel {}", subscription.getSourceEntityId(), topic.getTopic()); }
private void removeSubscriptionsOfOneType(final Subscription subscription) { // Por ejemplo, puede ser borrar todas las subscripciones de tipo alarm del listener. // Esto implica en Redis recuperar primero todas las subscripciones de ese tipo y despues borrar // via un hdel // En el container se trata de recuperar todas las subscripciones que existen (holders) y para // cada una, si se trata de una subscripcion del tipo indicado se pasa a eliminar el listener // de su lista de listeners. LOGGER.debug("Removing all subscriptions of type {} for listener {}", subscription.getType(), subscription.getSourceEntityId()); // Recuperamos todos los canales a los cuales esta subscrito el listener. final Set<String> topics = jedisTemplate.hKeys(keysBuilder.getSubscriptionKey(subscription.getSourceEntityId())); final List<String> topicsToRemove = ChannelUtils.filterTopicsOfType(topics, subscription.getType()); // Y para cada uno, eliminamos la subscripcion activa del listener final MessageListenerImpl listener = listeners.get(subscription.getSourceEntityId()); for (final String topicName : topicsToRemove) { if (listener != null) { final Topic topic = ChannelUtils.buildTopic(topicName); listenerContainer.removeMessageListener(listener, topic); listener.removeSubscription(topic); } } LOGGER.debug("Number of subscriptions to remove in Redis: {}", topicsToRemove.size()); if (!CollectionUtils.isEmpty(topicsToRemove)) { // Por ultimo, eliminamos en Redis de la hash de subscripciones todas aquellas que // corresponden a canales del tipo indicado: jedisTemplate.hDel(keysBuilder.getSubscriptionKey(subscription.getSourceEntityId()), topicsToRemove.toArray(new String[0])); } LOGGER.debug("Subscriptions of type {} removed for listener {} ", subscription.getType(), subscription.getSourceEntityId()); }