Gh-2921: Fix bean registration in docs sample

Fixes https://github.com/spring-projects/spring-kafka/issues/2921

The `RoutingKafkaTemplate` sample configuration in the `sending-messages.adoc`
use an out-dated API for `context.registerBean()`
(Or the sample has never been correct)
This commit is contained in:
Artem Bilan
2023-12-04 11:46:38 -05:00
parent f30d301763
commit 66f585a6e5

View File

@@ -247,7 +247,7 @@ public class Application {
Map<String, Object> configs = new HashMap<>(pf.getConfigurationProperties());
configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class);
DefaultKafkaProducerFactory<Object, Object> bytesPF = new DefaultKafkaProducerFactory<>(configs);
context.registerBean(DefaultKafkaProducerFactory.class, "bytesPF", bytesPF);
context.registerBean("bytesPF", DefaultKafkaProducerFactory.class, () -> bytesPF);
Map<Pattern, ProducerFactory<Object, Object>> map = new LinkedHashMap<>();
map.put(Pattern.compile("two"), bytesPF);