Forum Discussion

nsohal's avatar
nsohal
Employee
7 years ago

Enable or disable a task

Contributed by @nsohal


This pipeline pattern enables or disables an existing task by using the SnapLogic Read and Update Snaps.

Configuration

  • The path to the task is passed to the SnapLogic Read Snap as a pipeline parameter.
  • The Mapper Snap uses the Boolean expression to enable or disable task.

Source: SnapLogic Read
Target: SnapLogic Task
Snaps used: SnapLogic Read, Mapper, SnapLogic Update

Downloads

enable or disable task.slp (4.1 KB)

2 Replies

  • nsmith's avatar
    nsmith
    New Contributor III

    This is very helpful. I’m trying to build a “Job Scheduling” system that will enable and disable tasks when they are ready to run based on another system’s scheduling.

    I have it “retry” each task 5 times, so that if the pipeline fails it will auto retry… but if it succeeds, then it will disable its own task and shouldn’t run again. Unfortunately even after the task has been disabled, the pipeline will run a second time – so it appears that scheduling is added to a queue, and if it’s within 1-2 minutes of running… disabling a task doesn’t remove it from the queue.

    Does anyone have any ideas? I thought about using the Task Execute, but that’s being deprecated (documentation says so). I don’t want to use the pipeline execute because I don’t want them all related, because I’ll have 1 master scheduler pipeline related to every single execution.

    EDIT: Maybe it’s that I’ve got the retry interval set to 3 minutes? I’m dropping it to 5 and will see if that fixes it.

    • nsmith's avatar
      nsmith
      New Contributor III

      Yeah it looks like there’s some type of pipeline run queue… so if you disable a task at the end of its own pipeline, there’s still a chance it runs again because it’s already in the queue… ☹️

      FIX: I added a task reader snap and a filter for “$parameters.enabled == true” at the start of the pipeline… so if the task has been disabled it will stop execution.