Consumes messages from a JMS queue or topic. Every message runs through the flow of this API and is sent to its target, like a request that came in over HTTP. The target can be an HTTP backend or another API using internal://.
A message is acknowledged when the target answers with a status below 400. Otherwise, e.g. after a server error or an unreachable target, the message is not acknowledged and the broker delivers it again according to its redelivery policy, and finally moves it to its dead-letter queue. A message can be delivered more than once, so the target should handle duplicates, e.g. by the message id passed in a header.
A redirect (3xx) counts as delivered and the message is acknowledged, but Membrane does not follow it, so the message does not reach the new location. Use the final URL of the backend as the target.
The request carries the message body and its Content-Type. The header fields and properties of the message are not passed to the target. The flow reads them from the exchange property jms, e.g. ${property.jms.messageId}, ${property.jms.correlationId}, ${property.jms.deliveryCount} or ${property.jms.properties.orderId}, and can pass them on as headers.
Any broker with a Jakarta Messaging (JMS 3) client can be used.
The API does not support retryInit, which is off by default.
The API needs the Membrane JMS Extension. Without the extension Membrane does not start. Contact predic8 for the extension.
Example Configuration
jmsConsumer:
name: orders-in
jmsConnection:
connectionFactory: org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
brokerURL: tcp://localhost:61616
queue: orders
flow:
- setHeader:
name: Idempotency-Key
value: ${property.jms.messageId}
target:
url: https://orders.example.com/orders
jmsConsumer:
name: orders-in
jmsConnection:
connectionFactory: org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
brokerURL: tcp://localhost:61616
queue: orders
flow:
- setHeader:
name: Idempotency-Key
value: ${property.jms.messageId}
target:
url: https://orders.example.com/orders
Syntax
jmsConsumer:
'$ref': <string>
concurrency: <int>
flow:
- <flow>
host: <string>
info: {}
ip: <string>
jmsConnection:
<jmsConnection>: <string>
name: <string>
path: {}
port: <int>
queue: <string>
ssl: {}
subscription: <string>
tags:
- <string>
target: {}
topic: <string>
jmsConsumer:
'$ref': <string>
concurrency: <int>
flow:
- <flow>
host: <string>
info: {}
ip: <string>
jmsConnection:
<jmsConnection>: <string>
name: <string>
path: {}
port: <int>
queue: <string>
ssl: {}
subscription: <string>
tags:
- <string>
target: {}
topic: <string>
Attributes
| Name | Required | Default | Description | Examples |
|---|---|---|---|---|
| $ref | false | - | Reference a component defined under components. | - |
| concurrency | false | 1 | Number of messages that are processed in parallel. With 1 the messages are processed one after the other. Above 1, a topic needs a subscription. | 4 |
| host | false | not set | Restricts to requests whose Host header matches one of the given hostnames. Separate multiple hostnames with spaces. The asterisk * matches any number of characters, including zero, for basic globbing. | predic8.de *.predic8.de |
| ip | false | not set | If present, binds the port only on the specified IP. Useful for hosts with multiple IP addresses. | 127.0.0.1 |
| name | false | By default, a name will be automatically generated from the target, openapi, etc. | The name of the proxy or API. | - |
| port | false | 80 | The port Membrane listens on for incoming connections. | 8080 |
| queue | false | - | Queue the messages are read from. Set either queue or topic. | orders |
| subscription | false | - | Name of a durable shared subscription on the topic. Membrane instances with the same subscription share the messages of the topic, and messages published while Membrane is down are kept by the broker. Without a subscription every instance receives every message, but only while it is running. Only for a topic. | membrane |
| tags | false | - | - | - |
| topic | false | - | Topic the messages are read from. Set either queue or topic. | order-events |
Child Structure
| Element | Cardinality | Description |
|---|---|---|
| flow | 0..* | |
| info | 0..1 | Metadata about the API that API catalogs publish, such as whom to contact. It takes precedence over the same metadata in an OpenAPI document of the API. |
| jmsConnection | 0..1 | Connection 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. |
| path | 0..1 | Restricts to requests whose path matches, either by prefix (starts-with) or, when enabled, by regular expression. In a soapProxy, setting a path also rewrites the paths of SOAP requests and the service addresses in the WSDL accordingly. |
| ssl | 0..1 | Configures a TLS context: the identity (key and certificate) presented to the peer, the certificates trusted from it, and handshake parameters such as protocol, ciphers, and client-certificate policy. Attach it to a serviceProxy/api to terminate inbound TLS, or to a target to make an outbound connection over TLS; most attributes and child elements apply to both directions, but a few - such as clientAuth and useAsDefault - only take effect on an inbound context. See tutorials/ssl-tls/10-TLS-Termination.yaml for inbound termination and tutorials/ssl-tls/20-Central-SSL-Config.yaml for sharing one ssl across several APIs via $ref. |
| target | 0..1 | The backend server that requests are forwarded to after passing through the flow. |
Can be used in
No parent elements.