Previous Next JavaScript must be enabled to correctly display this content

## 9.7 Host Notifications

In order to listen to any Host events and trigger subsequent alerts in OBAPI for the same, please follow the below steps as part of extensibility:

Out-of-Box Notification Alert Support:

Update the output of the following script:

`SELECT * FROM digx_fw_config_all_b WHERE prop_id LIKE 'structure-createdAndAuthorized@%' AND category_id='KAFKA_CONFIG';`

New Notification Alert Support:

1. Get the Avro schema format for the notification to be consumed from the host. Ensure that the deserialized objects based on the Avro are present in the class-path.
2. Create a new consumer class that implements the IKafkaConsumable interface. Consumers implementing this interface will always consume messages from Kafka topics.

   Override Methods:

   - topicName(): Override this method to specify the name of the topic the consumer should listen to. Returns String.

     Example: structure-createdAndAuthorized

   - consumerGroup(): Override this method to specify the consumer group name. Returns String.
   - enableSeparateConsumerGroupsPerServer():
     1. When true, each instance of the consumer on each server creates its own consumer group.
     2. When false, all instances of this consumer across all servers share the same consumer group. Default is false.
   - run(): Responsible for initiating the message consumption process. Within this method, the consume method is called with an instance of IMessageProcessor (created as part of point 4) to handle the processing of each consumed message.
   - OOTB Reference: com.ofss.digx.kafka.liquiditymanagement.consumer.structure.StructureMessageConsumer
3. Create a file named com.ofss.digx.infra.events.kafka.consumer.IConsumer in resources/META-INF/services and provide the entry for the consumer class.
4. Create a new class implementing com.ofss.digx.infra.events.processor.IMessageProcessor for writing business logic. This class will be used from the consumer and listener classes and should be included in the service jar of the module.

   Override Methods:

   - process(K key, V data): Processes messages from the consumer. The out-of-box host alert service (Eg: com.ofss.digx.app.liquiditymanagement.service.hostalerts.HostAlertService) should be invoked from this method.

     key: The key object associated with the message.

     data: The data to be processed

     OOTB Reference: com.ofss.digx.app.liquiditymanagement.processor.structure.StructureMessageProcessor

5. Kafka consumer configurations can be maintained in `DIGX_FW_CONFIG_ALL_B` with category_id set to `KAFKA_CONFIG`. For configurations specific to a topic, prop_id can be specified as `TOPIC_NAME@CONFIGURATION`.

   Example: structure-createdAndAuthorized@bootstrap.servers

6. Configure a subscription based OBAPI alert specific for the new notification configured. Post maintaining subscription for the new OBAPI alert, subscribed users will receive OBAPI alerts specific to the notification.

Parent topic: Liquidity Management