forked from iluwatar/java-design-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iluwatar#2681 : add refactoring on PR#2712
-- refactoring source, test -- clean up in pom file -- updated comments in source -- refactoring the readme wiki
- Loading branch information
Showing
21 changed files
with
554 additions
and
55 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...onent/src/main/java/com/iluwatar/component/component/physiccomponent/PhysicComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,61 @@ | ||
## MESSAGING DESIGN PATTERN | ||
|
||
|
||
### Also Known As : | ||
Event Driven / Message Stream Based MicroService | ||
|
||
### Intent: | ||
Sample implementation for Kafka Bases messaging service | ||
and events will be published based on transactions | ||
|
||
### Explanation | ||
|
||
Use asynchronous messaging for inter-service communication. Services communicating by exchanging messages over messaging channels. | ||
|
||
There are several different styles of asynchronous communication: | ||
|
||
Request/response - a service sends a request message to a recipient and expects to receive a reply message promptly | ||
Notifications - a sender sends a message a recipient but does not expect a reply. Nor is one sent. | ||
Request/asynchronous response - a service sends a request message to a recipient and expects to receive a reply message eventually | ||
Publish/subscribe - a service publishes a message to zero or more recipients | ||
Publish/asynchronous response - a service publishes a request to one or recipients, some of whom send back a reply | ||
|
||
#### This pattern has the following benefits: | ||
|
||
Loose runtime coupling since it decouples the message sender from the consumer | ||
* Improved availability since the message broker buffers messages until the consumer is able to process them | ||
* Supports a variety of communication patterns including request/reply, notifications, request/async response, publish/subscribe, publish/async response etc | ||
* This pattern has the following drawbacks: | ||
|
||
### Class diagram: | ||
![img.png](etc/messaging-urm.png) | ||
|
||
#### High Level Design: | ||
![img.png](etc/high-level-design.png) | ||
|
||
|
||
### Applicability: | ||
* Its more appropriate where the system expecting Pub/Sub based communication | ||
* If immediate notification is required between two microservices, then this pattern will help on the same | ||
|
||
### Tutorials : | ||
1. https://medium.com/design-microservices-architecture-with-patterns/microservices-asynchronous-message-based-communication-6643bee06123 | ||
2. https://microservices.io/patterns/communication-style/messaging.html | ||
|
||
### Known uses: | ||
* Event Driven MicroService - Communication between more than one microservice using messaging channel | ||
* Distributed Transaction Service - Auditing and Notifying system from one to another | ||
|
||
### Consequences: | ||
Additional complexity of message broker, which must be highly available | ||
This pattern has the following issues: | ||
|
||
- Request/reply-style communication is more complex | ||
|
||
### Related patterns : | ||
* The Saga pattern and CQRS pattern use messaging : https://microservices.io/patterns/data/saga.html , https://microservices.io/patterns/data/cqrs.html | ||
* The Transactional Outbox pattern enables messages to be sent as part of a database transaction : https://microservices.io/patterns/data/transactional-outbox.html | ||
|
||
![img.png](img.png) | ||
### Credits: | ||
``` Chris Richardson ``` | ||
Experienced software architect, author of POJOs in Action, the creator of the original CloudFoundry.com |
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
messaging/src/main/java/com/iluwatar/messaging/MessagingApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
messaging/src/main/java/com/iluwatar/messaging/controller/OrderController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
messaging/src/main/java/com/iluwatar/messaging/exception/ConsumerNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
messaging/src/main/java/com/iluwatar/messaging/exception/OrderWithZeroItemException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
messaging/src/main/java/com/iluwatar/messaging/exception/RestaurantNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
messaging/src/main/java/com/iluwatar/messaging/kafka/KafkaConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.