Stop executing remaining processor of a pipeline












3















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 '18 at 6:36


















3















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 '18 at 6:36
















3












3








3








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 '18 at 6:27









siddharthsiddharth

1298




1298








  • 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 '18 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 '18 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 '18 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 '18 at 6:36












2 Answers
2






active

oldest

votes


















13














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

































    3














    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',
      autoActivateHeartbeat: false,
      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









      13














      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






























        13














        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




























          13












          13








          13







          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 '18 at 11:03

























          answered Nov 22 '18 at 7:37









          Marek MusielakMarek Musielak

          9,74311035




          9,74311035























              3














              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




























                3














                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


























                  3












                  3








                  3







                  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 '18 at 6:43









                  Siva KumarSiva Kumar

                  123110




                  123110






























                      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.




                      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

                      Costa Masnaga

                      Fotorealismo

                      Create new schema in PostgreSQL using DBeaver