Skip to content

Commit abe8e25

Browse files
committed
added example of event brokering with rabbit mq
1 parent 5d4c860 commit abe8e25

16 files changed

Lines changed: 568 additions & 0 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
4+
### STS ###
5+
.apt_generated
6+
.classpath
7+
.factorypath
8+
.project
9+
.settings
10+
.springBeans
11+
12+
### IntelliJ IDEA ###
13+
.idea
14+
*.iws
15+
*.iml
16+
*.ipr
17+
18+
### NetBeans ###
19+
nbproject/private/
20+
build/
21+
nbbuild/
22+
dist/
23+
nbdist/
24+
.nb-gradle/

rabbitmq-event-brokering/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Event Brokering with Spring Boot and RabbitMQ
2+
3+
This application implements an Event mechanism usable in Microservice environments.
4+
5+
## Scenario
6+
7+
* a publisher publishes events with one of these topics
8+
* customer.created
9+
* customer.edited
10+
* customer.deleted
11+
* order.created
12+
* order.edited
13+
* order.deleted
14+
* invoice.created
15+
* invoice.edited
16+
* invoice.deleted
17+
* a subscriber subscribes to events of a specific topic from
18+
a queue specific to its (micro-)service
19+
20+
![Event scenario](event.png)
21+
22+
## Usage
23+
24+
1. [Install RabbitMQ](https://www.rabbitmq.com/download.html) (if it's installed on another
25+
host than localhost then you need to change the connection properties in `application.properties`)
26+
1. start a couple instances of the demo application in `subscriber` mode, for example:
27+
* ./gradlew bootrun -Dspring.profiles.active=subscriber -Dsubscriber.queue=service1Queue -Dsubscriber.routingKey=customer.*
28+
* ./gradlew bootrun -Dspring.profiles.active=subscriber -Dsubscriber.queue=service2Queue -Dsubscriber.routingKey=.*created
29+
* ./gradlew bootrun -Dspring.profiles.active=subscriber -Dsubscriber.queue=service3Queue -Dsubscriber.routingKey=\*.\*
30+
1. start a single instance of the demo application in `publisher` mode:
31+
* ./gradlew bootrun -Dspring.profiles.active=publisher
32+
1. check the log output of the publisher and the subscribes to see which events are produced and which events
33+
are consumed by each subscriber
34+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
buildscript {
2+
ext {
3+
springBootVersion = '1.5.4.RELEASE'
4+
}
5+
repositories {
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10+
}
11+
}
12+
13+
apply plugin: 'java'
14+
apply plugin: 'eclipse'
15+
apply plugin: 'org.springframework.boot'
16+
17+
version = '0.0.1-SNAPSHOT'
18+
sourceCompatibility = 1.8
19+
20+
repositories {
21+
mavenLocal()
22+
mavenCentral()
23+
}
24+
25+
ext {
26+
springCloudVersion = 'Dalston.SR2'
27+
}
28+
29+
dependencies {
30+
compile('org.springframework.boot:spring-boot-starter-amqp')
31+
testCompile('org.springframework.boot:spring-boot-starter-test')
32+
}
33+
34+
bootRun{
35+
// jvmArgs = ["-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006"]
36+
systemProperties = System.properties
37+
}

rabbitmq-event-brokering/event.png

14.2 KB
Loading
53.4 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
zipStoreBase=GRADLE_USER_HOME
4+
zipStorePath=wrapper/dists
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip

rabbitmq-event-brokering/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rabbitmq-event-brokering/gradlew.bat

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)