Collecting messages from different sources - Energy use case
neekrish 0600011NDE Visits (3044)
WebSphere Message Broker (WMB) to achieve this.
Use case or an example
We'll take an example from the energy and utilities industry... consider a temperature sensor and a humidity sensor. These are 2 different devices that send the value read. Let's say that we have a web service that calculates the heat index, which is a combination of these values. You can read about heat index here. This requires temperature and humidity of the same location to be collected together. At the enterprise level the data mostly in the form of messages will be arriving from various sources and locations at the same time. The flows designed can't wait for all the values to arrive from one location before processing the next.
A short answer to the problem is to use the collector node of WebSphere Message Broker.
The temperature sensor could be sending the values via a some wired or wireless interface and protocol to a computer, it could even be MQTT. If data is incoming on some other protocol, it can be converted to MQTT message. On the server side's we need a WebSphere MQ installation with WebSphere MQ Telemetry installed on it. It needs to be configured to listen to a port (say 1883) for messages from MQTT clients. The configuration is described here. The values for the temperature and humidity arrive as two different messages and we'll use the WebSphere Message Broker collector node to collect and group these messages.
The message format and topics
In this example here, let's use the client ID, topic and the message body of MQTT message. The topic of the message can be of a convenient format that contains sensor type and the client identifier. For example "Device/temp/DV1" can represent a temperature sensor having the client identifier DV1. Its important to choose the right topic string while designing solutions as most of the routing decisions in the WebSphere Message Broker can be done based on this. The value measured by the sensor will be embed in the message body.
Configuration on the WebSphere MQ
WebSphere MQ can convert the incoming MQTT message to a JMS message that can be consumed a JMSInput node of WebSphere Message Broker. It can also be consumed using a MQInput node.. If using the JMSInput node we need to define the correct topic string in the JNDI bindings.
Configuration on the WebSphere Message Broker
The JMSInput node can be used to read the incoming messages. Let's set some properties of the message. In this example, let's say the the message body has the value. Since the MQTT messages are converted to JMS message here, the value will be a BLOB message.
SET RECEIVED_CLIENT_ID = Sele
The received client ID is important in the next step when we use the collector node and as you can see the value is BLOB message and can parsed as shown above.
WebSphere Message Broker also enable conversion to MQ message from a JMS message and vice-versa using the JMS MQ Transform nodes. Now connect these to the collector node as shown below
The collector node needs a minimum of 2 input terminals in this case. The collection definition plays a important role. The correlation path needs to be set to "$Ro
If the collector node uses 2 queues "SYS
The output of the collector node can be connect to a compute node where we can read the values of the collection like this:
DECLARE TEMPERATURE CHARACTER Inpu
DECLARE HUMIDITY CHARACTER Inpu
You can read more about the collector node in the following links: