4. Configuration options

Spring Cloud Stream supports general configuration options, as well as configuration for bindings and binders. Some binders allow additional properties for the bindings, supporting middleware-specific features.

All configuration options can be provided to Spring Cloud Stream applications via all the mechanisms supported by Spring Boot: application arguments, environment variables, YML files etc.

4.1 Spring Cloud Stream Properties

spring.cloud.stream.instanceCount
The number of deployed instances of the same application. Must be set for partitioning and with Kafka. Default value is 1.
spring.cloud.stream.instanceIndex
The instance index of the application, a number from 0 to instanceCount-1. Used for partitioning and with Kafka. Automatically set in Cloud Foundry to match the instance index of the application.
spring.cloud.stream.dynamicDestinations
A list of destinations that can be bound dynamically, for example in a dynamic routing scenario. Only listed destinations can be bound if set. Default empty, allowing any destination to be bound.
spring.cloud.stream.defaultBinder
The default binder to use, if there are multiple binders configured. See multiple binders.

4.2 Binding properties

Binding properties are supplied using the format spring.cloud.stream.bindings.<channelName>.<property>=<value>.<channelName> represents the name of the channel being configured, e.g. output for a Source. In what follows, we will indicate where the spring.cloud.stream.bindings.<channelName>. prefix is omitted and focus just on the property name, with the understanding that the prefix will be included at runtime.

4.2.1 Properties for the use of Spring Cloud Stream

The following binding properties are available for both input and output bindings and must be prefixed with spring.cloud.stream.bindings.<channelName>. .

destination
The target destination of channel on the bound middleware, e.g. Rabbit MQ exchange or Kafka topic. If not set, the channel name will be used instead.
group
The consumer group of the channel. This property applies only to inbound bindings. By default it is null, and indicates an anonymous consumer. See consumer groups.
contentType
The content type of the channel. By default it is null and no type coercion is performed. See ???.
binder
The binder used by this binding. By default, it is set to null and will use the default binder, if one exists. See Section 6.2, “Multiple Binders on the Classpath” for details.

4.2.2 Consumer properties

The following binding properties are available for input bindings only and must be prefixed with spring.cloud.stream.bindings.<channelName>.consumer:

concurrency
The concurrency of the inbound consumer. By default, set to 1.
partitioned
Must be set to true if the consumer is receiving data from a partitioned producer. By default it is set to false.
maxAttempts
The number of attempts of re-processing an inbound message. Default '3'. (Ignored by Kafka, currently).
backOffInitialInterval
The backoff initial interval on retry. Default 1000.(Ignored by Kafka, currently).
backOffMaxInterval
The maximum backoff interval. Default 10000.(Ignored by Kafka, currently).
backOffMultiplier
The backoff multiplier. Default 2.0.

4.2.3 Producer properties

The following binding properties are available for output bindings only and must be prefixed with spring.cloud.stream.bindings.<channelName>.producer:

partitionKeyExpression
A SpEL expression for partitioning outbound data. Default: null. If either this property is set or partitionKeyExtractorClass is present, outbound data on this channel will be partitioned, and partitionCount must be set to a value larger than 1 to be effective. The two options are mutually exclusive. See Section 2.3, “Partitioning”.
partitionKeyExtractorClass
A PartitionKeyExtractorStrategy implementation. Default: null. If either this property is set or partitionKeyExpression is present, outbound data on this channel will be partitioned, and partitionCount must be set to a value larger than 1 to be effective. The two options are mutually exclusive. See Section 2.3, “Partitioning”.
partitionSelectorClass
A PartitionSelectorStrategy implementation. Default null. Mutually exclusive with partitionSelectorExpression. If none is set, the partition will be selected as the hashCode(key) % partitionCount, where key is computed via either partitionKeyExpression or partitionKeyExtractorClass.
partitionSelectorExpression
A SpEL expression for customizing partition selection. Default null. Mutually exclusive with partitionSelectorClass. If none is set, the partition will be selected as the hashCode(key) % partitionCount, where key is computed via either partitionKeyExpression or partitionKeyExtractorClass.
partitionCount
The number of target partitions for the data, if partitioning is enabled. Default 1. Must be set to a value higher than 1 if the producer is partitioned. On Kafka it is interpreted as a hint, and the larger of this and the partition count of the target topic will be used instead.
requiredGroups
A comma separated list of groups that the producer must ensure message delivery even if they start after it has been created (e.g. by pre-creating durable queues in Rabbit MQ).