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.
pipelines
add a comment |
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.
pipelines
1
You can tryargs.AbortPipeline();
when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
– adarsh
Nov 22 at 6:36
add a comment |
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.
pipelines
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
pipelines
asked Nov 22 at 6:27
siddharth
1197
1197
1
You can tryargs.AbortPipeline();
when your condition is satisfied. args is the argument parameters you are passing to the pipeline.
– adarsh
Nov 22 at 6:36
add a comment |
1
You can tryargs.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
add a comment |
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);
}
add a comment |
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;
}
}
add a comment |
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);
}
add a comment |
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);
}
add a comment |
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);
}
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);
}
edited Nov 22 at 11:03
answered Nov 22 at 7:37
Marek Musielak
9,28511034
9,28511034
add a comment |
add a comment |
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;
}
}
add a comment |
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;
}
}
add a comment |
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;
}
}
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;
}
}
answered Nov 22 at 6:43
Siva Kumar
1138
1138
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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