Rabbitmq setup in grails

855 Views Asked by At

I am running into a configuration problem with Rabbitmq and grails. I was wondering if anyone else had encountered this particular situation.

My rabbitmq configuration in config.groovy looks like this:

environments {
    production {
        rabbitmq {
            connectionfactory {
                username = '******'
                password = '******'
                hostname = 'ip-******.ec2.internal'

                channelCacheSize = 25
                prefetchCount = 10
                concurrentConsumers = 3
            }
            retryPolicy {
                maxAttempts = 10
            }
            queues = {
                exchange name: 'plover', type: topic, durable: true, {
                    error durable: true, binding: 'error.#'
                    user durable: true, binding: 'user.#'
                    track durable: true, binding: 'track.#'
                    klout durable: true, binding: 'klout.#'
                    showuser durable: false, binding: 'showuser.#'
                    network durable: true, binding: 'network.#'
                    customer durable: true, binding: 'cusotmer.#'
                    recommend durable: true, binding: 'recommend.#'
                    pusher durable: true, binding:'pusher.#'
                    backfill durable: true, binding: 'backfill.#'
                    mail durable: true, binding: 'mail.#'
                    checkaction durable: true, binding: 'checkaction.#'
                    timertasks durable: true, binding: 'timertasks.#'
                    mission durable: true, binding: 'mission.#'
                    sentiment durable: true, binding: 'sentiment.#'
                    updateuser durable: false, binding: 'updateuser.#'
                    googlereader durable: true, binding: 'googlereader.#'
                    flickr durable: true, binding: 'flickr.#'
                }

                exchange name:'pubsub', type: fanout, durable: true
            }
        }
    }

    development {
        rabbitmq {
            connectionfactory {
                username = 'guest'
                password = 'guest'
                hostname = 'localhost'
                channelCacheSize = 25
                prefetchCount = 10
                concurrentConsumers = 3
            }

            retryPolicy {
                maxAttempts = 10
            }

            queues = {
                exchange name: 'plover', type: topic, durable: true, {
                    error durable: true, binding: 'error.#'
                    user durable: true, binding: 'user.#'
                    track durable: true, binding: 'track.#'
                    klout durable: true, binding: 'klout.#'
                    showuser durable: false, binding: 'showuser.#'
                    network durable: true, binding: 'network.#'
                    customer durable: true, binding: 'cusotmer.#'
                    recommend durable: true, binding: 'recommend.#'
                    pusher durable: true, binding:'pusher.#'
                    backfill durable: true, binding: 'backfill.#'
                    mail durable: true, binding: 'mail.#'
                    checkaction durable: true, binding: 'checkaction.#'
                    timertasks durable: true, binding: 'timertasks.#'
                    mission durable: true, binding: 'mission.#'
                    sentiment durable: true, binding: 'sentiment.#'
                    updateuser durable: false, binding: 'updateuser.#'
                    googlereader durable: true, binding: 'googlereader.#'
                    flickr durable: true, binding: 'flickr.#'
                }

                exchange name:'pubsub', type: fanout, durable: true
            }
        }

    }
}

So all Rabbitmq configuration settings are done in the production/development environment as intended.

However, when I try to run on either production or local development, I get the following error:

2013-04-18 13:23:10,583 [pool-7-thread-1] ERROR RabbitmqGrailsPlugin - RabbitMQ connection factory settings (rabbitmq.connectionfactory.username, rabbitmq.connectionfactory.password and rabbitmq.connectionfactory.hostname) must be defined in Config.groovy

And I cannot see how my config setup is broken. Does the grails environments configuration not work as documented?

Mike

1

There are 1 best solutions below

0
On BEST ANSWER

Turns out that the version of Groovy we are using has a bug in ConfigSlurper that prevents multiple Environments blocks. So if you believe that you may have multiple Environments { Production {} Development {} Test {} } expressions in your config.groovy then you will see rather odd behavior.

There is a Jira on this bug. I believe it will be fixed in Groovy 2.1 or if you wish to apply a patch provided here. I don't trust patches much so I rolled all the different Environments into one large expression (looks rather ugly) and it fixed the problem.

https://jira.codehaus.org/browse/GROOVY-5370