englishteeth.co.uk

… the weblog of Ian “English Teeth” Robinson
  • rss
  • Home

Grails & JMS Revisited: Topic instead of Queue

Ian | June 26, 2008

Following a question onto my post Grails Service, JMS and an MDB, I was amused and pleased to find that the grails site for the JMS Plugin had been updated and included much of my post. Right down to the xfire reference, setting up Apache ActiveMQ and my service name typo… Sample was meant to be Simple. Unfortunately no citation, though there was quite a bit of other information added too.

Thomas’ question got me to thinking about publish subscribe as opposed to point to point and how that might be set up using Grails.

No changes were needed to the Apache ActiveMQ set up or the spring configuration in the grails app. I simply added another service to the mix.

class SampleTopicService {
    static expose = ['jms']
    static pubSub = true
    static destination = 'test/topic'

    def onMessage(messageObject) {
       println "GOT PUBLISHED MESSAGE: $messageObject"
    }

}

The destination bit was a little allusive at first. Without it or trying the static “topic” results in the default configuration whereby the service name “sampleTopic” is used for the destination (topic or queue).

To execute this from the grails console needed one extra line to tell the JMS template to use a topic rather than a queue:

def connectionFactory = ctx.getBean("connectionFactory")
def template = new org.springframework.jms.core.JmsTemplate(connectionFactory)
template.setPubSubDomain(true)
template.convertAndSend("test/topic", "Message Posted!")

et voilà
GOT PUBLISHED MESSAGE: Message Posted!

Set the pub sub domain to false and no message is received for SampleTopicService though the previous SampleQueueService works on its destination and visa versa.

Not really the answer to the question Thomas posted here, but it may help with the aspect he mentioned here.

Categories
development
Tags
active-mq, grails, jms
Comments rss
Comments rss
Trackback
Trackback

« This week I have mostly been reading… Scoped Model Driven Interceptor »

One response

[...] - bookmarked by 3 members originally found by thatbrad

Bookmarks about Pubsub | August 1, 2008

[...] - bookmarked by 3 members originally found by thatbrad on July 18, 2008 Grails & JMS Revisited: Topic instead of Queue http://www.englishteeth.co.uk/2008/06/26/grails-jms-revisited/ - bookmarked by 1 members [...]

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Author

Ian Robinson is a relatively agile software engineer interested in things both sides of the object relational divide and beyond.

Categories

  • development (37)
  • miscellaneous (28)
  • music (7)
  • software (19)

What I'm Doing...

  • @noelfielding11 why are you in watching telly!? in reply to noelfielding11 2010-04-16
  • What was so good about Nick Drake? These "artists" are covering, music is spot on but no effect at all. Totally lacking the goose pimples. 2010-04-16
  • Some Ginger bloke's on telly covering Nick Drake in a mediocre style. 2010-04-16
  • More updates...

Posting tweet...

Powered by Twitter Tools.

Blogroll

  • Dan North
  • Dave Astels
  • Dave Wood
  • eirikso.com
  • Matt Raible
  • Object Mentor Blog
  • The Ancient Art of Programming
  • The Wisdom of Ganesh

Tags

active-mq architecture bauhaus css db eclipse esb festivals freesat gorm grails groovy hd hibernate htpc java jboss jms junit links mce media center mini music oracle osgi patterns pirsig plugins satellite soa software spring sql struts2 testing themes tools tv vmc web wordpress xml xpath xslt
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox