/** * Adds a message listener to the (potentially running) container. If the container is running, the listener starts * receiving (matching) messages as soon as possible. * * @param listener message listener * @param topics message listener topic */ public void addMessageListener(MessageListener listener, Collection<? extends Topic> topics) { addListener(listener, topics); lazyListen(); }
public void start() { if (!running) { running = true; // wait for the subscription to start before returning // technically speaking we can only be notified right before the subscription starts synchronized (monitor) { lazyListen(); if (listening) { try { // wait up to 5 seconds for Subscription thread monitor.wait(initWait); } catch (InterruptedException e) { // stop waiting Thread.currentThread().interrupt(); running = false; return; } } } if (logger.isDebugEnabled()) { logger.debug("Started RedisMessageListenerContainer"); } } }
/** * Handle subscription task exception. Will attempt to restart the subscription if the Exception is a connection * failure (for example, Redis was restarted). * * @param ex Throwable exception */ protected void handleSubscriptionException(Throwable ex) { listening = false; subscriptionTask.closeConnection(); if (ex instanceof RedisConnectionFailureException) { if (isRunning()) { logger.error("Connection failure occurred. Restarting subscription task after " + recoveryInterval + " ms"); sleepBeforeRecoveryAttempt(); lazyListen(); } } else { logger.error("SubscriptionTask aborted with exception:", ex); } }
/** * Adds a message listener to the (potentially running) container. If the container is running, the listener starts * receiving (matching) messages as soon as possible. * * @param listener message listener * @param topics message listener topic */ public void addMessageListener(MessageListener listener, Collection<? extends Topic> topics) { addListener(listener, topics); lazyListen(); }
/** * Adds a message listener to the (potentially running) container. If the container is running, the listener starts * receiving (matching) messages as soon as possible. * * @param listener message listener * @param topics message listener topic */ public void addMessageListener(MessageListener listener, Collection<? extends Topic> topics) { addListener(listener, topics); lazyListen(); }
public void start() { if (!running) { running = true; // wait for the subscription to start before returning // technically speaking we can only be notified right before the subscription starts synchronized (monitor) { lazyListen(); if (listening) { try { // wait up to 5 seconds for Subscription thread monitor.wait(initWait); } catch (InterruptedException e) { // stop waiting Thread.currentThread().interrupt(); running = false; return; } } } if (logger.isDebugEnabled()) { logger.debug("Started RedisMessageListenerContainer"); } } }
public void start() { if (!running) { running = true; // wait for the subscription to start before returning // technically speaking we can only be notified right before the subscription starts synchronized (monitor) { lazyListen(); if (listening) { try { // wait up to 5 seconds for Subscription thread monitor.wait(initWait); } catch (InterruptedException e) { // stop waiting Thread.currentThread().interrupt(); running = false; return; } } } if (logger.isDebugEnabled()) { logger.debug("Started RedisMessageListenerContainer"); } } }
/** * Handle subscription task exception. Will attempt to restart the subscription if the Exception is a connection * failure (for example, Redis was restarted). * * @param ex Throwable exception */ protected void handleSubscriptionException(Throwable ex) { listening = false; subscriptionTask.closeConnection(); if (ex instanceof RedisConnectionFailureException) { if (isRunning()) { logger.error("Connection failure occurred. Restarting subscription task after " + recoveryInterval + " ms"); sleepBeforeRecoveryAttempt(); lazyListen(); } } else { logger.error("SubscriptionTask aborted with exception:", ex); } }
/** * Handle subscription task exception. Will attempt to restart the subscription if the Exception is a connection * failure (for example, Redis was restarted). * * @param ex Throwable exception */ protected void handleSubscriptionException(Throwable ex) { listening = false; subscriptionTask.closeConnection(); if (ex instanceof RedisConnectionFailureException) { if (isRunning()) { logger.error("Connection failure occurred. Restarting subscription task after " + recoveryInterval + " ms"); sleepBeforeRecoveryAttempt(); lazyListen(); } } else { logger.error("SubscriptionTask aborted with exception:", ex); } }