Development

Setting up Scheduler for Auto Triggering of Applications in IIB

If you are required to trigger applications at a certain time of day to meet business needs, it’s not necessary to deploy the application at that particular time or to manually trigger it to begin the processing of messages.

Problem Statement

To schedule automatic triggering of application on a daily basis at a stipulated time (5:30am).

Solution

We can make use of the IBM Timeout Notification node managed by IBM Timeout Control node.

Message Flow Design

The above image represents the actual flow design.

The list of properties, which need configuration on the node level, are as follows:

Step 1 : Timeout Notify_Auto

This node is responsible for triggering the Message Flow on a daily basis and acts as the start point of the message flow. The first trigger happens for the Application deployment. Triggering takes place for every Integration Node/Integration Server restart. Thereafter timeout interval set on the node controls the next trigger.

Properties to set:

1) Operation Mode – Automatic

2) Timeout Interval – 86400 secs (24 hours in seconds)

Step 2 : Creating Timeout Message

The next step is to create a TimeOut Request message which for use in the TimeOut Control Node to control the processing of the message flow at the stipulated time. In our case it is 05:30am.

Code to construct the TimeOut Request Message:

Date now = new Date();

String sCurTimeStamp = new SimpleDateFormat(“HH:mm:ss”).format(now);

String sTriggerHistoryTime = “05:30:00”; //Hardcoded for easier understanding

Calendar cal = Calendar.getInstance();

cal.setTime(now);

cal.add(Calendar.DAY_OF_YEAR, 1);

Date tomorrow = cal.getTime();

// Generating Next date from Current date

String nextdate = new SimpleDateFormat(“yyyy-MM-dd”).format(tomorrow);

Covid 19
COVID-19: Digital Insights For Enterprise Action

Access Perficient’s latest insights into how you can leverage digital technologies to not only respond to the pandemic, but drive your operations forward and deliver experiences your customers need.

Get Informed

MbElement root = outMessage.getRootElement();

// Creating MQMD Headers

MbElement mqmd = root.createElementAsLastChild(“MQHMD”);

mqmd.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,”Format”,”MQSTR “);

mqmd.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,”Version”,2);

mqmd.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,”MsgType”,8);

// Creating Request Message

MbElement outBody = root.createElementAsLastChild(“XMLNSC”);

MbElement timeOutRequest = outBody.createElementAsLastChild(MbXMLNSC.FOLDER,”TimeoutRequest”,null);

// Setting Unique Identifier for use in TimeOut Control and TimeOut Notify_Controlled

timeOutRequest.createElementAsLastChild(MbXMLNSC.FIELD,”Identifier”,”startTime”);

timeOutRequest.createElementAsLastChild(MbXMLNSC.FIELD,”Action”,”SET”);

// Default value for startdate set to TODAY for current day

timeOutRequest.createElementAsLastChild(MbXMLNSC.FIELD,”StartDate”,”TODAY”);

// Setting StartTime=5.30am

timeOutRequest.createElementAsLastChild(MbXMLNSC.FIELD,”StartTime”,sTriggerHistoryTime);

// Setting Count to 1 and Interval to 0 for processing of Message only once a day

timeOutRequest.createElementAsLastChild(MbXMLNSC.FIELD,”Count”,”1″);

timeOutRequest.createElementAsLastChild(MbXMLNSC.FIELD,”Interval”,”0″);

timeOutRequest.createElementAsLastChild(MbXMLNSC.FIELD,”IgnoreMissed”,”TRUE”);

timeOutRequest.createElementAsLastChild(MbXMLNSC.FIELD,”AllowOverwrite”,”TRUE”);

// Comparing Current Time with Trigger Time (To ensure request message creation for every day’s processing)

if (sCurTimeStamp.compareTo(sTriggerHistoryTime) > 0) {

timeOutRequest.getFirstElementByPath(“StartDate”).setValue(nextdate);

}

Step 3 : TimeOut Control Node

This node takes the timeout request message as input and transfers control to the TimeOut Notify_Controlled node once the specified time has reached where the actual business functionality starts.

Properties to set:

1) Unique Identifier – Set the same unique identifier set in the “Identifier” field of request message.

2) Request Location – Point to the location of request message (InputRoot.XMLNSC.TimeoutRequest)

 Step 4 : Timeout Notify_Controlled node

This node becomes the first node of the actual business processing for the message flow once the stipulated time has reached.

Properties to set:

1) Unique Identifier – Set the same unique identifier set in the “Identifier” field of request message and in TimeOut Control Node.

2) Operation Mode – Controlled

 Report for the Solution suggested

04/26/2016 05:30:00.180 INFO  [SchedulerLog] [TimingLog] 2.0,2016-04-26T05:30:00.180Z, 7900a376-d7df-4616-9d49-2229e6a6666f,SchedulerLog

04/27/2016 05:30:00.192 INFO  [SchedulerLog] [TimingLog] 2.0,2016-04-27T05:30:00.192Z, 16ecca2a-48ff-4c46-8fe7-b7f70a9a75da,SchedulerLog

About the Author

More from this Author

Thoughts on “Setting up Scheduler for Auto Triggering of Applications in IIB”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up
Categories