Skip to content

Commit 0aa89c4

Browse files
committed
docs: add RabbitMQ documentation
1 parent 9cb517b commit 0aa89c4

File tree

8 files changed

+466
-92
lines changed

8 files changed

+466
-92
lines changed

docs/docs/migration-guides.md

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
# Migration
6+
7+
## From 5.x.x to 6.x.x
8+
9+
### Change notes
10+
11+
- The configuration property `listenReplies` for RabbitMQ now defaults to `null`. Previously, it was `true`, causing all
12+
applications to subscribe to a reply queue even when not needed.
13+
- The domain `app` is now **required**. If not defined, the application will fail to start.
14+
15+
### Actions
16+
17+
- If your application uses the ReqReply pattern, you must explicitly set `app.async.app.listenReplies` to `true`.
18+
Otherwise, it should be `false` to avoid unnecessary resource usage:
19+
20+
```yaml title="application.yaml"
21+
app:
22+
async:
23+
app:
24+
listenReplies: true # set to true if ReqReply is required, false if not
25+
```
26+
27+
```java title="Programmatic configuration"
28+
29+
@Configuration
30+
public class MyDomainConfig {
31+
32+
@Bean
33+
@Primary
34+
public AsyncRabbitPropsDomainProperties customDomainProperties() {
35+
RabbitProperties propertiesApp = new RabbitProperties();
36+
// Additional connection configuration goes here...
37+
return AsyncRabbitPropsDomainProperties.builder()
38+
.withDomain("app", AsyncProps.builder()
39+
.connectionProperties(propertiesApp)
40+
.listenReplies(Boolean.TRUE) // set to true if ReqReply is required, false if not
41+
.build())
42+
.build();
43+
}
44+
}
45+
```
46+
47+
---
48+
49+
- The domain `app` must be defined in your configuration. Otherwise, the application will throw an exception at startup:
50+
51+
```yaml title="application.yaml"
52+
app:
53+
async:
54+
app: # Configure the 'app' domain
55+
# domain configuration goes here
56+
```
57+
58+
```java title="Programmatic configuration"
59+
60+
@Configuration
61+
public class MyDomainConfig {
62+
63+
@Bean
64+
@Primary
65+
public AsyncRabbitPropsDomainProperties customDomainProperties() {
66+
RabbitProperties propertiesApp = new RabbitProperties();
67+
// Additional connection configuration goes here...
68+
return AsyncRabbitPropsDomainProperties.builder()
69+
.withDomain("app", AsyncProps.builder() // Configure the 'app' domain
70+
.connectionProperties(propertiesApp)
71+
.build())
72+
.build();
73+
}
74+
}
75+
```
76+
77+
## From 4.x.x to 5.x.x
78+
79+
### New Features
80+
81+
- Support for multiple brokers: It is now possible to configure and connect to up to two brokers simultaneously, using
82+
independent domains in the configuration.
83+
84+
### Change notes
85+
86+
- Configuration properties are now defined per domain, allowing each to have its own properties and connection
87+
settings.
88+
- The broker connection is no longer manually defined in the code. It is now automatically managed based on the
89+
configuration declared in the `application.yaml` file or through programmatic configuration.
90+
91+
### Actions
92+
93+
- The `app` domain needs to be defined to specify the configuration properties.
94+
95+
Before:
96+
97+
```yaml title="application.yaml"
98+
app:
99+
async:
100+
withDLQRetry: true
101+
maxRetries: 1
102+
retryDelay: 1000
103+
```
104+
105+
Now:
106+
107+
```yaml title="application.yaml"
108+
app:
109+
async:
110+
app: # this is the name of the default domain
111+
withDLQRetry: true
112+
maxRetries: 1
113+
retryDelay: 1000
114+
```
115+
116+
- Migrate the connection configuration:
117+
118+
Before: the connection was defined manually in a Java class, as shown below:
119+
120+
```java
121+
122+
@Log4j2
123+
@Configuration
124+
@RequiredArgsConstructor
125+
public class MyDomainConfig {
126+
127+
private final RabbitMQConnectionProperties properties;
128+
private static final String TLS = "TLSv1.2";
129+
private static final String FAIL_MSG = "Error creating ConnectionFactoryProvider in enroll";
130+
131+
@Primary
132+
@Bean
133+
public ConnectionFactoryProvider getConnectionFactoryProvider() {
134+
final var factory = new ConnectionFactory();
135+
var map = PropertyMapper.get();
136+
map.from(properties::hostname).whenNonNull().to(factory::setHost);
137+
map.from(properties::port).to(factory::setPort);
138+
map.from(properties::username).whenNonNull().to(factory::setUsername);
139+
map.from(properties::password).whenNonNull().to(factory::setPassword);
140+
map.from(properties::ssl).whenTrue().as(isSsl -> factory).to(this::configureSsl);
141+
return () -> factory;
142+
}
143+
144+
private void configureSsl(ConnectionFactory factory) {
145+
try {
146+
var sslContext = SSLContext.getInstance(TLS);
147+
var trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
148+
trustManagerFactory.init((KeyStore) null);
149+
sslContext.init(null, trustManagerFactory.getTrustManagers(), null);
150+
factory.useSslProtocol(sslContext);
151+
} catch (KeyManagementException | KeyStoreException | NoSuchAlgorithmException e) {
152+
log.error("{}: {}", FAIL_MSG, e);
153+
}
154+
}
155+
}
156+
```
157+
158+
Now: the connection is configured directly in the `application.yaml` file per domain:
159+
160+
```yaml title="application.yaml"
161+
app:
162+
async:
163+
app: # this is the name of the default domain
164+
connectionProperties: # you can override the connection properties of each domain
165+
host: localhost
166+
port: 5672
167+
username: guest
168+
password: guest
169+
virtual-host: /
170+
# Another domain can be configured with same properties structure that app
171+
accounts: # this is a second domain name and can have another independent setup
172+
connectionProperties: # you can override the connection properties of each domain
173+
host: localhost
174+
port: 5672
175+
username: guest
176+
password: guest
177+
virtual-host: /accounts
178+
```
179+
180+
Domains can also be configured programmatically:
181+
182+
```java title="Programmatic configuration"
183+
184+
@Configuration
185+
public class MyDomainConfig {
186+
187+
@Bean
188+
@Primary
189+
public AsyncRabbitPropsDomainProperties customDomainProperties() {
190+
RabbitProperties propertiesApp = new RabbitProperties();
191+
propertiesApp.setHost("localhost");
192+
propertiesApp.setPort(5672);
193+
propertiesApp.setVirtualHost("/");
194+
propertiesApp.setUsername("guest");
195+
propertiesApp.setPassword("guest");
196+
197+
RabbitProperties propertiesAccounts = new RabbitProperties();
198+
propertiesAccounts.setHost("localhost");
199+
propertiesAccounts.setPort(5672);
200+
propertiesAccounts.setVirtualHost("/accounts");
201+
propertiesAccounts.setUsername("guest");
202+
propertiesAccounts.setPassword("guest");
203+
204+
return AsyncRabbitPropsDomainProperties.builder()
205+
.withDomain("app", AsyncProps.builder()
206+
.connectionProperties(propertiesApp)
207+
.build())
208+
.withDomain("accounts", AsyncProps.builder()
209+
.connectionProperties(propertiesAccounts)
210+
.build())
211+
.build();
212+
}
213+
}
214+
```

docs/docs/reactive-commons/1-getting-started.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Commons.
1717

1818
You need Java JRE installed (Java 17 or later).
1919

20-
You also need to install RabbitMQ. Follow the [instructions from the website](https://www.rabbitmq.com/download.html)
20+
You also need to install RabbitMQ. Follow the [instructions from the website](https://www.rabbitmq.com/download.html).
2121

2222
## Start RabbitMQ
2323

@@ -50,15 +50,16 @@ dependencies {
5050
}
5151
```
5252

53-
Note: If you will use Cloud Events, you should include the Cloud Events dependency:
53+
:::tip
54+
If you will use Cloud Events, you should include the Cloud Events dependency:
5455

5556
```groovy
5657
dependencies {
5758
implementation 'io.cloudevents:cloudevents-json-jackson:4.0.1'
5859
}
5960
```
6061

61-
```groovy
62+
:::
6263

6364
### Configuration properties
6465

docs/docs/reactive-commons/3-sending-a-command.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
sidebar_position: 2
2+
sidebar_position: 3
33
---
44

55
# Sending a Command
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"label": "Reactive Commons",
33
"position": 2,
4+
"collapsed": false,
45
"link": {
56
"type": "generated-index",
67
"description": "Learn how to build reactive systems using the Reactive Commons library."
78
}
8-
}
9+
}

0 commit comments

Comments
 (0)