Leap Dispatch Channels

What are Dispatch Channels?

A <DispatchChannel> is a reusable channel that defines an output method for events processed by the Leap Event Framework. Once a dispatch channel is defined, it can be referenced from the <EventDispatcher> of any SystemEvent or Feature Event.

The purpose of each dispatcher, regardless of its definition details, is to publish an event to a specified location. By default, the Leap Event Framework has several built-in dispatch channels. Yet, new dispatchers are easy to add by creating a bean that extends from the AbstractDispatchChannel class and referencing the new bean in the dispatch channel configuration.

Types of Dispatchers

By default, Leap Event Framework implements four types of dispatchers. Others can be added as necessary. All of the dispatchers share the same XML structure, but, may contain different <ChannelConfiguration> JSON based on the dispatcher bean requirements.

1. Filestore Dispatcher

Writes events to a file on the local server. Most commonly this is used during development for logging and testing purposes. Event file logs in production servers can be problematic for resource management.

NameRequiredDefaultDescription
filepathY(String) Full path to the directory where the specific file will exist. Path must already exist on file system
filenameY(String) name and type of file to write. By default .txt is the file extension
Filestore ChannelConfiguration Options

2. Hazelcast Dispatcher

Writes events to either a Hazelcast Queue or Topic. These are in-memory data structures that can exist locally or via remote clusters. However, the IQueue and ITopic implementations use only a single Hazelcast instance and are not distributed the same way an IMap is. Additionally, extra steps are required in order to add persistence to these structures.

NameRequiredDefaultDescription
queueNameY(String) Name of the Queue hosted in the Hazelcast cluster
Hazelcast Queue ChannelConfiguration Options

3. HTTP Dispatcher

Once an event is generated, it can be sent via HTTP [POST] to any valid URL, remote or local. At this time, only regular HTTP(S) is supported, there are not configurations for embedding custom headers or Certificate details for 2-way SSL. If a request fails, it will be sent to the DispatchEventTracker table and retried based on your configured strategy.

NameRequiredDefaultDescription
restpathY(String) The full URL for the POST request sent when dispatching the event. The URL must also contain the specified port
HttpPost ChannelConfiguration Options

4. Kafka Dispatcher

Events can be published on a Kafka topic. By doing this, the events become available for further subscriptions by Leap Features or other applications. All messages are published with the KeyedMessage “reinvents”. This guarantees that the events with this key are sorted within a topics partition and maintain the order they were published. If this is not required, the KeyedMessage can be removed and events will be published to a topics partition in a round-robin fashion.

NameRequiredDefaultDescription
bootstrapserversY(String) URL and Port of the Kafka bootstrap server(s). Default port is 9092
isTenantAwareY(Boolean) Indicates whether multi-tenancy is enabled. If the Kafka instance is tenant aware, the events will be routed to a specific topic mentioned and also separated by the tenant.

Non-aware topic name: “test”
aware topic name: “test_tenant_site”
topicY(String) Name of the Kafka Topic to publish events
KafkaTopic ChannelConfiguration Options

Dispatcher Examples

<DispatchChanels>
   <DispatchChanel id="FILE_STORE" description="file store" isEnabled="true" processingWay="ASYNC">
      <ChanelImplementation fqcn="com.attunedlabs.eventframework.dispatcher.chanel.FileStoreDispatchChanel" beanRefid="fileStoreDispatcher" />
      <ChanelConfiguration>
         {
            "filepath":"C:\logs",
            "filename":"LogDispatchChanel.txt"
         }
      </ChanelConfiguration>
   </DispatchChanel>
</DispatchChanels>
<DispatchChanels>
<DispatchChanel id="HZ_CLUSTER" description="write to HZ Queue" isEnabled="true" processingWay="SYNC">
    <ChanelImplementation fqcn="com.attunedlabs.eventframework.dispatcher.chanel.HazelcastQueueDispatchChanel" beanRefid="hazelcastQueueDispatchChanel" />
    <ChanelConfiguration>
        {
            "queueName":"hzEvents"
        }
    </ChanelConfiguration>
</DispatchChanel>
</DispatchChanels>
<DispatchChanels>
<DispatchChanel id="REST_CLIENT" description="print rest client" isEnabled="true" processingWay="SYNC">
    <ChanelImplementation fqcn="com.attunedlabs.eventframework.dispatcher.chanel.RestClientPostDispatchChanel" beanRefid="restClientPostDispatchChanel" />
    <ChanelConfiguration>
        {
            "restpath":"http://localhost:8080/rest-webservices/webapi/restChanel"
        }
    </ChanelConfiguration>
</DispatchChanel>
</DispatchChanels>
<DispatchChanels>
<DispatchChanel id="Kafka_Topic" description="Kafka Topic" isEnabled="true" processingWay="ASYNC">
    <ChanelImplementation fqcn="com.attunedlabs.eventframework.dispatcher.chanel.KafkaTopicDispatchChannel" beanRefid="kafkaTopicDispatchChannel" />
    <ChanelConfiguration>
        {
            "bootstrapservers":"localhost:9092",
            "topic":"employee-topic",
	        "isTenantAware":false
        }
    </ChanelConfiguration>
</DispatchChanel>
</DispatchChanels>

Dispatch Channel Options

All of these options are shared by dispatch channels are they are all required

NameRequiredDefaultDescription
<DispatchChanel>Y(Element) Contains all of the details for a specific Dispatch Channel implementation
idY(String) Unique identifier for this channel. Must be unique across all dispatch channels. This will be referenced by EventDispatchers when publishing events
descriptionY(String) Plain-text documentation that describes the channel
isEnabledY(Boolean) Indicates whether or not the channel is available for use. Certain channels may be disabled depending on deployment circumstances
processingWayY(String) “SYNC” || “ASYNC” are the only two available options
<ChanelImplemetation>Y(Element) Contains bean details for the dispatcher. Child of <DispatchChanel>
fqcnY(String) The fully qualified class name of the bean to use when processing the event data for dispatch. Attribute of <ChanelImplementation>
beanRefidY(String) Unique beanReferenceId for the Framework. Attribute of <ChanelImplementation>
<ChanelConfiguration>Y(Element) Contains a JSON Object of key-value pairs that the dispatcher will use to configure itself. This object is different for each type of dispatcher. i.e. filestore, kafka, hazelcast, http
Updated on September 9, 2021

Was this article helpful?

Related Articles