Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<table class="wysiwyg-macro" data-macro-name="unmigrated-wiki-markup" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3VubWlncmF0ZWQtd2lraS1tYXJrdXB9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>Content on this page is under development, check the following email thread for the time being: [http://www.nabble.com/Groovy-JMS-Category-td19861454.html]\\ h1. Design Requirement * API must be in Groovy-style ** use typical Groovy syntax like with, each etc. ** sounds like English language * Follow JMS concept and keywords, but need to to use exact name and API * Simple and Easy to use * Thread-safety * JMS resource re-use and direct JMS usage ** Allow provision of ConnectionFactory, Connection or Session for reuse. ** Return sensible JMS resource for reuse or keeping reference h1. AS-IS, v0.1 release * &nbsp;assumed to be start with a user provided JMS ConnectionFactory named "jms". In future release, this should not be required. || Type \\ || JMS Usage (In Groovy Syntax with Static Type for clarity) \\ || Proposed/Current API \\ || Reference || | Create Connection \\ | Connection conn = jms.createConnection() \\ \\ | jms.connect() | v0.1 | | Create Session \\ | Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE) \\ \\ | jms.session() \\ conn.session() \\ | v0.1 \\ | | Create Topic \\ | Topic topic = session.createTopic("testTopic"); \\ \\ | jms.topic("testTopic") \\ conn.topic("testTopic") \\ session.topic("testTopic") \\ \\ | v0.1 | | Subscribe to Topic \\ | TopicSubscriber subscriber = session.createDurableSubscriber(topic, "sub-name") \\ MessageListener listener = \{Message m \-> println m.text \} as MessageListener \\ subscriber.setMessageListener(listener)&nbsp; \\ | topic.subscribe( {} as MessageListener ) \\ \\ | v0.1 | | \\ | \\ | \\ | \\ | h1. Groovy SQL-style API Content in this section is moved to [GroovyJMS Docs|GROOVY:GroovyJMS Docs]\\ h1. Proposed * Create ** jms.createQueue withName: "replyQueue" ** Queue replyQueue = jms.createQueue("replyQueue") * Topic subscription ** jms.subscribeTo topic/ subscribe toTopic: "greeting", withListener/with:\{ Message m \-> println "hey i got a message. it says, '\$\{m.text\}'" \} ** jms.subscribe toTopic: "greeting", onMessage:\{ Message msg \-> println "hey i got a message. it says, \$ {m.text} " \} ** jms.subscribe("greeting")\{println "hey i got a message. it says, \$ {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: 1000.ms jms.receiveAllMessages/receiveAll fromQueue: "greeting", within: 1000.ms ** jms.receiveMessage fromQueue: "greeting", within: 1000.ms, withMessage: { Message msg \-> reply withTextMessage: "hey, let me tell you secretly" } ** jms.receive ("greeting", within: 1000.ms) { reply "hey, let me tell you secretly" } ** &nbsp; * Send message * jms.send textMessage: "hey, please reply to me privately", onQueue: "greeting", withAttributes: \[JMSCorrelationID: 'privatePlease', JMSReplyTo: replyQueue\] * jms.send message: "hey, please reply to me privately", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;onQueue: "greeting", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;JMSCorrelationID: 'privatePlease', JMSReplyTo: replyQueue * jms.send "hey, please reply to me privately", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;onQueue: "greeting", &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;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. \\ Latest: * JMS Connection Factory * use a combination of Category and Builder to do the job. * Use builder/closure rather than Category \| use xxxx and xxxTo in two styles {code:groovy} new JMS(jms \| conn \| session \| no-arg){ &nbsp;&nbsp; { m \-> println "received message"}.listenTo "loginService" / "loginService".listenWith{}&nbsp;&nbsp; "loginService".getMessages.within "10ms".each{ } / "loginService".messages.each{} &nbsp; "what handshake protocol do you support".sendTo "loginService" \| "loginService".send "how to handshake?" &nbsp; \["\] &nbsp; jms.each{ } def messages = get messages from login queue within 100ms send messages to greeting topic&nbsp; \-> send(\["user":"mmm", "password":"fff"\]).to("loginQueue") \| \["user":"mmm"\].sendTo("loginQueue") receive messages from login queue \-> receive("loginquee"){ m} ; receiveAll("loginqueue").each{}&nbsp;&nbsp; (from is skipped) wait for messages from * keywords: to and from subject/object: either message content or destination action: get, send, waitFor } {code}</pre></td></tr></table>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced