0

I have recently run into a problem with trying to make the topic of my JMS @Subscriber a variable based upon environment. Currently, I have in my config.groovy:

environments {
    development {
        jms.foo.msg = "my.jms.topic.dev.1_0"
    }
    test {
        jms.foo.msg = "my.jms.topic.tst.1_0"
    }
    production {
        jms.foo.msg = "my.jms.topic.prd.1_0"
    }
}

And in my service, where I have my @Subscriber, I have this:

@Subscriber(
            topic = grailsApplication.config.jms.foo.msg,
            container = 'matter',
            adapter = 'durable'
)

The error that I am getting is: "Expected 'grailsApplication.config.jms.foo.msg' to be an inline constant."

I have tried many variations of getting the config value here. All I am looking for is how to subscribe to the proper topic while on a specific environment. Any ideas are appreciated.

DONKEYSAURUS
  • 141
  • 1
  • 3

1 Answers1

0

Try to use Holders (since Grails v2.0):

import grails.util.Holders

And then use:

@Subscriber( topic = Holders.getConfig().jms.foo.msg, container = 'matter', adapter = 'durable' )

dmonti
  • 448
  • 4
  • 13
  • I had tried this and was getting the same issue. What I have ended up doing for the mean time is this: static exposes = ["jms"] static destination = Holders.config.jms.destinations.foo.msg static isTopic = true static container = 'matter' static adapter = 'durable' def onMessage(msg) {...some code} This allowed for the use of config values, where as the annotation does not seem to. – DONKEYSAURUS Aug 05 '15 at 21:45