|
1 | 1 | [[migration]] |
| 2 | +=== Changes between 2.1 and 2.2 |
| 3 | + |
| 4 | +[[kafka-client-2.0]] |
| 5 | +==== Kafka Client Version |
| 6 | + |
| 7 | +This version requires the 2.0.0 `kafka-clients` or higher. |
| 8 | + |
| 9 | +==== Class and Package Changes |
| 10 | + |
| 11 | +The `ContainerProperties` class has been moved from `org.springframework.kafka.listener.config` to `org.springframework.kafka.listener`. |
| 12 | + |
| 13 | +The `AckMode` enum has been moved from `AbstractMessageListenerContainer` to `ContainerProperties`. |
| 14 | + |
| 15 | +The `setBatchErrorHandler()` and `setErrorHandler()` methods have been moved from `ContainerProperties` to both `AbstractMessageListenerContainer` and `AbstractKafkaListenerContainerFactory`. |
| 16 | + |
| 17 | +==== After Rollback Processing |
| 18 | + |
| 19 | +A new `AfterRollbackProcessor` strategy is provided. |
| 20 | +See <<after-rollback>> for more information. |
| 21 | + |
| 22 | +==== `ConcurrentKafkaListenerContainerFactory` Changes |
| 23 | + |
| 24 | +You can now use the `ConcurrentKafkaListenerContainerFactory` to create and configure any `ConcurrentMessageListenerContainer`, not only those for `@KafkaListener` annotations. |
| 25 | +See <<container-factory>> for more information. |
| 26 | + |
| 27 | +==== Listener Container Changes |
| 28 | + |
| 29 | +A new container property (`missingTopicsFatal`) has been added. |
| 30 | +See <<kafka-container>> for more information. |
| 31 | + |
| 32 | +A `ConsumerStoppedEvent` is now emitted when a consumer terminates. |
| 33 | +See <<thread-safety>> for more information. |
| 34 | + |
| 35 | +Batch listeners can optionally receive the complete `ConsumerRecords<?, ?>` object instead of a `List<ConsumerRecord<?, ?>`. |
| 36 | +See <<batch-listeners>> for more information. |
| 37 | + |
| 38 | +The `DefaultAfterRollbackProcessor` and `SeekToCurrentErrorHandler` can now recover (skip) records that keep failing, and, by default, does so after 10 failures. |
| 39 | +They can be configured to publish failed records to a dead-letter topic. |
| 40 | + |
| 41 | +Starting with version 2.2.4, the consumer's group ID can be used while selecting the dead letter topic name. |
| 42 | + |
| 43 | +See <<after-rollback>>, <<seek-to-current>>, and <<dead-letters>> for more information. |
| 44 | + |
| 45 | +The `ConsumerStoppingEvent` has been added. |
| 46 | +See <<events>> for more information. |
| 47 | + |
| 48 | +The `SeekToCurrentErrorHandler` can now be configured to commit the offset of a recovered record when the container is configured with `AckMode.MANUAL_IMMEDIATE` (since 2.2.4). |
| 49 | +See <<seek-to-current>> for more information. |
| 50 | + |
| 51 | +==== @KafkaListener Changes |
| 52 | + |
| 53 | +You can now override the `concurrency` and `autoStartup` properties of the listener container factory by setting properties on the annotation. |
| 54 | +You can now add configuration to determine which headers (if any) are copied to a reply message. |
| 55 | +See <<kafka-listener-annotation>> for more information. |
| 56 | + |
| 57 | +You can now use `@KafkaListener` as a meta-annotation on your own annotations. |
| 58 | +See <<kafka-listener-meta>> for more information. |
| 59 | + |
| 60 | +It is now easier to configure a `Validator` for `@Payload` validation. |
| 61 | +See <<kafka-validation>> for more information. |
| 62 | + |
| 63 | +You can now specify kafka consumer properties directly on the annotation; these will override any properties with the same name defined in the consumer factory (since version 2.2.4). |
| 64 | +See <<annotation-properties>> for more information. |
| 65 | + |
| 66 | +==== Header Mapping Changes |
| 67 | + |
| 68 | +Headers of type `MimeType` and `MediaType` are now mapped as simple strings in the `RecordHeader` value. |
| 69 | +Previously, they were mapped as JSON and only `MimeType` was decoded. |
| 70 | +`MediaType` could not be decoded. |
| 71 | +They are now simple strings for interoperability. |
| 72 | + |
| 73 | +Also, the `DefaultKafkaHeaderMapper` has a new `addToStringClasses` method, allowing the specification of types that should be mapped by using `toString()` instead of JSON. |
| 74 | +See <<headers>> for more information. |
| 75 | + |
| 76 | +==== Embedded Kafka Changes |
| 77 | + |
| 78 | +The `KafkaEmbedded` class and its `KafkaRule` interface have been deprecated in favor of the `EmbeddedKafkaBroker` and its JUnit 4 `EmbeddedKafkaRule` wrapper. |
| 79 | +The `@EmbeddedKafka` annotation now populates an `EmbeddedKafkaBroker` bean instead of the deprecated `KafkaEmbedded`. |
| 80 | +This change allows the use of `@EmbeddedKafka` in JUnit 5 tests. |
| 81 | +The `@EmbeddedKafka` annotation now has the attribute `ports` to specify the port that populates the `EmbeddedKafkaBroker`. |
| 82 | +See <<testing>> for more information. |
| 83 | + |
| 84 | +==== JsonSerializer/Deserializer Enhancements |
| 85 | + |
| 86 | +You can now provide type mapping information by using producer and consumer properties. |
| 87 | + |
| 88 | +New constructors are available on the deserializer to allow overriding the type header information with the supplied target type. |
| 89 | + |
| 90 | +The `JsonDeserializer` now removes any type information headers by default. |
| 91 | + |
| 92 | +You can now configure the `JsonDeserializer` to ignore type information headers by using a Kafka property (since 2.2.3). |
| 93 | + |
| 94 | +See <<serdes>> for more information. |
| 95 | + |
| 96 | +==== Kafka Streams Changes |
| 97 | + |
| 98 | +The streams configuration bean must now be a `KafkaStreamsConfiguration` object instead of a `StreamsConfig` object. |
| 99 | + |
| 100 | +The `StreamsBuilderFactoryBean` has been moved from package `...core` to `...config`. |
| 101 | + |
| 102 | +The `KafkaStreamBrancher` has been introduced for better end-user experience when conditional branches are built on top of `KStream` instance. |
| 103 | + |
| 104 | +See <<kafka-streams>> and <<streams-config>> for more information. |
| 105 | + |
| 106 | + |
| 107 | +==== Transactional ID |
| 108 | + |
| 109 | +When a transaction is started by the listener container, the `transactional.id` is now the `transactionIdPrefix` appended with `<group.id>.<topic>.<partition>`. |
| 110 | +This change allows proper fencing of zombies, https://www.confluent.io/blog/transactions-apache-kafka/[as described here]. |
| 111 | + |
| 112 | + |
2 | 113 | === Changes between 2.0 and 2.1 |
3 | 114 |
|
| 115 | +[[kafka-client-1.0]] |
4 | 116 | ==== Kafka Client Version |
5 | 117 |
|
6 | 118 | This version requires the 1.0.0 `kafka-clients` or higher. |
|
0 commit comments