IBM Message Hub is a fully-managed Apache Kafka service running on the IBM Bluemix PaaS. It exposes a native Kafka interface, so Lagom services can communicate with it using the standard Lagom Message Broker API.
This project demonstrates a simple service that integrates with the IBM Message Hub Kafka Liberty sample application. The source code demonstrates how to write a Lagom service that can both consume messages produced by the Liberty sample application, and produce messages that can be consumed by it. You can run the service in a local development environment, a local Kubernetes cluster created using Minikube, or in the cloud using IBM Bluemix Container Service.
To build and run this example, you need:
- git
- Java SE 8 JDK
- Maven 3.2.1+ to build and run the Lagom project (3.5.0 recommended)
- Message Hub Service Instance provisioned in IBM Bluemix — Note: the Liberty sample application requires the Message Hub Service Instance to have the name: "message-hub-service".
- IBM Message Hub Kafka Liberty sample application deployed to Bluemix
Follow these steps to get a copy of the Message Hub credentials that are needed for the Lagom service to authenticate with Message Hub.
- Log in to the IBM Bluemix console.
- Navigate to the Message Hub service you have created.
- Navigate to "Service credentials".
- Create new credentials if needed (no special parameters are required).
- Click "View credentials".
- Copy the following credential values to use in the Lagom service:
"kafka_brokers_sasl"
— Note: the Lagom service requires the list of brokers to be formatted as a single-line, comma-separated list of hostname:port pairs. For example:"host1:port1,host2:port2"
."user"
"password"
Follow these steps to get a local copy of this project and configure it with the Message Hub credentials you saved in the previous step.
-
Open a command line shell and clone this repository:
git clone https://github.com/lagom/ibm-integration-examples.git
-
Change into the root directory for this example:
cd ibm-integration-examples/lagom-message-hub-liberty-integration-example
-
Open the
message-hub-liberty-integration-impl/src/main/resources/message-hub.conf
file in a text editor and fill in the empty values of thebrokers
,user
andpassword
properties from the credentials retrieved above.Note: Be sure not to commit this file with your credentials in it.
Now that the project has been downloaded and configured, you can proceed to running it in any of these three ways: