-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add README.adoc for servicebus queue multibinders sample (#691)
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
spring-cloud-azure-samples/servicebus-queue-multibinders-sample/README.adoc
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
= Spring Cloud Azure Stream Binder for Multiple Service Bus Namespaces Code Sample | ||
|
||
This code sample demonstrates how to use the Spring Cloud Stream Binder for multiple Azure Service Bus namespaces. | ||
In this sample you will bind to two Service Bus namespaces separately through two queue binders. | ||
The sample app exposes REST APIs to receive string message. Then message is sent through Azure | ||
Service Bus to a `sink` which simply logs the message. | ||
|
||
Running this sample will be charged by Azure. You can check the usage and bill at https://azure.microsoft.com/en-us/account/[this link]. | ||
|
||
== Connection string based usage | ||
|
||
1. Create two queues in different Service Bus namespaces. Please refer to https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-create-namespace-portal[Azure Service Bus]. | ||
|
||
2. Update link:src/main/resources/application.properties[application.properties] | ||
|
||
+ | ||
|
||
[source%nowrap, properties] | ||
.... | ||
# Configuration for default binder. Currently, the limitation is default binder must be provided | ||
# Fill the first Service Bus namespace connection string copied from portal | ||
spring.cloud.azure.servicebus.connection-string=[servicebus-namespace-1-connection-string] | ||
# Configuration for another binder | ||
spring.cloud.stream.binders.servicebus2.type=servicebus-queue | ||
# Set defaultCandidate to false | ||
spring.cloud.stream.binders.servicebus2.defaultCandidate=false | ||
spring.cloud.stream.binders.servicebus2.environment.spring.cloud.azure.servicebus.connection-string=[servicebus-namespace-2-connection-string] | ||
.... | ||
|
||
[NOTE] | ||
==== | ||
The *defaultCandidate* configuration item: | ||
Whether the binder configuration is a candidate for being considered a default binder, or can be used only when explicitly referenced. This allows adding binder configurations without interfering with the default processing. | ||
==== | ||
|
||
|
||
== How to run | ||
1. Update stream binding related properties in link:src/main/resources/application.properties[application.properties] | ||
|
||
+ | ||
[source%nowrap, properties] | ||
.... | ||
spring.cloud.stream.bindings.input.destination=[servicebus-queue-1-name] | ||
spring.cloud.stream.bindings.output.destination=[servicebus-queue-name-same-as-above] | ||
spring.cloud.stream.bindings.input1.destination=[servicebus-queue-2-name] | ||
spring.cloud.stream.bindings.output1.destination=[servicebus-queue-name-same-as-above] | ||
.... | ||
|
||
2. Run the `mvn clean spring-boot:run` in the root of the code sample to get the app running. | ||
|
||
3. Send a POST request to test the default binder | ||
+ | ||
.... | ||
$ curl -X POST http://localhost:8080/messages?message=hello | ||
.... | ||
+ | ||
|
||
4. Verify in your app's logs that a similar message was posted: | ||
+ | ||
.... | ||
[1] New message received: 'hello' | ||
[1] Message 'hello' successfully checkpointed | ||
.... | ||
|
||
5. Send another POST request to test the other binder | ||
+ | ||
.... | ||
$ curl -X POST http://localhost:8080/messages1?message=hello | ||
.... | ||
+ | ||
|
||
6. Verify in your app's logs that a similar message was posted: | ||
+ | ||
.... | ||
[2] New message received: 'hello' | ||
[2] Message 'hello' successfully checkpointed | ||
.... | ||
|
||
5. Delete the resources on http://ms.portal.azure.com/[Azure Portal] to avoid unexpected charges. |