Set Up Store-and-Forward System

Implementing MQTT in Ignition: Video 12

4 min video  /  5 minute read
 

< Previous Video

Travis Cox shows how to set up the store-and-forward system in both the MQTT Engine Module and the MQTT Transmission Module. Store-and-forward is very critical to applications because if you lose connection to either side, you lose data. This demo is a pure MQTT solution, meaning it will work with third-party edge nodes or applications. Travis also shows how to buffer data locally when a connection is down and bring that data back to the historian once the connection is restored.


Video Transcript: 

Travis: In this session, we're going to show how to set up the Store-and-Forward System in both the MQTT Transmission and Engine Modules. But keep in mind that the Store-and-Forward I'm about to show is a pure MQTT solution. So we could be using third-party Edge Nodes or third-party applications, and it will all work exactly the same way. Store-and-Forward is critical in our applications because if we lose connection on either side, we could potentially lose data, and we don't want that.

In the case here, we're going to show how we can buffer that data locally when that connection's down; when the connection is restored, we could take that buffer data and bring it up and inject it into the Historian. So I'm using the MQTT Transmission Module on the edge side, I'm publishing data up to a server, then I have the Engine Module here that's subscribing from those tags. So in the Designer, we're seeing those tags on the MQTT Engine side, we have them configured to use Ignition's Tag Historian, log into a database, and right now we can see the last couple of minutes in a trend. Everything's working good, but the Store-and-Forward system right now is not turned on, so if we're to lose connection, I would see a gap in my data.

So, the first thing we need to do to enable this is to first go to the MQTT Transmission Module and turn this buffer on, and for that we we've got to go to the Ignition Gateway configuration page and come down to the MQTT Transmission history area. By default, we add an in-memory store but it is disabled, so we have to go over here and edit that setting and enable it so we can have the in-memory store working. Once we have that enabled, we then need to go to our Transmitters under the settings area, the Transmitters' tab, to use that in-memory store. So we're going to go ahead, edit this tag's transmitter, come down to the bottom and we're going to specify the Default In-memory Store here, and we're going to save our changes. So now the Transmission side is using that in-memory store, so when we lose connection, we're going to buffer all the value changes locally.

The next thing we need to do is make sure the Engine Module is going to use that data and bring it into the Historian. And so for that, we've got to go over here to our MQTT Engine settings, and by default is this turned on for us. We can see the Store Historical Events is turned on, it's enabled, we're ready to go. So, that's just the default setting for it. So at this point, we can actually see all this working in action.

So I'm going to go back to my designer. Now, you'll note a little gap here 'cause I made that change to turn on the in-memory store. But if we were to lose connection to our MQTT server, and so I'm going to simulate that here by disabling the MQTT server, and so on the Engine side, you can see the bad quality that's happened (i.e., “bad quality” overlays have appeared next to the tags). And of course, that is where we're going to start seeing the gap. No data's coming in at this point. However, the edge side, the Transmission side is buffering those changes now. So, when we've enabled this connection again, that buffer data should come back, we should see that backfill here. We're going to make sure we bring that in the right order in the Historian so we can have that data come in.

So we're going to go ahead now and enable the MQTT server, and save our changes. And so at this point that is coming in, you could solve all that backfill that happened there of that data. So we didn't skip a beat here with all the history data that is there. It's a really important setting to turn on and to use.

Now, a couple of things to point out with this is that on the transmission side... Let's go back over here to our Settings, to our transmitters. I'm going to go edit this. There are some additional settings here. First and foremost, we're enabling history storage by default on every single tag that is coming in. We can override that on a per tag, we can enable or disable that if we need to, as well as we are not going to be flushing history in order synchronously before live data resumes, and this is really for... There's two different modes of Engine. We can inject that data into Historian directly, or we can replay those values on the tag itself. If I need to replay that, I need to basically flush that data in order, and so we have to tell the transmission side to go ahead and do that. And so we would turn this on. Then on the Engine side, we would go over there and uncheck this Store Historical Events so that we can update the tag itself with those values that are coming through.

So, very seldom that you wanna do this because you want that to go to the Historian, but there's some cases where you want to replay those values for alarming purposes, or for tag change scripts or whatever it might be, we have to enable those settings. But it's really simple to get this all up and running, and it's really powerful to have the Store-and-Forward in the system.

Posted on December 2, 2019