Search code examples
apache-kafkaibm-cloudmessage-hub

How To Authenticate To IBM Message Hub Without Jass Login Module


I have tried setting up a connection to kafka-message-hub on Bluemix using a Liberty for Java app. I followed the docs and the git repository example. It creates/uses a jaas.conf file fine and says it logs in. When a message is written, however, it says "Failed to update metadata after 60000 ms." In order to write a message, I had to add the following code to the server.xml file:

    <jaasLoginModule id="KafkaClient"
            className="org.apache.kafka.common.security.plain.PlainLoginModule"
            controlFlag="REQUIRED" libraryRef="kafkaLoginLib">

    <options serviceName="kafka" username="MYUSERNAME" password="MYPASSWORD" />
</jaasLoginModule>

However, the docs say (under "How to migrate the Kafka client from 0.9.x to 0.10.x"):

  1. Delete the Message Hub login Jar module.
  2. Change your jaas.conf file to the following code:

KafkaClient { org.apache.kafka.common.security.plain.PlainLoginModule required serviceName="kafka" username="<your username>" password="<your password>"; };

  1. Add the following line to your consumer and producer properties:
    sasl.mechanism=PLAIN

Am I missing something here? It seems like the instructions say I don't need this module anymore, but I can't get it to work without it.


Solution

  • the docs are correct, though when using Liberty you define a in server.xml rather than a jaas.comf file.

    please take a look at our updated Liberty sample using the 0.10.x client

    https://github.com/ibm-messaging/message-hub-samples/tree/master/kafka-java-liberty-sample

    that sample does no longer include the deprecated messagehub login.jar