Java Magazine, Jan/Feb 2018
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2018 83 beyond CRUD @ PreDestroy public void closeConsumer eventConsumer stop Integrating Apache Kafka Apache Kafka serves as a reliable persistent and scalable event hub that delivers events to the services involved I make use of event topics that are consumed in so called consumer groups In this case I configure Kafka to deliver the events reliably once in every consumer group By configuring the same group for all event handlers I ensure that only one instance processes an event The event producer shown in the following code publishes the events to Kafka @ ApplicationScoped public class EventProducer private Producer String CoffeeEvent producer @ Inject Properties kafkaProperties @ Inject Logger logger @ PostConstruct private void init
You must have JavaScript enabled to view digital editions.