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 )
22# reactive-commons-java
33The 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.
44
@@ -11,23 +11,23 @@ To include all (API and implementation) (Spring boot Starter):
1111``` groovy
1212
1313 dependencies {
14- compile 'org.reactivecommons:async-commons-starter:0.5.0 '
14+ compile 'org.reactivecommons:async-commons-starter:0.6.0-beta '
1515 }
1616```
1717
1818To include only domain events API:
1919
2020``` groovy
2121 dependencies {
22- compile 'org.reactivecommons:domain-events-api:0.5.0 '
22+ compile 'org.reactivecommons:domain-events-api:0.6.0-beta '
2323 }
2424```
2525
2626To include only async commons API:
2727
2828``` groovy
2929 dependencies {
30- compile 'org.reactivecommons:async-commons-api:0.5.0 '
30+ compile 'org.reactivecommons:async-commons-api:0.6.0-beta '
3131 }
3232```
3333
@@ -60,19 +60,7 @@ public class DomainEvent<T> {
6060 this . data = data;
6161 }
6262
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..
7664
7765}
7866```
@@ -119,15 +107,28 @@ public class MainApplication {
119107 }
120108
121109}
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+ }
122120```
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:
124124
125125``` groovy
126126 dependencies {
127- compile 'org.reactivecommons:async-commons:0.0.1-alpha1 '
127+ compile 'org.reactivecommons:async-commons:0.6.0-beta '
128128 }
129129```
130130
131+
131132### Domain Event-Listener
132133Reactive commons has four types of listeners implemented, available to be registered in the application via the ** HandlerRegistry** , each of them is designed to tackle
133134common 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:
140141
141142Example Code:
142143``` 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+ }
150163```
151164
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
153166every running instance of a microservice, e.g: notify to every instance that a configuration setting has changed
154167 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.
155175
156176### Request-Reply
157177Example Code:
@@ -265,7 +285,7 @@ app.async.global.exchange=exchangeCustomName
265285app.async.global.maxLengthBytes=125000000
266286```
267287
268- * withDLQRetry: Wheter to enable or not the new Retry DLQ Strategy
288+ * withDLQRetry: Whether to enable or not the new Retry DLQ Strategy
269289* 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.
271291
0 commit comments