Grails Config.groovy file read from file

What's the best practice? I mostly use rabbitMQ and it has a setting for the number of concurrent processes that I deploy as a WAR for the test server and I want to optimize that number of consonants by just changing the value and not creating new WAR files every time.

I think I'm reading a properties file that I can just change the value and restart the server?

Ex: in my config.groovy file

rabbitmq {
    connectionfactory {
        username = 'groovy'
        password = 'groovy'
        hostname = 'localhost'

    }
    queues = {
        processTerritory exclusive: true
    }
    concurrentConsumers = **READ INTEGER VALUE FROM A FILE**
}

      

+3


source to share


1 answer


You can import external configuration files from Config.groovy. Config.groovy has already commented out the code that shows how to do this:

grails.config.locations = [ "classpath:${appName}-config.properties",
                         "classpath:${appName}-config.groovy"]

      

Let's say your application name is foo, now you can put foo-config.groovy or foo-config.properties somewhere in the classpath. For Tomcat, you can put the file in lib folder.

It is also described in the documentation

Then in foo-config.groovy you can put:



rabbitmq.concurrentConsumers = 10

      

or any other value suitable for this server.

Grails 3

Grails 3 does not include this feature by default, but you can use the external-config plugin

+2


source







All Articles