Open Source API Gateway
2. Enterprise Integration Patterns

jmsProducer

Version

Sends the body of the request or the response as a message to a JMS queue or topic.

In the flow of an API, the interceptor sends a message for the request and another one for the response. Put it into request or response to send only one of them.

Header fields and properties of the message can be set with expressions, e.g. from the request or from the message a jmsConsumer received (${property.jms.correlationId}). After sending, the exchange property jmsSent describes the sent message, e.g. ${property.jmsSent.messageId}. When the interceptor sends in the request and the response flow, it holds the message sent last.

Any broker with a Jakarta Messaging (JMS 3) client can be used.

The interceptor needs the Membrane JMS Extension. Without the extension Membrane does not start. Contact predic8 for the extension.

Example Configuration

api:
port: 2000
flow:
- request:
- jmsProducer:
jmsConnection:
connectionFactory: org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
brokerURL: tcp://mq.example.com:61616
queue: orders
correlationId: ${header['X-Request-Id']}
priority: 6
properties:
orderId: ${json.id}
- template:
contentType: application/json
src: '{"messageId": "${property.jmsSent.messageId}"}'
- return:
status: 202
api:
   port: 2000
   flow:
     - request:
         - jmsProducer:
             jmsConnection:
               connectionFactory: org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
               brokerURL: tcp://mq.example.com:61616
             queue: orders
             correlationId: ${header['X-Request-Id']}
             priority: 6
             properties:
               orderId: ${json.id}
     - template:
         contentType: application/json
         src: '{"messageId": "${property.jmsSent.messageId}"}'
     - return:
         status: 202

Syntax

jmsProducer:
'$ref': <string>
correlationId: <string>
deliveryDelay: <int>
deliveryMode: persistent
jmsConnection:
<jmsConnection>: <string>
language: groovy
priority: <int>
properties:
<property>: <string>
queue: <string>
replyTo: <string>
sendTimeout: <int>
timeToLive: <int>
topic: <string>
type: <string>
xmlConfig: {}
jmsProducer:
  '$ref': <string>
  correlationId: <string>
  deliveryDelay: <int>
  deliveryMode: persistent
  jmsConnection:
    <jmsConnection>: <string>
  language: groovy
  priority: <int>
  properties:
    <property>: <string>
  queue: <string>
  replyTo: <string>
  sendTimeout: <int>
  timeToLive: <int>
  topic: <string>
  type: <string>
  xmlConfig: {}

Attributes

NameRequiredDefaultDescriptionExamples
$reffalse-Reference a component defined under components.-
correlationIdfalse-Correlation id of the messages (JMSCorrelationID), e.g. to relate a reply to its request. Can contain expressions.${header['X-Request-Id']}
deliveryDelayfalse0Time in milliseconds the broker waits before it delivers a message to consumers.5000
deliveryModefalsepersistentWhether the broker stores the messages so that they survive a restart of the broker.persistent | non_persistent
languagefalseSpELScripting language used to evaluate the value expression.SpEL | groovy | jsonpath | xpath
priorityfalse4Priority of the messages, from 0 (lowest) to 9 (highest). Brokers may deliver messages with a higher priority first.6
queuefalse-Queue the messages are sent to. Set either queue or topic.orders
replyTofalse-Queue a receiver should send its reply to (JMSReplyTo). For a topic, prefix the name with topic:. Can contain expressions. Membrane does not wait for the reply.replies | topic:order-replies
sendTimeoutfalse10000Time in milliseconds the broker may take to accept a message. If it takes longer, e.g. because the broker blocks producers when its disk is full, the request is answered with 500. 0 waits without limit.30000
timeToLivefalse0Time in milliseconds after which the broker discards a message that was not consumed. 0 keeps the message until it is consumed.60000
topicfalse-Topic the messages are published to. Set either queue or topic.order-events
typefalse-Type of the messages (JMSType). Can contain expressions.order-created

Child Structure

ElementCardinalityDescription
jmsConnection0..1Connection to a JMS broker. Works with every broker that has a Jakarta Messaging (JMS 3) client, e.g. ActiveMQ Artemis, ActiveMQ Classic 6, IBM MQ or AMQP brokers through Qpid JMS. The client library of the broker has to be put into the lib folder of Membrane.
properties0..1JMS properties of the messages.
xmlConfig0..1XML namespace declarations for XPath expressions in the value.

Can be used in