Search code examples
apache-kafkajmsmicroservicesevent-driven

Kafka vs JMS for event publishing


In our scenario we have a set of micro services which interact with other services by sending event messages. We anticipate millions of messages per day at the peak. Every message is targeted to one or more listener types. Our requirements are as follows:

  1. Zero lost messages.
  2. Ability to dynamically register multiple listeners of a specific type in order to increase throughput.
  3. Listeners are not guaranteed to be alive when messages are dispatched.

We consider 2 options:

  1. Send each message to JMS main queue then listeners of that queue will route the messages to specific queues according to message content, and then target services will listen to those specific queues.
  2. Send messages to a Kafka topic by message type then target services will subscribe to the relevant topic and consume the messages.

What are the cons and pros for using either JMS or Kafka for that purpose?


Solution

  • I would suggest to go with Kafka as it has fault tolerance mechanism and even if some message lost or not captured by any listener you can easily retrieve it from Kafka cluster.

    Along with this you can easily add new listener / listener in group and kafka along with zookeeper will take care of managing it very well.

    In summary, Kafka is a distributed publish-subscribe messaging system that is designed to be fast, scalable, and durable. Like many publish-subscribe messaging systems, Kafkamaintains feeds of messages in topics. Producers write data to topics and consumers read from topics.

    Very easy for integration.