How to disable Spring @JmsListener programmatically on startup

sudr

I have a Spring application that has methods annotated with Spring's @JmsListener. The application is deployed on multiple nodes. On some specific nodes I need to disable the JMS listener so that it is not pulling messages off the queue.

There appears to be a way to stop the listener after the application has started up. But this appears to leave open the brief window between startup and when the disable code runs where the application instance may consume messages. So instead is there a way to disable the listener during application startup.

Gary Russell

You need to customize the listener container definitions created by the annotation.

Add a listener container factory @Bean (see the documentation) and set the autoStartup property to false.

setAutoStartup(false);

You can then start each container as needed by getting a reference via the JmsListenerEndpointRegistry bean. The containers are not beans themselves - from its javadoc...

...
* <p>Contrary to {@link MessageListenerContainer}s created manually, listener
* containers managed by registry are not beans in the application context and
* are not candidates for autowiring. Use {@link #getListenerContainers()} if
* you need to access this registry's listener containers for management purposes.
* If you need to access to a specific message listener container, use
* {@link #getListenerContainer(String)} with the id of the endpoint.
...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Spring JMSListener - How should it handle empty payloads?

From Dev

Spring JMSListener - How should it handle empty payloads?

From Dev

How do I disable Spring Dashboard on startup on GGTS?

From Dev

How to disable SparkUI programmatically?

From Dev

How to disable a constraint programmatically?

From Dev

How to add different destination dynamically to JMSListener Annotation in Spring boot?

From Dev

Spring 4.1 @JmsListener configuration

From Dev

Spring JMSListener and JAXB marshalling

From Dev

GitLab: How to disable automatic startup?

From Dev

How to disable fast startup permanently

From Dev

how to disable the output in powershell startup

From Dev

How to programmatically disable/enable a UIBarButtonItem

From Dev

How to disable javascript in chrome programmatically

From Dev

spring jmsListener to listen to multiple Queues

From Dev

How to disable JRebel "splash" screen / banner at startup

From Dev

How to disable master password window on netbeans startup?

From Dev

How to disable JRebel "splash" screen / banner at startup

From Dev

How disable run at startup feature in android studio?

From Dev

How to disable the startup "Web Authentication for Google" application?

From Dev

How to disable Plank application on Ubuntu startup

From Dev

How can I disable postfix on startup?

From Dev

How to disable a spring logger?

From Dev

How to enable and disable vibration mode programmatically

From Dev

How to disable screen lock password programmatically.

From Dev

Nativescript: how to programmatically disable / enable ScrollView scrolling?

From Dev

How to disable sleep mode of Apple watch programmatically

From Dev

How do I programmatically disable "Connectivity Checking"?

From Dev

How to enable or disable incognito keyboard programmatically in android?

From Dev

How do I programmatically disable "Connectivity Checking"?

Related Related

  1. 1

    Spring JMSListener - How should it handle empty payloads?

  2. 2

    Spring JMSListener - How should it handle empty payloads?

  3. 3

    How do I disable Spring Dashboard on startup on GGTS?

  4. 4

    How to disable SparkUI programmatically?

  5. 5

    How to disable a constraint programmatically?

  6. 6

    How to add different destination dynamically to JMSListener Annotation in Spring boot?

  7. 7

    Spring 4.1 @JmsListener configuration

  8. 8

    Spring JMSListener and JAXB marshalling

  9. 9

    GitLab: How to disable automatic startup?

  10. 10

    How to disable fast startup permanently

  11. 11

    how to disable the output in powershell startup

  12. 12

    How to programmatically disable/enable a UIBarButtonItem

  13. 13

    How to disable javascript in chrome programmatically

  14. 14

    spring jmsListener to listen to multiple Queues

  15. 15

    How to disable JRebel "splash" screen / banner at startup

  16. 16

    How to disable master password window on netbeans startup?

  17. 17

    How to disable JRebel "splash" screen / banner at startup

  18. 18

    How disable run at startup feature in android studio?

  19. 19

    How to disable the startup "Web Authentication for Google" application?

  20. 20

    How to disable Plank application on Ubuntu startup

  21. 21

    How can I disable postfix on startup?

  22. 22

    How to disable a spring logger?

  23. 23

    How to enable and disable vibration mode programmatically

  24. 24

    How to disable screen lock password programmatically.

  25. 25

    Nativescript: how to programmatically disable / enable ScrollView scrolling?

  26. 26

    How to disable sleep mode of Apple watch programmatically

  27. 27

    How do I programmatically disable "Connectivity Checking"?

  28. 28

    How to enable or disable incognito keyboard programmatically in android?

  29. 29

    How do I programmatically disable "Connectivity Checking"?

HotTag

Archive