GRAILS JMS (sonicMQ)集成
网上很多示例都是以activeMQ和openMQ为主,对SonicMQ的配置不多。
下面是针对sonicMQ的配置信息,resources.groovy内容如下: *beans = {
connectionFactory(org.springframework.jndi.JndiObjectFactoryBean){
jndiTemplate = ref("jndiTemplate")
jndiName = "testConnectionFactory"
}
jndiTemplate(org.springframework.jndi.JndiTemplate){
environment =
}
}*
这里jndiName对应的connectionFactory是在sonicMQ Management Cosole配置的,名字是testConnectionFactory。
接收的程序代码如下:
*class SampleQ1Service {
static expose =
static destination = "testQueue"
def onMessage(messageObject) {
println "GOT MESSAGE: $messageObject"
}
} * 监听的Queue的名字是testQueue。 发送的代码如下: *class TestController {
def index = {
sendJMSMessage("testQueue", "Blog Entry entitled sss has been created.")
}
} *
搞定了。