Skip to content

Commit cee535c

Browse files
authored
docs(scenarios): Add scenarios documentation (#125)
* docs(scenarios): Add some documentation for multi-broker support
1 parent bedd6f4 commit cee535c

File tree

25 files changed

+4858
-2088
lines changed

25 files changed

+4858
-2088
lines changed

async/async-commons/async-commons.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies {
1010
compileOnly 'io.projectreactor:reactor-core'
1111
api 'com.fasterxml.jackson.core:jackson-databind'
1212
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
13-
implementation 'commons-io:commons-io:2.17.0'
13+
implementation 'commons-io:commons-io:2.18.0'
1414
implementation 'io.cloudevents:cloudevents-json-jackson:4.0.1'
1515

1616
testImplementation 'io.projectreactor:reactor-test'

async/async-kafka/async-kafka.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ dependencies {
88
api project(':domain-events-api')
99
api project(':async-commons')
1010
api 'io.projectreactor.kafka:reactor-kafka:1.3.23'
11-
api 'io.cloudevents:cloudevents-json-jackson:4.0.1'
11+
12+
implementation 'io.cloudevents:cloudevents-json-jackson:4.0.1'
1213
}

async/async-rabbit/async-rabbit.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ dependencies {
1313
api 'io.projectreactor.rabbitmq:reactor-rabbitmq:1.5.6'
1414
api 'com.rabbitmq:amqp-client'
1515
api 'com.fasterxml.jackson.core:jackson-databind'
16-
testImplementation 'io.projectreactor:reactor-test'
16+
1717
implementation 'io.cloudevents:cloudevents-json-jackson:4.0.1'
18+
19+
testImplementation 'io.projectreactor:reactor-test'
1820
}

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ buildscript {
1212

1313
plugins {
1414
id 'jacoco'
15-
id 'org.sonarqube' version '5.1.0.4882'
16-
id 'org.springframework.boot' version '3.3.4' apply false
15+
id 'org.sonarqube' version '6.0.0.5145'
16+
id 'org.springframework.boot' version '3.4.0' apply false
1717
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
18-
id 'co.com.bancolombia.cleanArchitecture' version '3.17.26'
18+
id 'co.com.bancolombia.cleanArchitecture' version '3.20.2'
1919
}
2020

2121
repositories {

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ dependencies {
5050
}
5151
```
5252

53+
Note: If you will use Cloud Events, you should include the Cloud Events dependency:
54+
55+
```groovy
56+
dependencies {
57+
implementation 'io.cloudevents:cloudevents-json-jackson:4.0.1'
58+
}
59+
```
60+
61+
```groovy
62+
5363
### Configuration properties
5464
5565
Also you need to include the name for your app in the `application.properties`, it is important because this value will
@@ -83,7 +93,7 @@ spring:
8393

8494
You can also set it in runtime for example from a secret, so you can create the `RabbitProperties` bean like:
8595

86-
```java title="org.reactivecommons.async.rabbit.standalone.config.RabbitProperties"
96+
```java title="org.reactivecommons.async.rabbit.config.RabbitProperties"
8797
8898
@Configuration
8999
public class MyRabbitMQConfig {
@@ -206,6 +216,14 @@ dependencies {
206216
}
207217
```
208218

219+
Note: If you will use Cloud Events, you should include the Cloud Events dependency:
220+
221+
```groovy
222+
dependencies {
223+
implementation 'io.cloudevents:cloudevents-json-jackson:4.0.1'
224+
}
225+
```
226+
209227
### Configuration properties
210228

211229
Also you need to include the name for your app in the `application.properties`, it is important because this value will

docs/docs/reactive-commons/11-creating-a-cloud-event.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ In order to instantiate a CloudEvent you may need to include the dependencies:
1616

1717
```groovy
1818
implementation 'io.cloudevents:cloudevents-core:<version>'
19+
// or
20+
implementation 'io.cloudevents:cloudevents-json-jackson:<version>'
21+
```
22+
23+
## Creating a CloudEvent instance with our Data wrapper
24+
25+
add this classes:
26+
27+
```java
28+
import io.cloudevents.core.builder.CloudEventBuilder;
29+
import io.cloudevents.CloudEvent;
30+
import org.reactivecommons.async.commons.converters.json.CloudEventBuilderExt;
1931
```
20-
## Creating a CloudEvent instance
2132

2233
```java
2334
CloudEvent commandCloudEvent = CloudEventBuilder.v1()
@@ -44,4 +55,44 @@ CloudEvent eventCloudEvent = CloudEventBuilder.v1()
4455
.withTime(OffsetDateTime.now())
4556
.withData("application/json", CloudEventBuilderExt.asCloudEventData(eventData)) // eventData is your own object
4657
.build();
58+
```
59+
60+
## Creating a CloudEvent instance with jackson wrapper Data wrapper
61+
62+
add this classes:
63+
64+
```java
65+
import io.cloudevents.core.builder.CloudEventBuilder;
66+
import io.cloudevents.CloudEvent;
67+
import io.cloudevents.jackson.JsonCloudEventData;
68+
import com.fasterxml.jackson.databind.ObjectMapper;
69+
```
70+
71+
```java
72+
ObjectMapper mapper = new ObjectMapper(); // You should convert your object to a JsonNode
73+
74+
CloudEvent commandCloudEvent = CloudEventBuilder.v1()
75+
.withId(UUID.randomUUID().toString())
76+
.withSource(URI.create("https://reactivecommons.org/foos"))
77+
.withType("some.command.name")
78+
.withTime(OffsetDateTime.now())
79+
.withData("application/json", JsonCloudEventData.wrap(mapper.valueToTree(commandData))) // commandData is your own object
80+
.build();
81+
82+
CloudEvent queryCloudEvent = CloudEventBuilder.v1()
83+
.withId(UUID.randomUUID().toString())
84+
.withSource(URI.create("https://reactivecommons.org/foos"))
85+
.withType("some.query.name")
86+
.withTime(OffsetDateTime.now())
87+
.withData("application/json", JsonCloudEventData.wrap(mapper.valueToTree(queryData))) // queryData is your own object
88+
.build();
89+
90+
CloudEvent eventCloudEvent = CloudEventBuilder.v1()
91+
.withId(UUID.randomUUID().toString())
92+
.withSource(URI.create("https://reactivecommons.org/foos"))
93+
.withType("some.event.name")
94+
.withDataContentType("application/json")
95+
.withTime(OffsetDateTime.now())
96+
.withData("application/json", JsonCloudEventData.wrap(mapper.valueToTree(eventData))) // eventData is your own object
97+
.build();
4798
```

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public interface DirectAsyncGateway {
3939
}
4040
```
4141

42+
You can send a CloudEvent or a Command\<T> to a target application. You also can send a command to a specific domain
43+
(remote broker out of you application context).
44+
4245
## Enabling autoconfiguration
4346

4447
To send Commands you should enable the respecting spring boot autoconfiguration using the `@EnableDomainEventBus` annotation
@@ -50,7 +53,7 @@ For example:
5053
public class ReactiveDirectAsyncGateway {
5154
public static final String TARGET_NAME = "other-app";// refers to remote spring.application.name property
5255
public static final String SOME_COMMAND_NAME = "some.command.name";
53-
private final DirectAsyncGateway gateway; // Auto injectec bean created by the @EnableDirectAsyncGateway annotation
56+
private final DirectAsyncGateway gateway; // Auto injected bean created by the @EnableDirectAsyncGateway annotation
5457

5558
public Mono<Void> runRemoteJob(Object command/*change for proper model*/) {
5659
return gateway.sendCommand(new Command<>(SOME_COMMAND_NAME, UUID.randomUUID().toString(), command), TARGET_NAME);

docs/docs/reactive-commons/4-making-an-async-query.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public interface DirectAsyncGateway {
3838

3939
In this method the Class\<R> called type is the return type of the query, represented by a JSON Serializable object
4040

41+
You can send a CloudEvent or an AsyncQuery\<T> to a target application. You also can send a query to a specific domain
42+
(remote broker out of you application context).
43+
4144
## Enabling autoconfiguration
4245

4346
To do an Async Query you should enable the respecting spring boot autoconfiguration using the `@EnableDirectAsyncGateway` annotation

docs/docs/reactive-commons/5-handler-registry.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,24 @@ The next methods are the main methods that you can use to register a handler.
1616

1717
```java
1818
public class HandlerRegistry {
19-
public <T> HandlerRegistry listenEvent(String eventName, EventHandler<T> handler, Class<T> eventClass){...}
20-
public <T> HandlerRegistry handleDynamicEvents(String eventNamePattern, EventHandler<T> handler, Class<T> eventClass){...}
21-
public <T> HandlerRegistry listenNotificationEvent(String eventName, EventHandler<T> handler, Class<T> eventClass){...}
22-
public <T> HandlerRegistry handleCommand(String commandName, CommandHandler<T> fn, Class<T> commandClass){...}
23-
public <T, R> HandlerRegistry serveQuery(String resource, QueryHandler<T, R> handler, Class<R> queryClass){...}
24-
public <R> HandlerRegistry serveQuery(String resource, QueryHandlerDelegate<Void, R> handler, Class<R> queryClass) {...}
25-
// ... other methods for eda variant and overloads
19+
public <T> HandlerRegistry listenDomainEvent(String domain, String eventName, DomainEventHandler<T> handler, Class<T> eventClass)
20+
public HandlerRegistry listenDomainCloudEvent(String domain, String eventName, CloudEventHandler handler)
21+
public <T> HandlerRegistry listenEvent(String eventName, DomainEventHandler<T> handler, Class<T> eventClass)
22+
public HandlerRegistry listenCloudEvent(String eventName, CloudEventHandler handler)
23+
public <T> HandlerRegistry listenNotificationEvent(String eventName, DomainEventHandler<T> handler, Class<T> eventClass)
24+
public HandlerRegistry listenNotificationCloudEvent(String eventName, CloudEventHandler handler)
25+
public <T> HandlerRegistry handleDynamicEvents(String eventNamePattern, DomainEventHandler<T> handler, Class<T> eventClass)
26+
public HandlerRegistry handleDynamicCloudEvents(String eventNamePattern, CloudEventHandler handler)
27+
public <T> HandlerRegistry handleCommand(String commandName, DomainCommandHandler<T> fn, Class<T> commandClass)
28+
public HandlerRegistry handleCloudEventCommand(String commandName, CloudCommandHandler handler)
29+
public <T, R> HandlerRegistry serveQuery(String resource, QueryHandler<T, R> handler, Class<R> queryClass)
30+
public <R> HandlerRegistry serveQuery(String resource, QueryHandlerDelegate<Void, R> handler, Class<R> queryClass)
31+
public <R> HandlerRegistry serveCloudEventQuery(String resource, QueryHandler<R, CloudEvent> handler)
32+
public <R> HandlerRegistry serveCloudEventQuery(String resource, QueryHandlerDelegate<Void, CloudEvent> handler)
2633
}
27-
```
34+
```
35+
36+
Methods that Has `CloudEvent` in the name are related to the CloudEvent specification.
37+
38+
Methods that has `domain` String argument are related to the multi-broker support, this support is limited to listen events
39+
from different domains (brokers) independent of the technology.

docs/docs/reactive-commons/9-configuration-properties.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ You can override this settings programmatically through a `AsyncPropsDomainPrope
6767
```java
6868
package sample;
6969
70-
import org.reactivecommons.async.rabbit.standalone.config.RabbitProperties;
70+
import org.reactivecommons.async.rabbit.config.RabbitProperties;
7171
import org.reactivecommons.async.rabbit.config.props.AsyncProps;
7272
import org.reactivecommons.async.rabbit.config.props.AsyncRabbitPropsDomainProperties;
7373
import org.springframework.context.annotation.Bean;

0 commit comments

Comments
 (0)