Partitioning

Spring Cloud Stream provides support for partitioning data between multiple instances of an application. In the typical use case, the destination is viewed as being divided into different partitions. Each producer, when sending messages received by multiple consumer instances, ensures that data is identified by configured fields to force processing by the same consumer instance.

To enable the partitioning feature for your application, you have to define the partitionKeyExpression or partitionKeyExtractorClass properties, and partitionCount in the producer configuration settings. Here's the sample configuration that may be provided for your application:

spring.cloud.stream.bindings.output.producer.partitionKeyExpression=payload.customerId ...

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.