IBM Sterling B2B: Configuring SB2Bi to use Kafka: Difference between revisions

From Wiki
 
(16 intermediate revisions by the same user not shown)
Line 9: Line 9:




= Create a Business Process to put a file in Kafka =
= Put and Get Files from Kafka =


<process name="Demo_Kafka_Producer">
* [[IBM Sterling B2B: Create a Business Process to put a file in Kafka]]
  <sequence>
 
    <operation name="Kafka Client Begin Session Service">
* [https://github.com/ebasso/sterling-b2b-samples/tree/master/business-process/using-kafka | Create a Business Process to Consume (get) a file from Kafka]
        <participant name='KafkaBeginSessionService'/>
 
        <output message="xout">
= Create a Custom Protocol in SFG to use with Kafka =
          <assign to='Action'>put</assign>
 
          <assign to='BootStrapServers'>'''localhost:29092'''</assign>
* https://github.com/ebasso/sterling-b2b-samples/tree/master/filegateway-scenarios/route-via-kafka
          <assign to='KafkaClientAdapter'>'''KafkaClientAdapter'''</assign>
 
          <assign to='SecurityAction'>'''PLAINTEXT'''</assign>
 
          <assign to='GroupId'>'''demo-kafka-producer-001'''</assign>
= Configure Kafka Consumer Streams Adapter =
          <assign to='ProducerConfig'>buffer.memory=102400;compression.type=gzip</assign>
 
          <assign to='.' from='PrimaryDocument'/>
The Kafka Consumer Streams Adapter connects with a Kafka queue to pull messages continuously.
        </output>
 
        <input message="xin">
* '''Important''': key must be the filename of file.
          <assign to="KafkaBeginSessionServiceResults" from="*"/>
 
        </input>
[[File:Sb2b-kdk-key-value.png]]
    </operation>
 
 
    <operation name="Kafka Client Producer Service">
== Configuring the Adapter ==
        <participant name="KafkaProducerService"/>
 
        <output message="xout">
1) To Create a new Adapter, open Dashboard > Deployment > Configuration
          <assign to="SessionID" from="//KafkaBeginSessionServiceResults/SessionID/text()"/>
 
          <assign to="KafkaClientAdapter" from="//KafkaBeginSessionServiceResults/KafkaClientAdapter/text()"/>
2) Search for Kafka Consumer Stream Service, and click '''Next'''
          <assign to='Topic'>'''sb2b-kfk-outbound'''</assign>
 
          <assign to='.' from='PrimaryDocument'/>
[[File:sb2b-kafka-setup-01.png]]
        </output>
 
         <input message="xin">
3) Define a name and description, and click '''Next'''
          <assign to="." from="*"/>
 
        </input>
[[File:sb2b-kafka-setup-02.png]]
    </operation>
 
4) Define Bootstrap Server and Topic, and click '''Next'''
    <operation name="Kafka Client End Session Service">
 
        <participant name='KafkaEndSessionService'/>
[[File:sb2b-kafka-setup-03.png]]
         <output message="xout">
 
          <assign to="SessionID" from="//KafkaBeginSessionServiceResults/SessionID/text()"/>
5) In Deserializer, click '''Next'''
          <assign to="KafkaClientAdapter" from="//KafkaBeginSessionServiceResults/KafkaClientAdapter/text()"/>
 
          <assign to='Action'>put</assign>
[[File:sb2b-kafka-setup-04.png]]
        </output>
 
        <input message="xin">
6) In properties, click '''Next'''
          <assign to="." from="*"/>
 
        </input>
[[File:sb2b-kafka-setup-05.png]]
    </operation>
 
  </sequence>
7) Choose to write the file to a Mailbox, and click '''Next'''
 
[[File:sb2b-kafka-setup-06.png]]
 
8) Define a Mailbox to write the file , and click '''Next'''
 
[[File:sb2b-kafka-setup-07.png]]
 
9) Click '''Next''' and '''Finish'''
 
Now this adapter will use BP '''KafkaStreamServiceMailbox''' to monitor topics and write to mailboxes.
 
<process name="KafkaStreamServiceMailbox">
  <sequence>
    <operation name="SetUserContext">
      <participant name="SetUserTokenServiceKafka"/>
      <output message="xin">
        <assign to="USER_TOKEN" from="//MAILBOXUSER/text()"/>
      </output>
      <input message="xout">
        <assign to="." from="*"/>
      </input>
    </operation>
    <operation name="Mailbox Add Service">
      <participant name="MailboxAdd"/>
      <output message="MailboxAddServiceTypeInputMessage">
        <assign to="." from="*"/>
        <assign to="Extractable">Yes</assign>
        <assign to="MailboxPath" from="//MAILBOXPATH/text()"/>
         <assign to="DocumentId" from="/PrimaryDocument/@SCIObjectID"/>
         <assign to="MessageName" from="//Files/Documents/Document/Name/text()"/>
        <assign to="UseGlobalMailboxes" from="//GLOBALMAILBOX/text()"/>
      </output>
      <input message="inmsg">
        <assign to="MailboxAddResult" from="*"/>
      </input>
    </operation>
  </sequence>
  </process>
  </process>
= Check Topics and messages =
To check Topics and messages i using Kowl
[[File: sb2b-kfk-inbound-01.png]]


= Ver também =
= Ver também =

Latest revision as of 20:02, 1 November 2023

1) Deploy Kafka: Deploy Kafka as Container

2) Using Kwol create topics

  • sb2b-kfk-inbound
  • sb2b-kfk-outbound


Put and Get Files from Kafka

Create a Custom Protocol in SFG to use with Kafka


Configure Kafka Consumer Streams Adapter

The Kafka Consumer Streams Adapter connects with a Kafka queue to pull messages continuously.

  • Important: key must be the filename of file.


Configuring the Adapter

1) To Create a new Adapter, open Dashboard > Deployment > Configuration

2) Search for Kafka Consumer Stream Service, and click Next

3) Define a name and description, and click Next

4) Define Bootstrap Server and Topic, and click Next

5) In Deserializer, click Next

6) In properties, click Next

7) Choose to write the file to a Mailbox, and click Next

8) Define a Mailbox to write the file , and click Next

9) Click Next and Finish

Now this adapter will use BP KafkaStreamServiceMailbox to monitor topics and write to mailboxes.

<process name="KafkaStreamServiceMailbox">
 <sequence>
   <operation name="SetUserContext">
     <participant name="SetUserTokenServiceKafka"/>
     <output message="xin">
       <assign to="USER_TOKEN" from="//MAILBOXUSER/text()"/>
     </output>
     <input message="xout">
       <assign to="." from="*"/>
     </input>
   </operation>
   <operation name="Mailbox Add Service">
     <participant name="MailboxAdd"/>
     <output message="MailboxAddServiceTypeInputMessage">
       <assign to="." from="*"/>
       <assign to="Extractable">Yes</assign>
       <assign to="MailboxPath" from="//MAILBOXPATH/text()"/>
       <assign to="DocumentId" from="/PrimaryDocument/@SCIObjectID"/>
       <assign to="MessageName" from="//Files/Documents/Document/Name/text()"/>
       <assign to="UseGlobalMailboxes" from="//GLOBALMAILBOX/text()"/>
     </output>
     <input message="inmsg">
       <assign to="MailboxAddResult" from="*"/>
     </input>
   </operation>
 </sequence>
</process>

Check Topics and messages

To check Topics and messages i using Kowl

Ver também