Tutorial
Integrating Kafka with Sterling Order Management
Guide to integrate Apache Kafka with IBM Sterling Order Management system, covering installation, configuration, and both synchronous and asynchronous messaging implementationsIn today’s fast-paced digital landscape, integrating systems and ensuring seamless data flow is essential for business success. This tutorial focuses on integrating Apache Kafka with IBM Sterling Order Management System (OMS), providing a comprehensive guide for developers and system integrators. By leveraging Kafka’s robust messaging capabilities, businesses can enhance their order management processes, improve operational efficiency, and gain real-time insights into their data streams.
This tutorial walks you through the installation and configuration of Apache Kafka and the implementation of both synchronous and asynchronous messaging flows within the Sterling OMS. You will learn how to set up Kafka topics, manage message handling, and utilize the Kafka Transport Component to interact with data streams effortlessly. Whether you are looking to streamline your order fulfillment processes or seeking to enhance your system integration strategies, this guide will equip you with the necessary skills and knowledge to effectively utilize the power of Kafka in your OMS environment.
Installing OpenJDK for Apache Kafka runtime
Apache Kafka is a Java-based application that requires a JDK. You can use any supported version of JDK. In this tutorial, we will use OpenJDK, available in the Linux yum repository.
If you plan to install Kafka as a non-root user, switch to root and run the following command:
yum install -y javaVerify the Java installation by running:
java -versionYou should see an output similar to this:
openjdk version "11.0.20.1" 2023-08-24 LTS OpenJDK Runtime Environment (Red_Hat-11.0.20.1.1-2) (build 11.0.20.1+1-LTS) OpenJDK 64-Bit Server VM (Red_Hat-11.0.20.1.1-2) (build 11.0.20.1+1-LTS, mixed mode, sharing)After confirming the installation, exit from the root user.
Installing Apache Kafka
Download the required version of Apache Kafka from Kafka download or use the following
curlcommand:curl -o kafka.tgz https://downloads.apache.org/kafka/3.8.0/kafka_2.13-3.8.0.tgzIn this example, the file is downloaded to
/home/admin.Extract the downloaded file:
tar -xvf kafka.tgzRename the extracted directory for simplicity:
mv kafka_2.13-3.8.0 kafkaNavigate to the Kafka directory:
cd /home/admin/kafkaStart Zookeeper by navigating to the
bindirectory and running the following command:nohup ./zookeeper-server-start.sh /home/admin/kafka/config/zookeeper.properties > /home/admin/kafka/zookeeper.log & disownCheck the log file (
/home/admin/kafka/zookeeper.log) to ensure Zookeeper is running. By default, Zookeeper runs on port 2181. Make sure the port is accessible.Start the Kafka server by running:
nohup ./kafka-server-start.sh /home/admin/kafka/config/server.properties > /home/admin/kafka/server.log & disownVerify that the Kafka server is running by checking the log file (
/home/admin/kafka/server.log). The Kafka server runs on port 9092 by default. Ensure this port is also accessible.
Creating a Kafka topic
To create a Kafka topic, run the following command:
./kafka-topics.sh --create --topic OMSTOPIC0 --bootstrap-server localhost:9092
If the topic is successfully created, you will see the message:
Created topic OMSTOPIC0.
Testing the Kafka setup
To listen for incoming messages, navigate to
/home/admin/kafka/binand run the following command:./kafka-console-consumer.sh --bootstrap-server 9.30.211.227:9092 --topic OMTOPIC0Execute the following code to post a message. If the message is successfully received by the Kafka topic, it should appear in the console from the previous step:
package com.kafka; import java.io.IOException; import java.util.Properties; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; public class KafkaProducerApp { public static void main(String[] args) throws IOException { Properties props = new Properties(); props.put("bootstrap.servers", "9.30.211.227:9092"); props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); try { KafkaProducer<String, String> producer = new KafkaProducer<>(props); ProducerRecord<String, String> record = new ProducerRecord<>("OMTOPIC0", "sample message"); producer.send(record); producer.flush(); producer.close(); System.out.println("Message sent !!"); } catch (Exception e) { e.printStackTrace(); } } }
Configuring Sterling OMS to post messages to Kafka topic via a synchronous service
Starting from OMS Fix Pack v10 10.0.2309.0, Kafka client jars are bundled with the product. These can be found in the Sterling OMS jar/kafka directory. The following two jars are included as part of the Kafka component:
slf4j-api-1.7.21.jarkafka-clients-3.2.1.jar
Steps to configure Kafka component
Go to
Applications -> Application Platform -> Process Modelling. Click onOrder Fulfillment, then selectServices.Name the service
KafkaProducer.
Figure: Create a synchronous serviceDesign the flow to handle message posting, as depicted in the Kafka producer service (refer to figure below).
Figure: Kafka producer service
Kafka configuration options
You can configure Kafka in two ways:
Through a Configuration Group: Use pass-through properties under the
property vendorof Kafka by adding them in thecustomer_overrides.propertiesfile as key-value pairs. The syntax is:kafka.cgrp.<config_group_id>.producer.<config_key>=<config_value>For example, to set
bootstrap.serversfor a group calledmastergroup, use:kafka.cgrp.mastergroup.producer.bootstrap.servers=9.30.211.227:9092Set
mastergroupas the "Config Group Id" under the General tab.This kafka property can also be set using SMA Console using property management under kafka category.
Figure: Setting Kafka Property using SMA property managementDirectly in the Kafka producer component: Alternatively, the same properties can be configured directly in the Kafka producer component in Sterling Application Manager.
Note: If no Kafka configuration is provided either as a pass-through property or at the service level, Kafka will use its default configuration values. For more information on default values, refer to IBM Kafka Configuration Documentation
Setting up Kafka configuration:
Under the Kafka Configuration tab, set
bootstrap.serversto9.30.211.227:9092(refer to the Bootstrap configuration in figure below).
Figure: Bootstrap configuration.Ensure that
kafka-console-consumeris running on the Kafka server.
Posting a message via KafkaProducer service:
Use an API tester to call the
KafkaProducerservice with a message. If successfully posted, the message should appear in the Kafka console consumer.
Figure: Posting message to Kafka topicTo confirm, run the following command on the Kafka server:
./kafka-console-consumer.sh --bootstrap-server 9.30.211.227:9092 --topic OMTOPIC0You should see an output like:
[admin@labmachoine bin]$ ./kafka-console-consumer.sh --bootstrap-server 9.30.211.227:9092 --topic OMTOPIC0 <?xml version="1.0" encoding="UTF-8"?> <Items> <Item AdjustmentType="ABSOLUTE" ItemID="IBMItem1" ProductClass="Good" Quantity="1000" ShipNode="IBMStore1" SupplyType="ONHAND" UnitOfMeasure="EACH"/> </Items>
Event integration
The
KafkaProducerservice can now be used in other transactions, such as events.Implement the necessary event, mapping the service in the event configuration (see figure below).
Figure: Event configurationMap this event to the
ON_SUCCESSevent of thecreateOrderAPI.
Figure: ON_SUCCESS event of createOrder APIAfter making a
createOrderAPI call, verify that theON_SUCCESSevent message is posted to Kafka.
Configuring Sterling OMS to post messages to Kafka topic via an asynchronous flow
To configure Sterling Order Management System (OMS) to post messages to a Kafka topic via an asynchronous flow, follow these steps:
Create an asynchronous service with a JMS receiver.
Figure: Asynchronous service JMS receiver.Configure the integration server to handle the asynchronous flow.
Figure: Integration serverSet up exception handling to ensure the flow handles any errors during execution.
Figure: Exception settingsIn the flow, configure the system to invoke the
createOrderAPI call.
Figure: createOrder API callConfigure the Kafka topic where the messages will be posted.
Figure: Kafka configuration (Topic)Ensure that the correct Kafka host is configured for message posting.
Figure: Kafka configuration (Host)
Flow execution
The JMS Receiver on the Integration Server picks up the
createOrderXML fromDEV.QUEUE.1.It then calls the out-of-the-box (OOB)
createOrderAPI.On successful execution of the API, the output will be posted to the configured Kafka topic.
Summary
This tutorial provided comprehensive details on the OMS Sterling Kafka Transport Component, which enables interaction with Kafka data streams without the need for custom code. Application developers can expedite their API development by creating simple services instead of writing extensive custom code.
The tutorial covered:
- Installation steps for Apache Kafka
- Configuration of Kafka topics
- Implementation of both synchronous and asynchronous message handling
- Setting up integration servers to consume messages from queues and post them to topics
Currently, only outbound integration with Kafka is available. However, the Kafka Receiver component is in the pipeline and will soon enable reading messages from Kafka topics.