SK SKYVVA Documentation

3. How to use Agent Kafka adapter for Consumer?

Introduction

Agent Kafka adapter for consumer uses for reading data records from Topic, meaning that we do inbound from Kafka to salesforce. To use Agent Kafka for consumer, we need to configure the Agent control board, and we need to create an Agent Kafka adapter. In the adapter, we need to fill in a specific topic name and one broker to connect, and Kafka will automatically take care of pulling the data from the right broker to the salesforce. This tutorial will learn how to do Agent Kafka adapter for the consumer with file types CSV, XML, and JSON. Pre-require

1.How to configure a new agent control board.

2. How to work with Kafka Inbound Adapter?

A topic is a category/feed title to which records are stored and published. All Kafka records are organized into topics. In Kafka, we need to create different topics for different types of records. Example: We have three types of records such as CSV, XML, and JSON so we need to create different topics also like TestInboundCSVconsumerTopic, TestInboundXMLconsumerTopic and TestInboundJsonconsumerTopic.

${KAFKA_HOME}/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic -  Here's example.

After we create different topics, we can use the command line to see all the topics that we have in Kafka. -  here's the command line to see all the topics in Kafka. ${KAFKA_HOME}/bin/kafka-topics.sh --zookeeper localhost:2182 --list -  here's example.

Case 1: Create Inbound KAFKA Adapter for CSV format.

  1. Go to the new Agent control board and create a new Adapter Kafka for CSV data format inbound processing
  2. Here's adapter InboundCSV

  1. We can run or stop Kafka Inbound adapter in the Adapter Screen.

  1. Create message type for CSV Kafka inbound using below CSV data
[aux_code language="javascript" theme="tomorrow" title="" extra_classes=""] Account_ID,AccountNumber,Name,Billincity,BillingCountry,Description 11,100001,Test KAFKA Account1,#PP1,CAM1,Testing CSV Inbound 12,100002,Test KAFKA Account2,#PP2,CAM2,Testing CSV Inbound [/aux_code]
  1. Create Integration.
  2. Create Interface.

[su_box title="Note" box_color="#2a8af0" title_color="#000000"]Kafka supports only Synchronous Processing Mode [/su_box]

  1. Click the button start Adapter to start the route.

3. How to check the Caching New Agent control board We can check it for different Object names. To ensure that Integration, Interface, adapter, and mapping are in the catch. If we some properties that don't work in the catch, it will get an error.

4. How to set data to Kafka to send to salesforce? 

$KAFKA_HOME/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic TestInboundCSVconsumerTopic

  1. The format is given below for data for CSV.
[su_box title="Note" box_color="#2a8af0" title_color="#000000"]When we want to use CSV record, the format is need to have __SKYVVA__START_MESSAGE  AND __SKYVVA__END_MESSAGE   [/su_box] [aux_code language="javascript" theme="tomorrow" title="" extra_classes=""] __SKYVVA__START_MESSAGE Account_ID,AccountNumber,Name,Billincity,BillingCountry,Description 11,100001,Test KAFKA Account1,#PP1,CAM1,Testing CSV Inbound 12,100002,Test KAFKA Account2,#PP2,CAM2,Testing CSV Inbound 13,100003,Test KAFKA Account3,#PP3,CAM3,Testing CSV Inbound 14,100004,Test KAFKA Account4,#PP4,CAM4,Testing CSV Inbound 15,100005,Test KAFKA Account5,#PP5,CAM5,Testing CSV Inbound 16,100006,Test KAFKA Account6,#PP6,CAM6,Testing CSV Inbound __SKYVVA__END_MESSAGE [/aux_code]

Case 2: Create Inbound KAFKA Adapter for XML format.

  1. We need to create an XML adapter, Kafka.
Go to agent control board => click Adapter =>click Button new. ( we configuration like the case1 but choose filetype xml)

  1. Click the button start Adapter to start the route.

  1. Linked the adapter on Interface.
  2. Public message to the topic
$KAFKA_HOME/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic TestInboundXMLconsumerTopic

[su_box title="Note" box_color="#2a8af0" title_color="#000000"]When we want to use XML record,  we don't need to have Start and End message but we need to convert XML data in to one line. Also, make sure that Data and message Types are the same structure. [/su_box]

ppKhmerMeastest2@gmail.comManurothmappKhmerGoldentest2@gmail.comManurothgagappKhmerAudantest2@gmail.comPiAudanppKhmerko131test2@gmail.comManurothchita

Case 3: Create an Inbound KAFKA Adapter for JSON format.

  1. We need to create a Kafka adapter Type JSON.
Go to agent control board => click Adapter =>click Button new. ( we configuration like the case1 but choose filetype xml).

  1. Linked adapter with the Interface.

4.Public message to the topic. $KAFKA_HOME/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic RothJsonInbound [su_box title="Note" box_color="#2a8af0" title_color="#000000"]We need to convert Json data to single line. [/su_box]

Summary Agent Kafka Consumer uses reading data from Topic to Salesforce, which means we Send data from Topic in Kafka to Salesforce. In this adapter, we can do Inbound with CSV, XML, and JSON data records, but we need to make sure our Adapter is configurated to match the file type.

Open this article in the interactive viewer →