Skip to content

Commit f357dfe

Browse files
committed
New RabbitMQ connector based on the RabbitMQ Java client
1 parent 2cb5bdf commit f357dfe

86 files changed

Lines changed: 11801 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

documentation/mkdocs.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ nav:
6767
- 'Client Customization' : rabbitmq/rabbitmq-client-customization.md
6868
- 'Connecting to managed instances' : rabbitmq/rabbitmq-cloud.md
6969

70+
- RabbitMQ OG:
71+
- rabbitmq-og/rabbitmq-og.md
72+
- 'Receiving messages' : rabbitmq-og/receiving-messages-from-rabbitmq.md
73+
- 'Sending messages' : rabbitmq-og/sending-messages-to-rabbitmq.md
74+
- 'Health Checks' : rabbitmq-og/rabbitmq-og-health.md
75+
- 'Client Customization' : rabbitmq-og/rabbitmq-og-client-customization.md
76+
- 'OpenTelemetry Tracing' : rabbitmq-og/rabbitmq-og-tracing.md
77+
- 'Connecting to managed instances' : rabbitmq-og/rabbitmq-og-cloud.md
78+
7079
- Pulsar:
7180
- pulsar/pulsar.md
7281
- 'Receiving messages': pulsar/receiving-pulsar-messages.md

documentation/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
<artifactId>smallrye-reactive-messaging-rabbitmq</artifactId>
7373
<version>${project.version}</version>
7474
</dependency>
75+
<dependency>
76+
<groupId>io.smallrye.reactive</groupId>
77+
<artifactId>smallrye-reactive-messaging-rabbitmq-og</artifactId>
78+
<version>${project.version}</version>
79+
</dependency>
7580
<dependency>
7681
<groupId>io.smallrye.reactive</groupId>
7782
<artifactId>smallrye-reactive-messaging-pulsar</artifactId>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Customizing the underlying RabbitMQ client
2+
3+
You can customize the underlying RabbitMQ Client configuration by
4+
*producing* an instance of
5+
[`ConnectionFactory`](https://rabbitmq.github.io/rabbitmq-java-client/api/current/com/rabbitmq/client/ConnectionFactory.html):
6+
7+
``` java
8+
{{ insert('rabbitmq/og/customization/RabbitMQProducers.java', 'named') }}
9+
```
10+
11+
This instance is retrieved and used to configure the client used by the
12+
connector. You need to indicate the name of the client using the
13+
`client-options-name` attribute:
14+
15+
mp.messaging.incoming.prices.client-options-name=my-named-options
16+
17+
## Credentials Provider
18+
19+
The OG connector supports RabbitMQ's
20+
[`CredentialsProvider`](https://rabbitmq.github.io/rabbitmq-java-client/api/current/com/rabbitmq/client/impl/CredentialsProvider.html)
21+
interface for dynamic credential management. This is useful when
22+
credentials are rotated or fetched from an external secrets manager.
23+
24+
To use a credentials provider, expose a CDI bean implementing
25+
`com.rabbitmq.client.impl.CredentialsProvider` with an `@Identifier`
26+
qualifier, and reference it via the `credentials-provider-name` attribute:
27+
28+
```properties
29+
mp.messaging.incoming.prices.credentials-provider-name=my-credentials-provider
30+
```
31+
32+
## Cluster mode
33+
34+
To connect to a RabbitMQ cluster, use the `addresses` attribute to
35+
specify multiple broker addresses. When set, this overrides the `host`
36+
and `port` attributes:
37+
38+
```properties
39+
rabbitmq-addresses=host1:5672,host2:5672,host3:5672
40+
```
41+
42+
## NIO Sockets
43+
44+
The connector supports using NIO sockets for the RabbitMQ connection.
45+
Enable NIO mode with:
46+
47+
```properties
48+
rabbitmq-use-nio=true
49+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Connecting to managed instances
2+
3+
This section describes the connector configuration to use managed
4+
RabbitMQ instances (hosted on the Cloud).
5+
6+
## Cloud AMQP
7+
8+
To connect to an instance of RabbitMQ hosted on [Cloud
9+
AMQP](https://www.cloudamqp.com/), use the following configuration:
10+
11+
``` properties
12+
rabbitmq-host=host-name
13+
rabbitmq-port=5671
14+
rabbitmq-username=user-name
15+
rabbitmq-password=password
16+
rabbitmq-virtual-host=user-name
17+
rabbitmq-ssl=true
18+
```
19+
20+
You can extract the values from the `AMQPS` url displayed on the
21+
administration portal:
22+
23+
amqps://user-name:password@host/user-name
24+
25+
## Amazon MQ
26+
27+
[Amazon MQ](https://aws.amazon.com/amazon-mq/) can host RabbitMQ brokers
28+
(as well as AMQP 1.0 brokers). To connect to a RabbitMQ instance hosted
29+
on Amazon MQ, use the following configuration:
30+
31+
``` properties
32+
rabbitmq-host=host-name
33+
rabbitmq-port=5671
34+
rabbitmq-username=user-name
35+
rabbitmq-password=password
36+
rabbitmq-ssl=true
37+
```
38+
39+
You can extract the host value from the `AMQPS` url displayed on the
40+
administration console:
41+
42+
amqps://foobarbaz.mq.us-east-2.amazonaws.com:5671
43+
44+
The username and password are configured during the broker creation.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Health reporting
2+
3+
The RabbitMQ OG connector reports the readiness and liveness of each
4+
channel managed by the connector.
5+
6+
On the inbound side (receiving messages from RabbitMQ), the check
7+
verifies that the receiver is connected to the broker.
8+
9+
On the outbound side (sending records to RabbitMQ), the check verifies
10+
that the sender is not disconnected from the broker; the sender *may*
11+
still be in an initialized state (connection not yet attempted), but
12+
this is regarded as live/ready.
13+
14+
You can disable health reporting by setting the `health-enabled` attribute of the channel to `false`.
15+
It disables both liveness and readiness.
16+
You can disable readiness reporting by setting the `health-readiness-enabled` attribute of the channel to `false`.
17+
18+
## @Channel and lazy subscription
19+
20+
When you inject a channel using `@Channel` annotation, you are responsible for subscribing to the channel.
21+
Until the subscription happens, the channel is not connected to the broker and thus cannot receive messages.
22+
The default health check will fail in this case.
23+
24+
To handle this use case, you need to configure the `health-lazy-subscription` attribute of the channel to `true`.
25+
It configures the health check to not fail if there are no subscription yet.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# OpenTelemetry Tracing
2+
3+
The RabbitMQ OG connector supports [OpenTelemetry](https://opentelemetry.io/)
4+
tracing for both incoming and outgoing channels.
5+
6+
## Enabling tracing
7+
8+
Tracing is enabled by default. You can disable it per channel with:
9+
10+
```properties
11+
mp.messaging.incoming.prices.tracing.enabled=false
12+
mp.messaging.outgoing.prices.tracing.enabled=false
13+
```
14+
15+
## How it works
16+
17+
When tracing is enabled:
18+
19+
- **Outgoing messages**: The connector creates a `PUBLISH` span and
20+
injects the trace context into the message headers before sending.
21+
22+
- **Incoming messages**: The connector extracts the trace context from
23+
the message headers and creates a `RECEIVE` span linked to the
24+
producer's trace context.
25+
26+
The span attributes include the exchange name and routing key.
27+
28+
## Including headers as span attributes
29+
30+
You can configure specific message headers to be recorded as span
31+
attributes using the `tracing.attribute-headers` property:
32+
33+
```properties
34+
mp.messaging.incoming.prices.tracing.attribute-headers=my-header,another-header
35+
```
36+
37+
This is a comma-separated list of header names whose values will be
38+
added as attributes to the tracing span.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# RabbitMQ OG Connector
2+
3+
The RabbitMQ OG Connector adds support for RabbitMQ to Reactive Messaging,
4+
based on the AMQP 0-9-1 Protocol Specification.
5+
6+
Advanced Message Queuing Protocol 0-9-1 ([AMQP
7+
0-9-1](https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf)) is an
8+
open standard for passing business messages between applications or
9+
organizations.
10+
11+
With this connector, your application can:
12+
13+
- receive messages from a RabbitMQ queue
14+
- send messages to a RabbitMQ exchange
15+
16+
The RabbitMQ OG connector is based on the [RabbitMQ Java Client](https://www.rabbitmq.com/client-libraries/java-client),
17+
the official RabbitMQ client library.
18+
19+
!!!note
20+
This connector is an alternative to the existing RabbitMQ connector
21+
(`smallrye-rabbitmq`), which is based on the Vert.x RabbitMQ client.
22+
The OG connector uses the original RabbitMQ Java client directly,
23+
providing improved reconnection handling and direct access to all
24+
RabbitMQ client features.
25+
26+
!!!important
27+
The **AMQP connector** supports the AMQP 1.0 protocol, which is very
28+
different from AMQP 0-9-1. You *can* use the AMQP connector with
29+
RabbitMQ provided that the latter has the [AMQP 1.0
30+
Plugin](https://github.com/rabbitmq/rabbitmq-amqp1.0/blob/v3.7.x/README.md)
31+
installed, albeit with reduced functionality.
32+
33+
## Using the RabbitMQ OG connector
34+
35+
To use the RabbitMQ OG Connector, add the following dependency to your
36+
project:
37+
38+
``` xml
39+
<dependency>
40+
<groupId>io.smallrye.reactive</groupId>
41+
<artifactId>smallrye-reactive-messaging-rabbitmq-og</artifactId>
42+
<version>{{ attributes['project-version'] }}</version>
43+
</dependency>
44+
```
45+
46+
The connector name is: `smallrye-rabbitmq-og`.
47+
48+
So, to indicate that a channel is managed by this connector you need:
49+
```properties
50+
# Inbound
51+
mp.messaging.incoming.[channel-name].connector=smallrye-rabbitmq-og
52+
53+
# Outbound
54+
mp.messaging.outgoing.[channel-name].connector=smallrye-rabbitmq-og
55+
```

0 commit comments

Comments
 (0)