0

我遇到了 Rabbitmq 和 grails 的配置问题。我想知道是否有其他人遇到过这种特殊情况。

我在 config.groovy 中的 rabbitmq 配置如下所示:

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
            }
        }

    }
}

因此,所有 Rabbitmq 配置设置都按预期在生产/开发环境中完成。

但是,当我尝试在生产或本地开发上运行时,我收到以下错误:

2013-04-18 13:23:10,583 [pool-7-thread-1] 错误 RabbitmqGrailsPlugin - RabbitMQ 连接工厂设置(rabbitmq.connectionfactory.username、rabbitmq.connectionfactory.password 和 rabbitmq.connectionfactory.hostname)必须在 Config 中定义.groovy

而且我看不到我的配置设置是如何损坏的。grails 环境配置是否按文档说明工作?

麦克风

4

1 回答 1

1

事实证明,我们使用的 Groovy 版本在 ConfigSlurper 中有一个错误,该错误会阻止多个 Environments 块。因此,如果您认为您的 config.groovy 中可能有多个 Environments { Production {} Development {} Test {} } 表达式,那么您会看到相当奇怪的行为。

这个错误有一个 Jira。我相信它将在 Groovy 2.1 中修复,或者如果您希望应用此处提供的补丁。我不太信任补丁,所以我将所有不同的环境组合成一个大表达式(看起来相当难看),它解决了问题。

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

于 2013-04-19T20:01:44.437 回答