Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Content on this page is under development, check the following email thread for the time being:

High Level Ideas

  •  use English language like

Groovy-style API Proposal 

  •  assumed to be start with a user provided JMS ConnectionFactory named "jms". In future release, this should not be required.


JMS Usage (In Groovy Syntax with Static Type for clarity)

Proposed/Current API


Create Connection

Connection conn = jms.createConnection()



Create Session

Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE)



Create Topic

Topic topic = session.createTopic("testTopic");



Subscribe to Topic

TopicSubscriber subscriber = session.createDurableSubscriber(topic, "sub-name")
MessageListener listener = {Message m -> println m.text } as MessageListener

topic.subscribe( {} as MessageListener )



  • Create
    • jms.createQueue withName: "replyQueue"
    • Queue replyQueue = jms.createQueue("replyQueue")
  • Topic subscription
    • jms.subscribeTo topic/ subscribe toTopic: "greeting", withListener/with:
      Unknown macro: { Message m -> println "hey i got a message. it says, '${m.text}'" }
    • jms.subscribe toTopic: "greeting", onMessage:
      Unknown macro: { Message msg -> println "hey i got a message. it says, '$
      Unknown macro: {m.text}
      " }
    • jms.subscribe("greeting") {
         println "hey i got a message. it says, '$
      Unknown macro: {it.text}
    • jms.subscribe("greeting") {
           println "hey i got a message. it says, '\${m.text}'"
  • Queue receive
    • jms.receiveMessage fromQueue: "greeting", withinTimeoutOf: 1000
      jms.receiveMessage/receive fromQueue: "greeting", within:
      jms.receiveAllMessages/receiveAll fromQueue: "greeting", within:
    • jms.receiveMessage fromQueue: "greeting", within:, withMessage:
      Unknown macro: { Message msg -> reply withTextMessage}
    • jms.receive ("greeting", within:
      Unknown macro: { reply "hey, let me tell you secretly" }
  • Send message
    • jms.send message: "I'm joining the JMS party", toTopic: "greeting"
    • jms.send textMessage: "hey, please reply to me privately", onQueue: "greeting", withAttributes: [JMSCorrelationID: 'privatePlease', JMSReplyTo: replyQueue]
      jms.send(to:"greeting", "I'm joining the JMS party")
    • jms.send message: "hey, please reply to me privately",
                 onQueue: "greeting",
                 JMSCorrelationID: 'privatePlease', JMSReplyTo: replyQueue
    • jms.send "hey, please reply to me privately",
                 onQueue: "greeting",
                 JMSCorrelationID: 'privatePlease', JMSReplyTo: replyQueue
  • When handling the closure, you could set a delegate to it, so that
    methods like reply() would be delegated to the jms instance.
    Also, passing the message in parameter of the closure, you can have
    access to it, to deal with it, and use some of its attributes or text
    body in your own replies.
  •   }
  • No labels