`
seanwon
  • 浏览: 63704 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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 =
            ['java.naming.factory.initial':'com.sonicsw.jndi.mfcontext.MFContextFactory',
            'com.sonicsw.jndi.mfcontext.domain' : 'Domain1',
            'com.sonicsw.jndi.mfcontext.idleTimeout' : '60000',
            'java.naming.security.principal' : 'Administrator',
            'java.naming.security.credentials' : 'Administrator',
            'java.naming.provider.url' : 'tcp://localhost:2506']
       
    }
}


这里jndiName对应的connectionFactory是在sonicMQ Management Cosole配置的,名字是testConnectionFactory。

接收的程序代码如下:

class SampleQ1Service {

    static expose = ['jms']
    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.")

    }
}


搞定了。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics