Skip to content

Commit

Permalink
added azure service bus topics as a binder
Browse files Browse the repository at this point in the history
  • Loading branch information
malevy committed Jan 1, 2020
1 parent a8bfd04 commit bae057d
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 31 deletions.
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ services:
environment:
server.port: 80
spring.rabbitmq.host: rabbit
spring_profiles_active: ${active_profile}
spring.cloud.azure.servicebus.connection-string: ${azure_topic_connectstring}

payment-service:
build: ./eda-payment-service
Expand All @@ -49,6 +51,8 @@ services:
spring.rabbitmq.host: rabbit
chaos.monkey.assaults.level: 10 # attack each 10th request. the default is 5
chaos_monkey_enabled:
spring_profiles_active: ${active_profile}
spring.cloud.azure.servicebus.connection-string: ${azure_topic_connectstring}

order-service:
build: ./eda-order-service
Expand All @@ -66,4 +70,6 @@ services:
spring.rabbitmq.host: rabbit
app_services_payment: http://payment-service
app_services_reservation: http://reservation-service
spring_profiles_active: ${active_profile}
spring.cloud.azure.servicebus.connection-string: ${azure_topic_connectstring}

7 changes: 7 additions & 0 deletions eda-order-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
<version>3.0.1.RELEASE</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.microsoft.azure/spring-cloud-azure-servicebus-topic-stream-binder -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-azure-servicebus-topic-stream-binder</artifactId>
<version>1.2.0</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
37 changes: 28 additions & 9 deletions eda-order-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,26 @@ spring:
name: eda-order
cloud:
stream:
# the destination is the RMQ exchange while the group is the RMQ queue
bindings:
input:
destination: ticketing-events
group: order-processor
output:
destination: ticketing-events

# disable azure servicebus
azure:
servicebus:
enabled: false

app:
services:
payment: http://eda-payment
reservation: http://eda-reservation


---
# the destination is the RMQ exchange while the group is the RMQ queue
spring:
profiles: rabbitmq
rabbitmq:
Expand All @@ -48,11 +53,25 @@ spring:
virtual-host: /
cloud:
stream:
bindings:
input:
binder: local_rabbit
output:
binder: local_rabbit
binders:
local_rabbit:
type: rabbit
default-binder: rabbit

---
# the destination is the Azure Servicebus Topic and the group is the Subscription
# binder properties: https://github.com/Microsoft/spring-cloud-azure/tree/master/spring-cloud-azure-stream-binder/spring-cloud-azure-servicebus-topic-stream-binder
spring:
profiles: azure-topic
cloud:
stream:
servicebus:
topic:
bindings:
input:
consumer:
checkpoint-mode: RECORD
default-binder: servicebus-topic
azure:
servicebus:
enabled: true
connection-string:


7 changes: 7 additions & 0 deletions eda-payment-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
<version>3.0.1.RELEASE</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.microsoft.azure/spring-cloud-azure-servicebus-topic-stream-binder -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-azure-servicebus-topic-stream-binder</artifactId>
<version>1.2.0</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
33 changes: 25 additions & 8 deletions eda-payment-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ spring:
output:
destination: ticketing-events

# disable azure servicebus
azure:
servicebus:
enabled: false

---
spring:
profiles: rabbitmq
Expand All @@ -42,11 +47,23 @@ spring:
virtual-host: /
cloud:
stream:
bindings:
input:
binder: local_rabbit
output:
binder: local_rabbit
binders:
local_rabbit:
type: rabbit
default-binder: rabbit

---
# the destination is the Azure Servicebus Topic and the group is the Subscription
# binder properties: https://github.com/Microsoft/spring-cloud-azure/tree/master/spring-cloud-azure-stream-binder/spring-cloud-azure-servicebus-topic-stream-binder
spring:
profiles: azure-topic
cloud:
stream:
servicebus:
topic:
bindings:
input:
consumer:
checkpoint-mode: RECORD
default-binder: servicebus-topic
azure:
servicebus:
enabled: true
connection-string:
6 changes: 6 additions & 0 deletions eda-reservation-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
<version>3.0.1.RELEASE</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.microsoft.azure/spring-cloud-azure-servicebus-topic-stream-binder -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>spring-cloud-azure-servicebus-topic-stream-binder</artifactId>
<version>1.2.0</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
39 changes: 30 additions & 9 deletions eda-reservation-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@ spring:
output:
destination: ticketing-events

---
# disable azure servicebus
azure:
servicebus:
enabled: false

app:
services:
payment: http://eda-payment
reservation: http://eda-reservation

---
# the destination is the RMQ exchange while the group is the RMQ queue
spring:
profiles: rabbitmq
rabbitmq:
Expand All @@ -45,12 +55,23 @@ spring:
virtual-host: /
cloud:
stream:
bindings:
input:
binder: local_rabbit
output:
binder: local_rabbit
binders:
local_rabbit:
type: rabbit
default-binder: rabbit

---
# the destination is the Azure Servicebus Topic and the group is the Subscription
# binder properties: https://github.com/Microsoft/spring-cloud-azure/tree/master/spring-cloud-azure-stream-binder/spring-cloud-azure-servicebus-topic-stream-binder
spring:
profiles: azure-topic
cloud:
stream:
servicebus:
topic:
bindings:
input:
consumer:
checkpoint-mode: RECORD
default-binder: servicebus-topic
azure:
servicebus:
enabled: true
connection-string:
38 changes: 33 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,44 @@ really bad ticketing website. There are two modes that the
demo can be run in:

1. a typical request/response system
2. an EDA configuration that uses RabbitMQ as a message
bus.
1. an EDA configuration that uses either RabbitMQ or Azure ServiceBus Topics.


#### configuring Azure ServiceBus Topic

#### build and run the demo
> Note: there are opportunities for improvement here via automation
> Requires Java 10
Using this demo solution with Azure requires that you have configured the appropriate resources.
1. you must have an Azure Subscription
1. create a Resource Group to contain the ServiceBus Namespace
1. create a Service Bus Namespace
1. the Premium tier or higher is required
1. create a Topic within the namespace
1. create a Shared Access Policy (SAP) with the Send and Listen claims, at a minimum.
1. you will need to supply one of the generated connection strings as shown below.
1. create three subscriptions against the topic. these subscriptions are named after the
service that will make use of them.
1. order-processor
1. reservation-processor
1. payment-processor

#### build and run the demo

> the environment variable 'active_profile' needs to be set to either
> 'rabbitmq' to use RabbitMQ or
> 'azure-topic' for Azure ServiceBus Topic
> the environment variable 'azure_topic_connectstring' should be set to one of the
> connection strings that were generated when you created the SAP above. I am using a single
> connection string for all the services for simplicity. a better practice would be for each
> service to have it's own access policy
mvn clean package
export active_profile=azure-topic
export azure_topic_connectstring=...
docker-compose build --no-cache
docker-compose up


#### sample requests

submit an order using the request/response sync configuration
Expand Down Expand Up @@ -70,6 +95,9 @@ to *true* prior to spinning up the containers.
export chaos_monkey_enabled=true

#### cleanup
deleting the Azure Resource Group is a quick and easy way to release all of the resources that
were created within Azure.

an easy way to remove all of the EDA images

docker rmi $(docker images --filter=reference="eda*" -q)
Expand Down

0 comments on commit bae057d

Please sign in to comment.