Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The context startup does not take into account the setting of auto-startup to false. #56

Closed
jindalshivali opened this issue Jan 29, 2024 · 5 comments

Comments

@jindalshivali
Copy link
Contributor

jindalshivali commented Jan 29, 2024

Steps to reproduce:

Define a listener bean:

eventListenerContainer {
            concurrentConsumers = 10
            autoStartup = false
            connectionFactoryBean = "jmsConnectionFactory"
            messageSelector = null
            cacheLevel = 0
        }

When the application server starts, the eventListenerContainer is already running (isActive=true, and isRunning=true but autoStartup=false)

This seems to be because the plugin code calls the start() method on all the listener containers during application Context start irrespective of whether or not the autoStartup field is set to true.

It looks like the code in below file
https://github.com/gpc/jms/blob/master/src/main/groovy/grails/plugin/jms/JmsGrailsPlugin.groovy
Method

doWithApplicationContext():

 void doWithApplicationContext() {
        listenerConfigs.each { serviceClassName, serviceClassListenerConfigs ->
            serviceClassListenerConfigs.each {
                startListenerContainer(it, applicationContext)
            }
        }

The code above starts all the containers irrespective of the autoStartup property.

@jindalshivali
Copy link
Contributor Author

jindalshivali commented Jan 29, 2024

Currently, when the startListenerContainer() method is invoked, below is what happens.

    def startListenerContainer(listenerConfig, applicationContext) {
        applicationContext.getBean(listenerConfig.listenerContainerBeanName).start()
    }

Instead the code should be as below:

    def startListenerContainer(listenerConfig, applicationContext) {
        def listenerContainer = applicationContext.getBean(listenerConfig.listenerContainerBeanName)

        if (listenerContainer.isAutoStartup()) {
            listenerContainer.start()
        }
    }

@codeconsole
Copy link
Contributor

@jindalshivali can you submit a pull request?

@jindalshivali
Copy link
Contributor Author

jindalshivali commented Feb 9, 2024

We have a forked version of the repo which is currently being used after the fix in our application.
Will submit a PR.

@jindalshivali
Copy link
Contributor Author

Added the PR to the issue.

@codeconsole
Copy link
Contributor

#57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants