Skip to content

Commit

Permalink
Merge pull request #114 from yiliuTo/add-content-type-description
Browse files Browse the repository at this point in the history
add description for content type of batch mode
  • Loading branch information
yiliuTo authored Dec 16, 2021
2 parents b958aaf + 64b5537 commit 38103dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ see the [BatchProducerAndConsumerConfiguration.java][BatchProducerAndConsumerCon
public Supplier<Message<String>> supply() {
return () -> {
LOGGER.info("Sending message, sequence " + i);
return MessageBuilder.withPayload("\"Hello world"+ i++ +"\"").build();
return MessageBuilder.withPayload("\"Hello world "+ i++ +"\"").build();
};
}
```
Expand Down Expand Up @@ -308,10 +308,15 @@ For checkpointing mode as MANUAL, you can use below code to send messages and co
public Supplier<Message<String>> supply() {
return () -> {
LOGGER.info("Sending message, sequence " + i);
return MessageBuilder.withPayload("\"Hello world"+ i++ +"\"").build();
return MessageBuilder.withPayload("\"Hello world "+ i++ +"\"").build();
};
}
```

NOTE: in the batch-consuming mode, the default content type of Spring Cloud Stream binder is **application/json**, so make sure the message payload is aligned with the content-type. For example, when using the default content type of **application/json** to received messages with **String** payload, the payload should be a JSON String, surrounded with double quotes for the original String text. While for **text/plain** content type, it can be a **String** object directly.

For more details, please refer to the official doc of [Spring Cloud Stream Content Type Negotiation][content-type-negotiation].

## Troubleshooting

## Next steps
Expand All @@ -335,4 +340,5 @@ For checkpointing mode as MANUAL, you can use below code to send messages and co
[spring-cloud-stream-batch0-consumer]: https://docs.spring.io/spring-cloud-stream/docs/3.1.4/reference/html/spring-cloud-stream.html#_batch_consumers
[BatchProducerAndConsumerConfiguration]:
src/main/java/com/azure/spring/sample/eventhubs/binder/BatchProducerAndConsumerConfiguration.java
[deploy-spring-boot-application-to-app-service]: https://docs.microsoft.com/java/azure/spring-framework/deploy-spring-boot-java-app-with-maven-plugin?toc=%2Fazure%2Fapp-service%2Fcontainers%2Ftoc.json&view=azure-java-stable
[deploy-spring-boot-application-to-app-service]: https://docs.microsoft.com/java/azure/spring-framework/deploy-spring-boot-java-app-with-maven-plugin?toc=%2Fazure%2Fapp-service%2Fcontainers%2Ftoc.json&view=azure-java-stable
[content-type-negotiation]: https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream.html#content-type-management
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class BatchProducerAndConsumerConfiguration {
public Supplier<Message<String>> supply() {
return () -> {
LOGGER.info("Sending message, sequence " + i++);
return MessageBuilder.withPayload("\"Hello world " + i + "\"").build();
return MessageBuilder.withPayload("\"Hello world " + i++ + "\"").build();
};
}

Expand Down

0 comments on commit 38103dd

Please sign in to comment.