Prep work for Kafka Issue #236

See https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/236

- add `none` as a synonym for `HeaderMode.raw`
- add `headers` meaning "use native headers"
- change the default header mode - `null`
- remove `supportsHeadersNatively` - allow binders to chose header mode for each binding
  binders decide their own default when the property is null
- Rabbit will choose `headers` as default (but can be overridden to `none` for a binding)
  `embeddedHeaders` will not be allowed
- Kafka will choose `embeddedHeaders` as default for compatibility with 1.x peer apps
- remove deprecations on header embedding code

Polishing; support fallback

- if the consumer side is configured to support embedded headers,
  binders should look for native headers first and signal their presence
  using the `BinderHeaders.NATIVE_HEADERS_PRESENT` header;
  fall back to embedded headers if it appears the payload might contain
  them
- remove support for XD embedded headers (first byte < 0xff)
- add a quick check for embedded headers by examining the first byte for 0xff
- change the log from error to debug when decoding embedded headers fails

- see the kafka binder PR for a test case with a consumer that can handle all
  message flavors (native, embedded, and no headers).
This commit is contained in:
Gary Russell
2017-10-20 14:32:18 -04:00
committed by Oleg Zhurakousky
parent a06231b20f
commit b5aa59e244
8 changed files with 79 additions and 61 deletions

View File

@@ -1165,7 +1165,7 @@ Default: null (the default binder will be used, if one exists).
The following binding properties are available for input bindings only and must be prefixed with `spring.cloud.stream.bindings.<channelName>.consumer.`, e.g. `spring.cloud.stream.bindings.input.consumer.concurrency=3`.
Default values can be set by using the prefix `spring.cloud.stream.default.consumer`, e.g. `spring.cloud.stream.default.consumer.headerMode=raw`.
Default values can be set by using the prefix `spring.cloud.stream.default.consumer`, e.g. `spring.cloud.stream.default.consumer.headerMode=none`.
concurrency::
The concurrency of the inbound consumer.
@@ -1176,11 +1176,13 @@ partitioned::
+
Default: `false`.
headerMode::
When set to `raw`, disables header parsing on input.
When set to `none`, disables header parsing on input.
Effective only for messaging middleware that does not support message headers natively and requires header embedding.
Useful when inbound data is coming from outside Spring Cloud Stream applications.
This option is useful when consuming data from non-Spring Cloud Stream applications when native headers are not supported.
When set to `headers`, uses the middleware's native header mechanism.
When set to `embeddedHeaders`, embeds headers into the message payload.
+
Default: `embeddedHeaders`.
Default: depends on binder implementation.
maxAttempts::
If processing fails, the number of attempts to process the message (including the first).
Set to 1 to disable retry.
@@ -1252,16 +1254,18 @@ Default: `1`.
requiredGroups::
A comma-separated list of groups to which the producer must ensure message delivery even if they start after it has been created (e.g., by pre-creating durable queues in RabbitMQ).
headerMode::
When set to `raw`, disables header embedding on output.
When set to `none`, disables header embedding on output.
Effective only for messaging middleware that does not support message headers natively and requires header embedding.
Useful when producing data for non-Spring Cloud Stream applications.
This option is useful when producing data for non-Spring Cloud Stream applications when native headers are not supported.
When set to `headers`, uses the middleware's native header mechanism.
When set to `embeddedHeaders`, embeds headers into the message payload.
+
Default: `embeddedHeaders`.
Default: Depends on binder implementation.
useNativeEncoding::
When set to `true`, the outbound message is serialized directly by client library, which must be configured correspondingly (e.g. setting an appropriate Kafka producer value serializer).
When this configuration is being used, the outbound message marshalling is not based on the `contentType` of the binding.
When native encoding is used, it is the responsibility of the consumer to use appropriate decoder (ex: Kafka consumer value de-serializer) to deserialize the inbound message.
Also, when native encoding/decoding is used the `headerMode` property is ignored and headers will not be embedded into the message.
Also, when native encoding/decoding is used the `headerMode=embeddedHeaders` property is ignored and headers will not be embedded into the message.
+
Default: `false`.
errorChannelEnabled::