Skip to content

Commit 646ab6e

Browse files
committed
ci(docs): Add docs in main branch, commit gradle version on relese
1 parent 9ee7b0f commit 646ab6e

39 files changed

+16804
-2
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,5 +644,4 @@ MigrationBackup/
644644
# End of https://www.toptal.com/developers/gitignore/api/macos,linux,windows,gradle,java,intellij,visualstudio,eclipse
645645
contiperf-report
646646

647-
samples/async/local-example/
648-
docs
647+
samples/async/local-example/

docs/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

docs/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.11.1

docs/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ yarn
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ yarn start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
Using SSH:
30+
31+
```
32+
$ USE_SSH=true yarn deploy
33+
```
34+
35+
Not using SSH:
36+
37+
```
38+
$ GIT_USER=<Your GitHub username> yarn deploy
39+
```
40+
41+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

docs/babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};

docs/docs/img/reactive-commons.png

31 KB
Loading

docs/docs/intro.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Overview
6+
7+
![Maven metadata URL](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Forg%2Freactivecommons%2Fasync-commons-rabbit-starter%2Fmaven-metadata.xml)
8+
9+
## Reactive Commons
10+
11+
![Example banner](./img/reactive-commons.png)
12+
13+
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.
14+
15+
Even though the main purpose is to provide such abstractions in a mostly generic way such abstractions would be of little use without a concrete implementation so we provide some implementations in a best effors maner that aim to be easy to change, personalize and extend.
16+
17+
The first approach to this work was to release a very simple abstractions and a corresponding implementation over asyncronous message driven communication between microservices build on top of project-reactor and spring boot.
18+
19+
20+
## Project Reactor
21+
22+
[Reactor](https://projectreactor.io) is a highly optimized reactive library for
23+
building efficient, non-blocking applications on the JVM based on the
24+
[Reactive Streams Specification](https://github.com/reactive-streams/reactive-streams-jvm).
25+
Reactor based applications can sustain very high throughput message rates
26+
and operate with a very low memory footprint,
27+
making it suitable for building efficient event-driven applications using
28+
the microservices architecture.
29+
30+
Reactor implements two publishers
31+
[Flux\<T>](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html) and
32+
[Mono\<T>](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html),
33+
both of which support non-blocking back-pressure.
34+
This enables exchange of data between threads with well-defined memory usage,
35+
avoiding unnecessary intermediate buffering or blocking.
36+
37+
## Reactive API for Event Mechanism
38+
39+
Reactive Commons is a reactive API for asynchronous message driven communication based on Reactor.
40+
Reactive Commons API enables messages to be published over a event bus like RabbitMQ or SNS/SQS and consumed using functional APIs with non-blocking back-pressure and low overheads.
41+
It enables applications using Reactor to use RabbitMQ or SNS/SQS as a message bus, integrating it with other systems to provide an end-to-end reactive system.
42+
43+
When we talk about asynchronous message driven communication, we can use several sematic ways to use the term "message". So, we can talk about Events, Commands and Queries.
44+
45+
## Cloud Events
46+
47+
[CloudEvents](https://cloudevents.io/) is a specification for describing event data in a common way. CloudEvents seeks to dramatically simplify event declaration and delivery across services, platforms, and beyond!
48+
49+
## Async API
50+
51+
[Async API](https://www.asyncapi.com/) Open-Source tools to easily build and maintain your event-driven architecture. All powered by the AsyncAPI specification, the industry standard for defining asynchronous APIs.
52+
53+
## Reactive Commons Abstraction
54+
55+
#### Events - Pub/Sub
56+
57+
Events represent a fact inside the domain, it is the representation of a decision or a state change that a system want to notify to its subscribers. Events represents facts that nobody can change, so events are not intentions or requests of anything, An example may be and UserRegistered or a NotificationSent.
58+
59+
Events are the most important topic in a Publish-Subscribe system, because this element let's notify a many stakeholders in a specific event. An other benefit is the system is decouple, because you can add more subscriber to the system without modify some component.
60+
61+
We support a Notification Event pattern in which each instance of an app can receive an event, it can be used to refresh or invalidate some data in all replicas.
62+
63+
#### Commands
64+
65+
Commands represent a intention for doing something, that intention must to be done by the domain context with that responsibility. An example of a command may be: "registerUser" or "sendNotification".
66+
67+
#### Request / Reply
68+
69+
Queries represent a intention for getting information about something, that query must to be processed by the domain context with that responsibility and that context must respond with the information requested throught request/reply pattern. An example of a query may be: "UserInfo".
70+
71+
## Versioning
72+
73+
Reactive Commons uses [Semantic Versioning Specification](https://semver.org)
74+
75+
Reactive Commons uses a MAJOR.MINOR.PATCH scheme, whereby an increment in:
76+
77+
MAJOR version when you make incompatible API changes,
78+
79+
MINOR version when you add functionality in a backwards compatible manner, and
80+
81+
PATCH version when you make backwards compatible bug fixes. Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format. == New & Noteworthy
82+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Getting Started
6+
7+
## What Changes in this Variant?
8+
9+
Before start this guide please review base [Reactive Commons](/reactive-commons-java/docs/category/reactive-commons)
10+
11+
### Multi Broker or Multi Domain support
12+
13+
This variant enables to you the ability to listen events from different domains, send commands to different domains and make queries to different domains.
14+
15+
### Cloud Events
16+
17+
This variant also includes the Cloud Events specification
18+
19+
## Setup
20+
21+
### Current version
22+
![Maven metadata URL](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Forg%2Freactivecommons%2Fasync-commons-rabbit-starter-eda%2Fmaven-metadata.xml)
23+
24+
### Dependency
25+
26+
```groovy
27+
dependencies {
28+
implementation "org.reactivecommons:async-commons-rabbit-starter-eda:<version>"
29+
}
30+
```
31+
32+
### Configuration properties
33+
34+
Also you need to include the name for your app in the `application.properties`, it is important because this value will be used
35+
to name the application queues inside RabbitMQ:
36+
37+
```properties
38+
spring.application.name=MyAppName
39+
```
40+
41+
Or in your `application.yaml`
42+
43+
```yaml
44+
spring:
45+
application:
46+
name: MyAppName
47+
```
48+
49+
You can set the RabbitMQ connection properties through spring boot with the [`spring.rabbitmq.*` properties](https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html)
50+
51+
```yaml
52+
spring:
53+
rabbitmq:
54+
host: localhost
55+
port: 5672
56+
username: guest
57+
password: guest
58+
virtual-host: /
59+
```
60+
61+
You can also set it in runtime for example from a secret, so you can create the `RabbitProperties` bean like:
62+
63+
```java title="org.reactivecommons.async.rabbit.config.RabbitProperties"
64+
@Configuration
65+
public class MyRabbitMQConfig {
66+
67+
@Bean
68+
@Primary
69+
public RabbitProperties customRabbitProperties(){
70+
RabbitProperties properties = new RabbitProperties();
71+
properties.setHost("localhost");
72+
properties.setPort(5672);
73+
properties.setVirtualHost("/");
74+
properties.setUsername("guest");
75+
properties.setPassword("guest");
76+
return properties;
77+
}
78+
}
79+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Creating a CloudEvent
6+
7+
## Aditional Dependencies
8+
9+
To start using this approach you should know the base of `Events`, `Commands` and `AsyncQuery`
10+
11+
This varian includes an object mapper that allows to you to emit CloudEvent serialize and deserialize.
12+
13+
Each API includes overloads related to emit CloudEvent events, send CloudEvent commands and make CloudEvent async queries.
14+
15+
In order to instantiate a CloudEvent you need to include the dependencies:
16+
17+
```groovy
18+
implementation 'io.cloudevents:cloudevents-core:3.0.0'
19+
implementation 'io.cloudevents:cloudevents-http-basic:3.0.0'
20+
implementation 'io.cloudevents:cloudevents-json-jackson:3.0.0'
21+
implementation 'io.cloudevents:cloudevents-spring:3.0.0'
22+
```
23+
## Creating a CloudEvent instance
24+
25+
```java
26+
ObjectMapper om = new ObjectMapper();
27+
28+
CloudEvent commandCloudEvent = CloudEventBuilder.v1()
29+
.withId(UUID.randomUUID().toString())
30+
.withSource(URI.create("https://reactivecommons.org/foos"))
31+
.withType("some.command.name")
32+
.withTime(OffsetDateTime.now())
33+
.withData("application/json", om.writeValueAsBytes(command)) // command is your own object
34+
.build();
35+
36+
CloudEvent queryCloudEvent = CloudEventBuilder.v1()
37+
.withId(UUID.randomUUID().toString())
38+
.withSource(URI.create("https://reactivecommons.org/foos"))
39+
.withType("some.query.name")
40+
.withTime(OffsetDateTime.now())
41+
.withData("application/json", om.writeValueAsBytes(query)) // query is your own object
42+
.build();
43+
44+
CloudEvent eventCloudEvent = CloudEventBuilder.v1()
45+
.withId(UUID.randomUUID().toString())
46+
.withSource(URI.create("https://reactivecommons.org/foos"))
47+
.withType("some.event.name")
48+
.withDataContentType("application/json")
49+
.withTime(OffsetDateTime.now())
50+
.withData("application/json", om.writeValueAsBytes(event)) // event is your own object
51+
.build();
52+
```
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
# Additional API Definitions
6+
7+
Returning to the base API, the additional methods enabled for EDA and CloudEvents are indicated below.
8+
9+
## Aditional Methods in Senders
10+
11+
### DomainEventBus interface
12+
13+
This interface has one additional method specific for EDA
14+
15+
```java
16+
public interface DomainEventBus {
17+
Publisher<Void> emit(CloudEvent event); // Emit with CloudEvent format
18+
19+
//... other base definitions
20+
}
21+
```
22+
23+
### DirectAsyncGateway interface
24+
25+
Ths interface adds some actions for commands and async queries
26+
27+
```java
28+
public interface DirectAsyncGateway {
29+
<T> Mono<Void> sendCommand(Command<T> command, String targetName, String domain); // Send to specific domain
30+
31+
<T> Mono<Void> sendCommand(Command<T> command, String targetName, long delayMillis, String domain); // Send to specific domain with delay
32+
33+
Mono<Void> sendCommand(CloudEvent command, String targetName); // Send with CloudEvent format
34+
35+
Mono<Void> sendCommand(CloudEvent command, String targetName, String domain); // Send with CloudEvent format to an specific domain
36+
37+
<T, R> Mono<R> requestReply(AsyncQuery<T> query, String targetName, Class<R> type, String domain); // Query to specific domain
38+
39+
<R extends CloudEvent> Mono<R> requestReply(CloudEvent query, String targetName, Class<R> type); // Query with CloudEvent format
40+
41+
<R extends CloudEvent> Mono<R> requestReply(CloudEvent query, String targetName, Class<R> type, String domain); // Query with CloudEvent format to specific domain
42+
}
43+
```
44+
45+
## Aditional Listener capabilities
46+
47+
On the other hand, for listener you can use additional capabilities like listen from another domain
48+
49+
### HandlerRegistry class
50+
51+
```java
52+
public class HandlerRegistry {
53+
public <T> HandlerRegistry listenDomainEvent(String domain, String eventName, EventHandler<T> handler, Class<T> eventClass) {...} // Class could be CloudEvent.class
54+
55+
// ... other base methods
56+
}
57+
```

0 commit comments

Comments
 (0)