- Properties props = new Properties();
-
- props.put("bootstrap.servers", kafkaProperties.getBootstrapServers());
- props.put("partition.assignment.strategy", "org.apache.kafka.clients.consumer.StickyAssignor");
- props.put("group.id", kafkaProperties.getConsumer().getGroupId());
- props.put("client.id", kafkaProperties.getClientId());
- props.put("auto.offset.reset", kafkaProperties.getConsumer().getAutoOffsetReset());
- props.put("auto.commit.interval.ms", (int)kafkaProperties.getConsumer().getAutoCommitInterval().toMillis());
- props.put("metadata.max.age.ms", kafkaProperties.getConsumer().getProperties().get("metadata.max.age.ms"));
- props.put("key.deserializer", StringDeserializer.class.getName());
- props.put("value.deserializer", JsonDeserializer.class.getName());
- props.put(JsonDeserializer.TRUSTED_PACKAGES, "de.juplo.kafka");
- props.put(JsonDeserializer.TYPE_MAPPINGS,
- Message.Type.ADD + ":" + MessageAddNumber.class.getName() + "," +
- Message.Type.CALC + ":" + MessageCalculateSum.class.getName());
-
- return new KafkaConsumer<>(props);