You are viewing documentation for an older version of Confluent Platform. For the latest, click here.
Java Message Service (JMS) is a widely used messaging API that is included as part of the Java Platform, Enterprise Edition. Confluent JMS Client (
kafka-jms-client) is an implementation of the JMS 1.1 provider interface that allows Apache Kafka® or Confluent Platform to be used as a JMS message broker.
[kafka-jms-client] <--- kafka protocol ---> [kafka broker]
Applications written using Confluent’s kafka-jms-client can exchange messages with other application written using kafka-jms-client as well as any application that produces or consumes messages using any other Kafka client library.
The purpose of this client is to allow existing applications written to the JMS API to be able to publish and subscribe to Kafka as a replacement for any other JMS broker.
If you are interested in integrating Kafka with an existing JMS broker (i.e. without replacing it) then you are encouraged to look at the Kafka Connect API or any pre-built Kafka Source or Sink Connectors for JMS.
If you are interested in writing new Java applications then you are encouraged to use the Java Kafka Producer/Consumer APIs as they provide advanced features not available when using the kafka-jms-client.
JMS 1.1 Compatibility¶
Where possible, the Kafka JMS Client is a complete implementation of the JMS 1.1 specification. However there are some JMS concepts that either do not map 1:1 to Kafka, or simply do not make sense at all in Kafka (such as nonpersistent messages).
JMS brokers typically provide distinct Topic and Queue functionality that reflects that in the JMS Specification. By contrast, Kafka provides only one abstraction - partitioned topics - which are actually distributed commit logs and behave differently to the traditional messaging system notion of a topic. In practice, Kafka topics can mimic the behavior of either topics or queues in the traditional messaging system sense.
Additional notes on JMS 1.1 compatibility are outlined below.
Both JMS messaging models are supported:
- Publish/Subscribe (Topics)
- Point-to-Point (Queues)
All JMS message types are supported including:
Treatment of JMS header values:
JMSDestination- Set (overwritten) to on send and available in message at the destination.
JMSDeliveryMode- Set (overwritten) to DEAULT_DELIVERY_MODE (PERSISTED) on send.
JMSExpiration- Ignored. Overwritten with 0 on send.
JMSPriority- Ignored. Set (overwritten) with DEFAULT_PRIORITY (4) on send.
JMSMessageID- Set (overwritten) with a unique id for the message on send and available in message at destination.
JMSTimestamp- Set (overwritten) on message send and transmitted to destination if this has not been disabled using
JMSCorrelationID- Value set by user is transmitted to destination.
JMSReplyTo- Value set by user is transmitted to destination.
JMSType- Value set by user is transmitted to destination.
JMSRedelivered- Ignored. Set (overwritten) to false on send.
Only durable topics/queues are supported.
The following functionality has either limited support or no support:
|createDurableSubscriber(Topic, String)||Durable Subscribers are not supported.|
|createDurableSubscriber(Topic, String, String, boolean)||Durable Subscribers are not supported.|
|getMessageListener()||Session based MessageListeners are not supported.|
|setMessageListener(MessageListener)||Session based MessageListeners are not supported.|
|rollback()||Transactions are not supported by Kafka.|
|recover()||Transactions are not supported by Kafka|
|commit()||Transactions are not supported by Kafka.|
|createBrowser(Queue, String)||QueueBrowsers with message selectors are not supported.|
|unsubscribe(String)||Durable Subscribers are not supported.|
|createConsumer(Destination, String)||Message selectors are not supported. An exception will be thrown if one is set.|
|createConsumer(Destination, String, boolean)||Message selectors are not supported. An exception will be thrown if one is set.|
|createTemporaryTopic()||Kafka does not have a concept of a temporary topic.|
|getTransacted()||Transactions are not supported. This will always return false.|
|createTemporaryQueue()||Kafka does not have a concept of a temporary topic.|
|createConnection(String, String)||Not supported. Authentication is only supported via Kafka configuration properties.|
|setClientID(String)||Setting the client id is only supported by using client.id in the settings passed to KafkaConnectionFactory.|