KafkaMessageBus v4.2.3 KafkaMessageBus.Examples.SampleMessageDataFactoryImplementation View Source

A set of functions that takes resource, action, and data as parameters and returns an instance of the appropriate message data struct. Each message data type will support a function new/1 that is a struct representation of the map data that it received. These new/1 functions do not alter or validate the data field values.

This is an example of a message data factory implementation. One of these must defined and wired into the validator through the config (see: test.config for an example).

Factory implementations will have n number of on_create/3 functions that take three parameters. The first parameter is the message data (data field form the kafka message structure) in the form of a map. The second parameter is the Kafka resource(s), and the third is the Kafka action. The factory will use the resource and action to map to a message data type. Each on_create function will call the associated message data type's new/1 function at the end of on_create.

At the end of each factory definition you should use UnrecognizedMessageDataType's on_create function. This is the default behavior for unrecognized message data types that are encountered on the bus.

Link to this section Summary

Link to this section Functions

Link to this function

on_create(data, resource, action) View Source