cancel
Showing results for 
Search instead for 
Did you mean: 

Intoroduce delay between message processing in PI 7.11

Former Member
0 Kudos

Hello,

Scenario is: File -> PI -> IDoc

Is there a simple/light weight way to introduce a delay (about 10 min) between any two messages in the IE/mapping that are received simultaneously by a File Sender communication channel and converted to IDocs.

The BDC session that processes these IDocs is unable to handle 2 of them at once...

Thanks in advance,

Mustafa

Accepted Solutions (1)

Accepted Solutions (1)

Satyagadadas
Active Participant
0 Kudos

HI,

Maintain QOS in sender communication channel as Exactly Once in Order, It should resolve the requirement.

Please let us know if it works.

Thanks,

Satya.

Answers (1)

Answers (1)

Former Member
0 Kudos

Without BPM involvement, you can also introduce a UDF wich use Java Sleep() fucntion, which map to the target parent node,

this way, the mapping step will be hold whatever you specified. Combine this with EOIO option.

Regards

Liang

Edited by: Liang Ji on Oct 4, 2010 10:02 PM

Former Member
0 Kudos

Hi Liang,

I tried this... but the Messages don't seem to wait... - it's mapped to the parent target node

String rc = "";

try

{

Thread.sleep(min);

}catch (InterruptedException ie) {

rc = ie.getMessage();

}

return rc;

Is there a special way to implement 'wait' in MM ?

Mustafa

Former Member
0 Kudos

Hi, Mustafa:

I did similar scenario, you can reference my code,

My requirements is that any messages received after 9:00pm will be hold until 12:00am to process.

Liang


public String CalendarDelay(String a,Container container){
 // get the supported ids for GMT-05:00 (Pacific Standard Time)
 String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000);
 // if no ids were returned, something is wrong. get out.
 if (ids.length == 0)
     System.exit(0);

//create a Pacific Standard Time time zone
 SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]);
 // set up rules for daylight savings time
 pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
 pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);

 // create a GregorianCalendar with the Pacific Daylight time zone
 // and the current date and time
 Calendar calendar = new GregorianCalendar(pdt);
 Date trialTime = new Date();
 calendar.setTime(trialTime);

//currYear = Integer.toString(calendar.get(Calendar.YEAR));
//currMonth =  Integer.toString(calendar.get(Calendar.MONTH));
//currDate = Integer.toString(calendar.get(Calendar.DATE));

int currYear = calendar.get(Calendar.YEAR);
int currMonth =  calendar.get(Calendar.MONTH);
int currDate = calendar.get(Calendar.DATE);

 Calendar StartCalendar = new GregorianCalendar(pdt);
 Calendar EndCalendar = new GregorianCalendar(pdt);

StartCalendar.set(currYear, currMonth, currDate, 17, 30, 0);
EndCalendar.set(currYear, currMonth, currDate, 23, 59, 59);

long startTime = StartCalendar.getTimeInMillis(); 
long endTime = EndCalendar.getTimeInMillis();
long currTime = calendar.getTimeInMillis();

if ((currTime >= startTime) && (currTime <= endTime)){
//return "Current time fall into the range !";
  try
      {
        //Thread.sleep(1000*60*10);   //delay 10 min
         Thread.sleep(endTime - currTime);  
            
            }catch (InterruptedException ie)
            {
        System.out.println(ie.getMessage());
            }   
return a;
}
else
return a;

}

Former Member
0 Kudos

Liang's suggestion works partly.... i.e. when you introduce 'wait' in MM - then each/every message coming thru gets delayed.... - this code in my opinion is unnecessary as you can mark the File Channel as "Automatic Control" under RWB-Adapter Monitoring and then add an entry on "Availaibity Times" when the Channel is to be temporarily stopped/inactive so nothing processes during that time.

The easiest way I found to interject a delay between any two consequent messages is thru the use - OS command -> /usr/bin/sleep <secs> on the "Run OS command After Message processing" attribute

Thanks all for valuable input on this one !

Mustafa

Former Member
0 Kudos

I have the same issue... can u pls help me..

I tried using the script but the message mapping and the rcv comm channel dont seem to wait ne longer..

Former Member
0 Kudos

Use - OS command -> /usr/bin/sleep <secs> on the "Run OS command After Message processing" attribute