1
- [ ![ Build Status ] ( https://travis-ci.org /reactive-commons/reactive-commons-java.svg?branch=master )] ( https://travis-ci.org/ reactive-commons/reactive-commons-java )
1
+ ![ ] ( https://github.com /reactive-commons/reactive-commons-java/workflows/ reactive-commons-ci-cd/badge.svg )
2
2
# reactive-commons-java
3
3
The purpose of reactive-commons is to provide a set of abstractions and implementations over different patterns and practices that make the foundation of a reactive microservices architecture.
4
4
@@ -11,23 +11,23 @@ To include all (API and implementation) (Spring boot Starter):
11
11
``` groovy
12
12
13
13
dependencies {
14
- compile 'org.reactivecommons:async-commons-starter:0.5.0 '
14
+ compile 'org.reactivecommons:async-commons-starter:0.6.0-beta '
15
15
}
16
16
```
17
17
18
18
To include only domain events API:
19
19
20
20
``` groovy
21
21
dependencies {
22
- compile 'org.reactivecommons:domain-events-api:0.5.0 '
22
+ compile 'org.reactivecommons:domain-events-api:0.6.0-beta '
23
23
}
24
24
```
25
25
26
26
To include only async commons API:
27
27
28
28
``` groovy
29
29
dependencies {
30
- compile 'org.reactivecommons:async-commons-api:0.5.0 '
30
+ compile 'org.reactivecommons:async-commons-api:0.6.0-beta '
31
31
}
32
32
```
33
33
@@ -60,19 +60,7 @@ public class DomainEvent<T> {
60
60
this . data = data;
61
61
}
62
62
63
- public String getName () {
64
- return this . name;
65
- }
66
-
67
- public String getEventId () {
68
- return this . eventId;
69
- }
70
-
71
- public T getData () {
72
- return this . data;
73
- }
74
-
75
- // ... equals, hascode, toString impl..
63
+ // ... getters, equals, hascode, toString impl..
76
64
77
65
}
78
66
```
@@ -119,15 +107,28 @@ public class MainApplication {
119
107
}
120
108
121
109
}
110
+
111
+
112
+ ```
113
+
114
+ Don't forget to add the starter bundle to the main spring boot module (application):
115
+
116
+ ``` groovy
117
+ dependencies {
118
+ compile 'org.reactivecommons:async-commons-starter:0.6.0-beta'
119
+ }
122
120
```
123
- Don't forget to add the implementation dependency to the main spring boot module:
121
+
122
+
123
+ Or add the implementation dependency if for any reason you don't want to use the starter:
124
124
125
125
``` groovy
126
126
dependencies {
127
- compile 'org.reactivecommons:async-commons:0.0.1-alpha1 '
127
+ compile 'org.reactivecommons:async-commons:0.6.0-beta '
128
128
}
129
129
```
130
130
131
+
131
132
### Domain Event-Listener
132
133
Reactive commons has four types of listeners implemented, available to be registered in the application via the ** HandlerRegistry** , each of them is designed to tackle
133
134
common requirements for listeners in event based applications and abstracts the behavior of event flow in every situation (Varying for example in retrying strategy, dead letter events, sources and so on).
@@ -140,18 +141,37 @@ The available event listeners are:
140
141
141
142
Example Code:
142
143
``` java
143
- public HandlerRegistry notificationEvents() {
144
- return HandlerRegistry . register()
145
- .listenNotificationEvent(" gatewayRouteAdded" , message - > {
146
- System . out. println(" Refreshing instance" );
147
- return Mono . empty();
148
- },GatewayEvent . class);
149
- }
144
+ import org.springframework.context.annotation.Bean ;
145
+ import org.springframework.context.annotation.Configuration ;
146
+ import org.springframework.beans.factory.annotation.Autowired ;
147
+
148
+ @Configuration
149
+ public class SomeConfigurationClass {
150
+
151
+ @Autowired
152
+ private ManageTasksUseCase someBusinessDependency;
153
+
154
+ @Bean
155
+ public HandlerRegistry notificationEvents () {
156
+ return HandlerRegistry . register()
157
+ .listenNotificationEvent(" some.event.name" , event - > someBusinessDependency. someFunctionReturningMonoVoid(event), SomeClass . class)
158
+ .listenEvent(" some.event.name2" , event - > someBusinessDependency. functionReturningMonoVoid(event), Some . class)
159
+ .serveQuery(" query.name" , query - > someBusinessDependency. findSomething(query), SomeQuery . class)
160
+ .handleCommand(" command.name" , cmd - > someBusinessDependency. handleCommand(cmd), CmdClass . class);
161
+ }
162
+ }
150
163
```
151
164
152
- The above code shows how to handle a notification event (Notification event: an event that should be handled by
165
+ The first line below "HandlerRegistry.register()" shows how to handle a notification event (Notification event: an event that should be handled by
153
166
every running instance of a microservice, e.g: notify to every instance that a configuration setting has changed
154
167
and has to do a hot reload from a persistent source of that data).
168
+
169
+ The line ".listenEvent.." shows how to handle a standard event, and event that should be handled only once by some running instance of
170
+ the microservice.
171
+
172
+ The line ".serveQuery..." shows how to handle a standard request/reply or rpc messages flow.
173
+
174
+ The line ".handleCommand..." shows how to handle a standard directed command, a message with a delivery guarantee.
155
175
156
176
### Request-Reply
157
177
Example Code:
@@ -265,7 +285,7 @@ app.async.global.exchange=exchangeCustomName
265
285
app.async.global.maxLengthBytes=125000000
266
286
```
267
287
268
- * withDLQRetry: Wheter to enable or not the new Retry DLQ Strategy
288
+ * withDLQRetry: Whether to enable or not the new Retry DLQ Strategy
269
289
* retryDelay: Delay retry value in ms
270
- * maxRetries: Max number of retries in case of error in adition to the one automatic retry per queue.
290
+ * maxRetries: Number of retries in case of error in addition to the one automatic retry per queue.
271
291
0 commit comments