You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **NOTE:** When using `application.yml` to configure the partition key, its priority will be the lowest.
197
+
> It will take effect only when the `ServiceBusMessageHeaders.SESSION_ID`, `ServiceBusMessageHeaders.PARTITION_KEY`, `AzureHeaders.PARTITION_KEY` are not configured.
198
+
199
+
**Way 2:**
200
+
Manually add the partition Key in the message header by code.
201
+
202
+
*Recommended:* Use `ServiceBusMessageHeaders.PARTITION_KEY` as the key of the header.
203
+
```java
204
+
@PostMapping("/messages")
205
+
public ResponseEntity<String> sendMessage(@RequestParam String message) {
206
+
LOGGER.info("Going to add message {} to Sinks.Many.", message);
> **NOTE:** When the `ServiceBusMessageHeaders.SESSION_ID` is set in the message headers, and a different `ServiceBusMessageHeaders.PARTITION_KEY` (or `AzureHeaders.PARTITION_KEY`) header is also set,
245
+
> the value of the session id will eventually be used to overwrite the value of the partition key.
246
+
247
+
### Run sample
248
+
1. Run the `mvn spring-boot:run` in the root of the code sample to get the app running.
249
+
250
+
2. Send a POST request
171
251
172
252
$ curl -X POST http://localhost:8080/messages?message=hello
173
253
174
254
or when the app runs on App Service or VM
175
255
176
256
$ curl -d -X POST https://[your-app-URL]/messages?message=hello
177
257
178
-
1. Verify in your app’s logs that a similar message was posted:
258
+
3. Verify in your app’s logs that a similar message was posted:
179
259
180
260
New message received: 'hello'
181
261
Message 'hello' successfully checkpointed
182
262
183
-
1. Delete the resources on [Azure Portal][azure-portal] to avoid unexpected charges.
263
+
4. Send a POST request
264
+
265
+
$ curl -X POST http://localhost:8080/setSessionId?message=hello
266
+
267
+
5. It will be visible on Azure Portal that sent messages are configured with session id and partition key.
268
+

269
+
270
+
6. Delete the resources on [Azure Portal][azure-portal] to avoid unexpected charges.
Copy file name to clipboardExpand all lines: servicebus/azure-spring-cloud-stream-binder-servicebus-queue/servicebus-queue-binder/src/main/java/com/azure/spring/sample/servicebus/queue/binder/ServiceProducerController.java
> **NOTE:** When using `application.yml` to configure the partition key, its priority will be the lowest.
198
+
> It will take effect only when the `ServiceBusMessageHeaders.SESSION_ID`, `ServiceBusMessageHeaders.PARTITION_KEY`, `AzureHeaders.PARTITION_KEY` are not configured.
199
+
200
+
**Way 2:**
201
+
Manually add the partition Key in the message header by code.
202
+
203
+
*Recommended:* Use `ServiceBusMessageHeaders.PARTITION_KEY` as the key of the header.
204
+
```java
205
+
@PostMapping("/messages")
206
+
public ResponseEntity<String> sendMessage(@RequestParam String message) {
207
+
LOGGER.info("Going to add message {} to Sinks.Many.", message);
> **NOTE:** When the `ServiceBusMessageHeaders.SESSION_ID` is set in the message headers, and a different `ServiceBusMessageHeaders.PARTITION_KEY` (or `AzureHeaders.PARTITION_KEY`) header is also set,
246
+
> the value of the session id will eventually be used to overwrite the value of the partition key.
247
+
248
+
### Run sample
168
249
169
250
1. Run the `mvn spring-boot:run` in the root of the code sample to get the app running.
170
251
@@ -181,7 +262,14 @@ spring:
181
262
New message received: 'hello'
182
263
Message 'hello' successfully checkpointed
183
264
184
-
1. Delete the resources on [Azure Portal][azure-portal] to avoid unexpected charges.
265
+
4. Send a POST request
266
+
267
+
$ curl -X POST http://localhost:8080/setSessionId?message=hello
268
+
269
+
5. It will be visible on Azure Portal that sent messages are configured with session id and partition key.
270
+

271
+
272
+
6. Delete the resources on [Azure Portal][azure-portal] to avoid unexpected charges.
Copy file name to clipboardExpand all lines: servicebus/azure-spring-cloud-stream-binder-servicebus-topic/servicebus-topic-binder/src/main/java/com/azure/spring/sample/servicebus/topic/binder/ServiceProducerController.java
0 commit comments