Skip to main content

Sample Code Snippet

AttunityMessageDecoder messageDecoder – Previously defined and initialized with a proper schema locator.

KafkaConsumer consumer – Previously defined and initialized, and subscribed to some Kafka topic(s).

The code follows the following flow:

  1. A Kafka consumer polls for messages. After the consumer has read the messages, each message is sent to the message decoder for decoding and message type verification.
  2. If the message is of type AttunityMetadataMessage, a user-defined handleMetadataMessage method is called with the proper casting on the message.
  3. If the message is of type AttunityDataMessage, a user-defined handleDataMessage method is called with the proper casting.
  4. If an unknown message class is returned (i.e. the SDK supports more class types than the customer's code), an appropriate message is sent.
  5. If decoding failed, an appropriate message is also sent, together with the exception details from the decoder.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!