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
    Nov 22 at 6:36

















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
    Nov 22 at 6:36















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 Nov 22 at 6:27









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
    Nov 22 at 6:36
















  • 1




    You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
    – adarsh
    Nov 22 at 6:36










1




1




You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
– adarsh
Nov 22 at 6:36






You can try args.AbortPipeline(); when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
– adarsh
Nov 22 at 6:36












2 Answers
2






active

oldest

votes

















up vote
9
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
      9
      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
        9
        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
          9
          down vote



          accepted







          up vote
          9
          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 Nov 22 at 11:03

























          answered Nov 22 at 7:37









          Marek Musielak

          9,28511034




          9,28511034






















              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 Nov 22 at 6:43









                  Siva Kumar

                  11310




                  11310






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Sitecore Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      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

                      Quarter-circle Tiles

                      build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                      Mont Emei