Stop executing remaining processor of a pipeline











up vote
1
down vote

favorite












Suppose i have 5 processor in a custom pipeline. I want to abort the execution of remaining processor if certain condition is satisfied in one of the processor.










share|improve this question


















  • 1




    You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
    – adarsh
    23 hours ago

















up vote
1
down vote

favorite












Suppose i have 5 processor in a custom pipeline. I want to abort the execution of remaining processor if certain condition is satisfied in one of the processor.










share|improve this question


















  • 1




    You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
    – adarsh
    23 hours ago















up vote
1
down vote

favorite









up vote
1
down vote

favorite











Suppose i have 5 processor in a custom pipeline. I want to abort the execution of remaining processor if certain condition is satisfied in one of the processor.










share|improve this question













Suppose i have 5 processor in a custom pipeline. I want to abort the execution of remaining processor if certain condition is satisfied in one of the processor.







pipelines






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 23 hours ago









siddharth

1197




1197








  • 1




    You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
    – adarsh
    23 hours ago
















  • 1




    You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
    – adarsh
    23 hours ago










1




1




You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
– adarsh
23 hours ago






You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
– adarsh
23 hours ago












2 Answers
2






active

oldest

votes

















up vote
7
down vote



accepted










Siva Kumar answer is correct in the most simple scenario. You must know that



args.AbortPipeline()


doesn't really abort the pipeline. It only sets a flag and all the remaining processors will be still checked and there is a chance some of them WILL be executed. Why?



Sitecore allows setting one extra flag on every processor which is called RunIfAborted. If you open /sitecore/admin/showconfig.aspx, you will see this flag set e.g. for 2 processors in publishItem pipeline:



<publishItem help="Processors should derive from Sitecore.Publishing.Pipelines.PublishItem.PublishItemProcessor">
<!-- ... -->
<processor
type="Sitecore.Publishing.Pipelines.PublishItem.RaiseProcessedEvent, Sitecore.Kernel"
runIfAborted="true"/>
<processor
type="Sitecore.Publishing.Pipelines.PublishItem.UpdateStatistics, Sitecore.Kernel"
runIfAborted="true">
<!-- ... -->
</publishItem>


This flag makes sure that the processors will be executed even if the Aborted flag is set on the args of the pipeline.



In summary, using args.AbortPipeline(); is the correct way of aborting the execution of pipeline processors, but you must remember that Sitecore may still execute some of the processors.



Pseudo code of how Sitecore pipeline works (this is not the exact code - it's just to show the basic logic part):



foreach (var processor in processors)
{
if (!args.Aborted || processor.RunIfAborted)
Execute(processor);
}





share|improve this answer






























    up vote
    3
    down vote













    args.AbortPipeline() method is used to Abort the Pipeline. This method sets _aborted flag as true and ignores the successor processors from execution.



    public override void Process(HttpRequestArgs args)
    {
    Assert.ArgumentNotNull(args, "args");
    if (condition is true)
    {
    args.AbortPipeline();
    return;
    }
    }





    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "664"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f15088%2fstop-executing-remaining-processor-of-a-pipeline%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      7
      down vote



      accepted










      Siva Kumar answer is correct in the most simple scenario. You must know that



      args.AbortPipeline()


      doesn't really abort the pipeline. It only sets a flag and all the remaining processors will be still checked and there is a chance some of them WILL be executed. Why?



      Sitecore allows setting one extra flag on every processor which is called RunIfAborted. If you open /sitecore/admin/showconfig.aspx, you will see this flag set e.g. for 2 processors in publishItem pipeline:



      <publishItem help="Processors should derive from Sitecore.Publishing.Pipelines.PublishItem.PublishItemProcessor">
      <!-- ... -->
      <processor
      type="Sitecore.Publishing.Pipelines.PublishItem.RaiseProcessedEvent, Sitecore.Kernel"
      runIfAborted="true"/>
      <processor
      type="Sitecore.Publishing.Pipelines.PublishItem.UpdateStatistics, Sitecore.Kernel"
      runIfAborted="true">
      <!-- ... -->
      </publishItem>


      This flag makes sure that the processors will be executed even if the Aborted flag is set on the args of the pipeline.



      In summary, using args.AbortPipeline(); is the correct way of aborting the execution of pipeline processors, but you must remember that Sitecore may still execute some of the processors.



      Pseudo code of how Sitecore pipeline works (this is not the exact code - it's just to show the basic logic part):



      foreach (var processor in processors)
      {
      if (!args.Aborted || processor.RunIfAborted)
      Execute(processor);
      }





      share|improve this answer



























        up vote
        7
        down vote



        accepted










        Siva Kumar answer is correct in the most simple scenario. You must know that



        args.AbortPipeline()


        doesn't really abort the pipeline. It only sets a flag and all the remaining processors will be still checked and there is a chance some of them WILL be executed. Why?



        Sitecore allows setting one extra flag on every processor which is called RunIfAborted. If you open /sitecore/admin/showconfig.aspx, you will see this flag set e.g. for 2 processors in publishItem pipeline:



        <publishItem help="Processors should derive from Sitecore.Publishing.Pipelines.PublishItem.PublishItemProcessor">
        <!-- ... -->
        <processor
        type="Sitecore.Publishing.Pipelines.PublishItem.RaiseProcessedEvent, Sitecore.Kernel"
        runIfAborted="true"/>
        <processor
        type="Sitecore.Publishing.Pipelines.PublishItem.UpdateStatistics, Sitecore.Kernel"
        runIfAborted="true">
        <!-- ... -->
        </publishItem>


        This flag makes sure that the processors will be executed even if the Aborted flag is set on the args of the pipeline.



        In summary, using args.AbortPipeline(); is the correct way of aborting the execution of pipeline processors, but you must remember that Sitecore may still execute some of the processors.



        Pseudo code of how Sitecore pipeline works (this is not the exact code - it's just to show the basic logic part):



        foreach (var processor in processors)
        {
        if (!args.Aborted || processor.RunIfAborted)
        Execute(processor);
        }





        share|improve this answer

























          up vote
          7
          down vote



          accepted







          up vote
          7
          down vote



          accepted






          Siva Kumar answer is correct in the most simple scenario. You must know that



          args.AbortPipeline()


          doesn't really abort the pipeline. It only sets a flag and all the remaining processors will be still checked and there is a chance some of them WILL be executed. Why?



          Sitecore allows setting one extra flag on every processor which is called RunIfAborted. If you open /sitecore/admin/showconfig.aspx, you will see this flag set e.g. for 2 processors in publishItem pipeline:



          <publishItem help="Processors should derive from Sitecore.Publishing.Pipelines.PublishItem.PublishItemProcessor">
          <!-- ... -->
          <processor
          type="Sitecore.Publishing.Pipelines.PublishItem.RaiseProcessedEvent, Sitecore.Kernel"
          runIfAborted="true"/>
          <processor
          type="Sitecore.Publishing.Pipelines.PublishItem.UpdateStatistics, Sitecore.Kernel"
          runIfAborted="true">
          <!-- ... -->
          </publishItem>


          This flag makes sure that the processors will be executed even if the Aborted flag is set on the args of the pipeline.



          In summary, using args.AbortPipeline(); is the correct way of aborting the execution of pipeline processors, but you must remember that Sitecore may still execute some of the processors.



          Pseudo code of how Sitecore pipeline works (this is not the exact code - it's just to show the basic logic part):



          foreach (var processor in processors)
          {
          if (!args.Aborted || processor.RunIfAborted)
          Execute(processor);
          }





          share|improve this answer














          Siva Kumar answer is correct in the most simple scenario. You must know that



          args.AbortPipeline()


          doesn't really abort the pipeline. It only sets a flag and all the remaining processors will be still checked and there is a chance some of them WILL be executed. Why?



          Sitecore allows setting one extra flag on every processor which is called RunIfAborted. If you open /sitecore/admin/showconfig.aspx, you will see this flag set e.g. for 2 processors in publishItem pipeline:



          <publishItem help="Processors should derive from Sitecore.Publishing.Pipelines.PublishItem.PublishItemProcessor">
          <!-- ... -->
          <processor
          type="Sitecore.Publishing.Pipelines.PublishItem.RaiseProcessedEvent, Sitecore.Kernel"
          runIfAborted="true"/>
          <processor
          type="Sitecore.Publishing.Pipelines.PublishItem.UpdateStatistics, Sitecore.Kernel"
          runIfAborted="true">
          <!-- ... -->
          </publishItem>


          This flag makes sure that the processors will be executed even if the Aborted flag is set on the args of the pipeline.



          In summary, using args.AbortPipeline(); is the correct way of aborting the execution of pipeline processors, but you must remember that Sitecore may still execute some of the processors.



          Pseudo code of how Sitecore pipeline works (this is not the exact code - it's just to show the basic logic part):



          foreach (var processor in processors)
          {
          if (!args.Aborted || processor.RunIfAborted)
          Execute(processor);
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 19 hours ago

























          answered 22 hours ago









          Marek Musielak

          9,19811034




          9,19811034






















              up vote
              3
              down vote













              args.AbortPipeline() method is used to Abort the Pipeline. This method sets _aborted flag as true and ignores the successor processors from execution.



              public override void Process(HttpRequestArgs args)
              {
              Assert.ArgumentNotNull(args, "args");
              if (condition is true)
              {
              args.AbortPipeline();
              return;
              }
              }





              share|improve this answer

























                up vote
                3
                down vote













                args.AbortPipeline() method is used to Abort the Pipeline. This method sets _aborted flag as true and ignores the successor processors from execution.



                public override void Process(HttpRequestArgs args)
                {
                Assert.ArgumentNotNull(args, "args");
                if (condition is true)
                {
                args.AbortPipeline();
                return;
                }
                }





                share|improve this answer























                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  args.AbortPipeline() method is used to Abort the Pipeline. This method sets _aborted flag as true and ignores the successor processors from execution.



                  public override void Process(HttpRequestArgs args)
                  {
                  Assert.ArgumentNotNull(args, "args");
                  if (condition is true)
                  {
                  args.AbortPipeline();
                  return;
                  }
                  }





                  share|improve this answer












                  args.AbortPipeline() method is used to Abort the Pipeline. This method sets _aborted flag as true and ignores the successor processors from execution.



                  public override void Process(HttpRequestArgs args)
                  {
                  Assert.ArgumentNotNull(args, "args");
                  if (condition is true)
                  {
                  args.AbortPipeline();
                  return;
                  }
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 23 hours ago









                  Siva Kumar

                  767




                  767






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f15088%2fstop-executing-remaining-processor-of-a-pipeline%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Bundesstraße 106

                      Verónica Boquete

                      Ida-Boy-Ed-Garten