Skip to content

Messaging

dizzzz edited this page Nov 11, 2014 · 38 revisions

please note: for the functions on this page the user must be 'dba' or he must be in the 'jms' group

Send message

A JMS message can be sent as easy as calling the jms:send() function with three parameters:

messaging:send( $content as item(), $jmsMessageProperties as map(*)?, 
          $jmsConfiguration as map(*) )
  • $content is the actual data that must be sent. This can be an XML fragment or a XSD type
  • $jmsMessageProperties are additional key-value pairs which can be used as meta-data
  • $jmsConfiguration are the JMS configuration parameters.

Check the complete [example](Example send message) for inspiration.

Receive message

Receiving messages is a bit more complex to do. First a higher-order-function (HoF) with 4 parameters need. to be defined:

handleMessage(
            $content as item(), $additionalParameters as item()*,  
            $messageProperties as map(*), $jmsConfiguration as map(*)
        )
  • $content is the actual data that will be received. This can be an XML fragment or a XSD type
  • $additionalParameters are extra values set when the HoG is registered
  • $messageProperties are additional key-value pairs which (meta-data)
  • $jmsConfiguration is a report of the used JMS configuration parameters

In the second step the HoF need to be registered. This will initialise and start a data receiver process (JMS listener). When a message is delivered the HoF function is called.

messaging:register(
            $callback as function(*), $additionalParameters as item()*, 
            $jmsConfiguration as map(*)
        )
  • $callback is the HoF callback function
  • $additionalParameters are additional values to be used by the HoF
  • $jmsConfiguration are the JMS configuration parameters.

The complete [example](Example receive messages) shows how to register a HoF callback function.

Managing receivers

Finally a number of functions are available to manage the receivers:

(:
  Retrieve list of receiver ids.
:)
jms:list() as xs:integer*
(:
  Get report for specified receiver.
:)
jms:report($id as xs:integer) as node()

A simple [example](Example receiver report) to show information about the receivers.

(:
  Start specified receiver (when stopped)
:)
jms:start($id as xs:integer)
(:
  Stop specified receiver (when possible)
:)
jms:stop($id as xs:integer)
(:
  Stop and close specified receiver. Receiver cannot be started again.
:)
jms:close($id as xs:integer)
Clone this wiki locally