Message Module¶
Publisher¶
First, You must create or have an output port in the application service layer. So, You create an adapter for implement these ports.
flowchart LR
subgraph application service
output_port
end
subgraph messaging module
secondary_adapter
end
output_port --> secondary_adapter
Part I.
- Models from Event Specification(e.g: Avro Models)
- Mappers
Part II.
- Implementing output ports(Publishers/Producers)
- Secondary Adapter
- Implementing input ports(Listener/Consumers)
- Primary Adapter
Dependencies¶
Important add the avro plugin and generate the avro models with
mvn -pl blank-message/blank-message-model clean install
<!-- Implements OUTPUT ports from application service layer -->
<dependencies>
<dependency>
<groupId>com.blanksystem</groupId>
<artifactId>blank-application-service</artifactId>
</dependency>
<dependency>
<groupId>com.blanksystem</groupId>
<artifactId>blank-message-model</artifactId>
</dependency>
<!-- if you need to produce events-->
<dependency>
<groupId>com.lg5.spring.kafka</groupId>
<artifactId>lg5-spring-kafka-producer</artifactId>
</dependency>
<!-- if you need to consume events-->
<dependency>
<groupId>com.lg5.spring.kafka</groupId>
<artifactId>lg5-spring-kafka-consumer</artifactId>
</dependency>
</dependencies>
Plugins to generate avro models¶
Only for blank-message-model submodule.
* First, Add avro-maven-plugin
for mng the avro model to java objects.
* Second, Disable the maven-checkstyle-plugin
with <skip>true</skip>
.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Project structure¶
Important add the avro plugin and generate the avro models with
mvn -pl blank-message/blank-message-model clean install
src/
├── main/
│ ├── java/
│ │ └── com.blanksystem.message/
│ │ └── model/
│ │ └── avro/
│ │ └── BlankAvroModel.java(autogenerate)
│ └── resources/
│ ├── avro/
│ │ └── blank.avsc
│ └── spec/
│ └── asyncapi.yaml
resourses/spec/asyncapi.yaml
Read more about openapi guidelines
2'DO¶
- Support for asyncapi definition and a process to avro files automatically generation.