You can modify the Message Routing sample ESQL so that you can use it in other message flows with very few changes.
The cache is currently refreshed when a refresh message is sent to the ROUTING.REFRESH queue.
Other criteria can be used to decide when to refresh the cache, for example:
To change the criterion, edit the following location in the ESQL:
To change the refresh criteria to use a time period of 60 seconds:
IF CacheFile.LastUpDate is not null and (CURRENT_TIMESTAMP - CacheFile.LastUpDate) second < INTERVAL '60' SECOND THEN
IF CacheFile.Valid is not null THENto be the same as in the previous step
SET CacheFile.valid = true;to
SET CacheFile.LastUpDate = CURRENT_TIMESTAMP;
Currently the sample chooses which record to propagate by setting the record selection expression. It might be the case that each time a message is sent you want to retrieve the next record in the file. This action can be achieved by setting the offset.
You can use the offset property in the following way:
declare cache SHARED ROW;
SET OutputLocalEnvironment = InputLocalEnvironment; IF (cache.file.offset > 0) THEN SET OutputLocalEnvironment.Destination.File.Offset = cache.file.offset; ELSE SET OutputLocalEnvironment.Destination.File.Offset = 0; END IF;Set the Compute mode property to LocalEnvironment.
SET OutputLocalEnvironment = InputLocalEnvironment;Set the Compute mode property to LocalEnvironment.
SET cache.file.offset = OutputLocalEnvironment.File.Read.NextRecordOffset;
The sample shows how to route a message to a particular queue. Another usage might be routing to a label. To implement this use the following instructions:
You can replace the MQOutput nodes with other types of output node. For example, use a flow using a RouteToLabel node: