<commit_before>= Rollback EIP
:doctitle: Rollback
:shortname: rollback
:description: Forces a rollback by stopping routing the message
:since:
:supportlevel: Stable

The Rollback EIP is used for marking an xref:latest@manual:ROOT:exchange.adoc[Exchange]
to rollback and stop continue routing the message.

== Options
// eip options: START
include::partial$eip-options.adoc[]
// eip options: END

== Using Rollback

We want test message for some conditions and force a rollback if a message may be faulty.

In Java DSL we can do:

[source,java]
----
from("direct:start")
    .choice().when(body().contains("error"))
        .rollback("That do not work")
    .otherwise()
        .to("direct:continue");
----

And in XML DSL:

[source,xml]
----
<route>
    <from uri="direct:start"/>
    <choice>
        <when>
            <simple>${body} contains 'error'</simple>
            <rollback message="That do not work"/>
        </when>
        <otherwise>
            <to uri="direct:continue"/>
        </otherwise>
    </choice>
</route>
----

When Camel is rolling back, then a `RollbackExchangeException` is thrown with the caused message "That do not work".

=== Marking for Rollback only

When a message is rolled back, then Camel will by default throw a `RollbackExchangeException`
to cause the message to fail and rollback.

This behavior can be modified to only mark for rollback, and not throw the exception.

[source,java]
----
from("direct:start")
    .choice().when(body().contains("error"))
        .markRollbackOnly()
    .otherwise()
        .to("direct:continue");
----

And in XML DSL:

[source,xml]
----
<route>
    <from uri="direct:start"/>
    <choice>
        <when>
            <simple>${body} contains 'error'</simple>
            <rollback markRollbackOnly="true"/>
        </when>
        <otherwise>
            <to uri="direct:continue"/>
        </otherwise>
    </choice>
</route>
----

Then no exception is thrown, but the message is marked to rollback and stopped continue routing.

=== Using Rollback with Transactions

Rollback can be used together with xref:transactional-client.adoc[transactions].
For more details see xref:transactional-client.adoc[Transaction Client] EIP.
<commit_msg>Regen for commit <PASSWORD> (#6251)<commit_after>= Rollback EIP
:doctitle: Rollback
:shortname: rollback
:description: Forces a rollback by stopping routing the message
:since: 
:supportlevel: Stable

The Rollback EIP is used for marking an xref:latest@manual:ROOT:exchange.adoc[Exchange]
to rollback and stop continue routing the message.

== Options
// eip options: START
include::partial$eip-options.adoc[]
// eip options: END

== Using Rollback

We want test message for some conditions and force a rollback if a message may be faulty.

In Java DSL we can do:

[source,java]
----
from("direct:start")
    .choice().when(body().contains("error"))
        .rollback("That do not work")
    .otherwise()
        .to("direct:continue");
----

And in XML DSL:

[source,xml]
----
<route>
    <from uri="direct:start"/>
    <choice>
        <when>
            <simple>${body} contains 'error'</simple>
            <rollback message="That do not work"/>
        </when>
        <otherwise>
            <to uri="direct:continue"/>
        </otherwise>
    </choice>
</route>
----

When Camel is rolling back, then a `RollbackExchangeException` is thrown with the caused message "That do not work".

=== Marking for Rollback only

When a message is rolled back, then Camel will by default throw a `RollbackExchangeException`
to cause the message to fail and rollback.

This behavior can be modified to only mark for rollback, and not throw the exception.

[source,java]
----
from("direct:start")
    .choice().when(body().contains("error"))
        .markRollbackOnly()
    .otherwise()
        .to("direct:continue");
----

And in XML DSL:

[source,xml]
----
<route>
    <from uri="direct:start"/>
    <choice>
        <when>
            <simple>${body} contains 'error'</simple>
            <rollback markRollbackOnly="true"/>
        </when>
        <otherwise>
            <to uri="direct:continue"/>
        </otherwise>
    </choice>
</route>
----

Then no exception is thrown, but the message is marked to rollback and stopped continue routing.

=== Using Rollback with Transactions

Rollback can be used together with xref:transactional-client.adoc[transactions].
For more details see xref:transactional-client.adoc[Transaction Client] EIP.
{'fraction_non_alphanumeric': 0.12802690582959642, 'fraction_numerical': 0.0008968609865470852, 'mean_word_length': 3.0889092575618697, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '260445', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1282, 'n_words': 452}