Event Dispatcher

Event Dispatcher

The event dispatcher is responsible for receiving the events generated in the device and sending them through the available connectors.

The interface defining the service is the EventDispatcher interface and the main method is the publish method that receives an event:

public interface EventDispatcher {
    void publish(Event event);
}

Events objects are explained in the Events page.

OpenGate Event Dispatcher

The OpenGate Event Dispatcher publishes the received events through an OpenGate connector with the OpenGate IOT JSON format.

The publish method use the proper serializer to serialize the received event to the configured content-type and send it to the active OpenGate Connector.

Dependencies
  • Serializers: Any needed implementation of Serializer Service that the dispatcher will need to de/serialize the payloads.
  • Device Info Provider: Needed to know the Device Id of the device that are running the Agent and the API Key to access to OpenGate.
  • OpenGate Connector: Needed to send data and respond to requests of OpenGate.
Configuration

The Event Dispatcher can be configured with the following global properties:

  • reducedOutput: Use a reduced IOT format, removing all optional fields, to decrease the bandwidth consumed. The default value is false
  • eventContentType: Content-type of the published events. The default content-type format is JSON.

Using a decorator pattern, the Event Collector allows to store the events of some configured datastreams to send multiple datapoints in the same message at a configured period of time. Each datastream is configured in a line in the configuration file with the following format:

datastreamId;deviceId=initialDelay;period

The configuration is built with the properties:

  • datastreamId: Datastream identifier configured.
  • deviceId: Device identifier configured. If not set, the current configuration is applied to all devices. Optional
  • initialDelay: First time the collected events are sent. Optional
  • period: Period in which the collected events are sent. May be 0 to configure a datastream that must be sent just one time when ODA starts.

An example of a valid configuration may be:

reducedOutput=true                  # Use reduce output
eventContentType=JSON               # Use JSON format content-type
device.software=30;0                # Send all devices software 30 seconds after start-up and do not sending again
device.temperature.value=60         # Send all devices temperatures every 60 seconds
current;sectionalizer123=30;300     # Send the sectionalizer123 current 30 seconds after start-up and every 5 minutes.