Shubham44
ServiceNow Employee
ServiceNow Employee

Producer Setup

Now let's talk about how to setup hermes messaging service which will connect to your own servicenow instance to act as a Kafka bus, well the steps are pretty straight-forward defined in the url below
https://docs.servicenow.com/bundle/utah-servicenow-platform/page/administer/hermes-messaging-service... 

 

Once you follow these setups, the folder for hermes will look like this it will have the keystore file and the private key.

Shubham44_0-1681643773247.png

 

Once you are done with this . Create a test flow using kafka stream connect to trigger messages from Servicenow  acting as a producer to the consumer instance

 

All you need to add is the custom action with the kafka producer step and the trigger can be of your own choice . For e.g. in the video above i am using trigger of incident creation. 

Shubham44_1-1681643950550.png

 

After the action is created , please add that to the flow.

 

Consumer setup

  1. Download and install Apache Kafka

     

  2. Once the download is done , open the config/consumer.properties file and make the below changes
    group.id=test-consumer-group
    
    # What to do when there is no initial offset in Kafka or if the current
    # offset does not exist any more on the server: latest, earliest, none
    #auto.offset.reset=
    security.protocol=SSL
    
    ssl.truststore.password=####
    
    ssl.truststore.location=/Users/shubham.mittal/Documents/hermeskafka/hermesQuickStart/hermestruststore.p12
    
    
    ssl.truststore.type=PKCS12
    
    ssl.keystore.password=#####
    
    ssl.keystore.location=/Users/shubham.mittal/Documents/hermeskafka/hermesQuickStart/hermesdemoKafkaKeystore.p12
    
    ssl.keystore.type=PKCS12
    ssl.key.password=####

Add the truststore and the key password that you have defined while setting the hermes messaging service.

 

Now let's also do the same configuration in the config/producer.properties to act your local kafka as a producer as well.

the cli commands to start the local kafka as a consumer is 

 

./bin/kafka-console-consumer.sh --consumer.config ./config/consumer.properties --topic snc.<instance_name>.<namespace>.sn_<app_id>.<topic_name> --group snc.<instance_name>.<consumer_group_id> --from-beginning --bootstrap-server <instance_name>.service-now.com:4100,<instance_name>.service-now.com:4101,<instance_name>.service-now.com:4102,<instance_name>.service-now.com:4103

 

and to act as a producer is

./bin/kafka-console-producer.sh --topic snc.<instance_name>.<namespace>.sn_<app_id>.<topic_name> --producer.config ./config/producer.properties --bootstrap-server <instance_name>.service-now.com:4000,<instance_name>.service-now.com:4001,<instance_name>.service-now.com:4002,<instance_name>.service-now.com:4003

the sample flow to consume messages is

Shubham44_3-1681645054903.png

 

 

#hermesmessaging #kafkastreamconnect

1 Comment