Search code examples
jitterbit

JitterBit Run Only One Instance of an Operation at a Time


I ran into an issue where I had long running JitterBit operations that were scheduled. I had them scheduled close together, since I needed to keep data flowing. But, when they would take longer than expected I would wind up with multiple instances of the operation set running at the same time. This was killing my performance.

I'll put the fix in the answer below.


Solution

  • To resolve this issue I added an additional Script Operation at the beginning of my operation set (with the schedule running on this operation). This script simply checks to see if one of the operations in this set is already running. If not, it starts the next operation. If there is anything running, it exists and waits till the next scheduled instance.

    This is a sample of my script. This one assumes that there were originally two operations in this operation set.

    <trans>
    $isInQueue=GetOperationQueue("<TAG>Operations/OperationToCheck01</TAG>");
    $isInQueue2=GetOperationQueue("<TAG>Operations/OperationToCheck02</TAG>");
    $isRunning=$isInQueue[0][1];
    $isRunning2=$isInQueue2[0][1];
    if(($isRunning==1 && $isRunning!=Null()) || ($isRunning2==1 && $isRunning2!=Null()),
      WriteToOperationLog("Skip for now: "+$isRunning+" / "+$isRunning2);,
      WriteToOperationLog("Nothign is Running - Starting Operation Chain.");
      RunOperation("<TAG>Operations/OperationToCheck01</TAG>");
    );
    </trans>