...
Routing
...
Slip
...
The
...
...
...
from
...
the
...
...
...
allows
...
you
...
to
...
route
...
a
...
message
...
consecutively
...
through
...
a
...
series
...
of
...
processing
...
steps
...
where
...
the
...
sequence
...
of
...
steps
...
is
...
not
...
known
...
at
...
design
...
time
...
and
...
can
...
vary
...
for
...
each message.
Options
Wiki Markup |
---|
message. !http://www.enterpriseintegrationpatterns.com/img/RoutingTableSimple.gif! h3. Options {div:class=confluenceTableSmall} || Name || Default Value || Description || | {{uriDelimiter}} | {{,}} | Delimiter used if the [Expression] returned multiple endpoints. | | {{ignoreInvalidEndpoints}} | {{false}} | If an endpoint uri could not be resolved, should it be ignored. Otherwise Camel will throw an exception stating the endpoint uri is not valid. | {div} h4. Example The following route will take any messages sent to the [Apache ActiveMQ|http://activemq.apache.org] queue *SomeQueue* and pass them into the [Routing Slip|http://www.enterpriseintegrationpatterns.com/RoutingTable.html] pattern. {code} |
Example
The following route will take any messages sent to the Apache ActiveMQ queue SomeQueue and pass them into the Routing Slip pattern.
Code Block |
---|
from("activemq:SomeQueue").routingSlip("aRoutingSlipHeader");
{code}
|
Messages
...
will
...
be
...
checked
...
for
...
the
...
existance
...
of
...
the
...
"aRoutingSlipHeader"
...
header.
...
The
...
value
...
of
...
this
...
header
...
should
...
be
...
a
...
comma-delimited
...
list
...
of
...
endpoint
...
...
you
...
wish
...
the
...
message
...
to
...
be
...
routed
...
to.
...
The
...
...
will
...
be
...
routed
...
in
...
a
...
...
fashion
...
(i.e.
...
one
...
after
...
the
...
other).
...
From
...
Camel
...
2.5
...
the
...
...
...
will
...
set
...
a
...
property
...
(
...
Exchange.SLIP_ENDPOINT
...
)
...
on
...
the
...
...
which
...
contains
...
the
...
current
...
endpoint
...
as
...
it
...
advanced
...
though
...
the
...
slip.
...
This
...
allows
...
you
...
to
...
know
...
how
...
far
...
we
...
have
...
processed
...
in
...
the
...
slip.
...
The
...
...
...
will
...
compute
...
the
...
slip
...
beforehand
...
which
...
means,
...
the
...
slip
...
is
...
only
...
computed
...
once.
...
If
...
you
...
need
...
to
...
compute
...
the
...
slip
...
on-the-fly
...
then
...
use
...
the
...
...
...
pattern
...
instead.
...
Configuration
...
options
...
Here
...
we
...
set
...
the
...
header
...
name
...
and
...
the
...
URI
...
delimiter
...
to
...
something
...
different.
...
Using
...
the
...
Wiki Markup |
---|
Builders]* {snippet:id=e3|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipTest.java} * |
Using
...
the
...
...
...
Code Block |
---|
]* {code} <camelContext id="buildRoutingSlip" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="direct:c"/> <routingSlip uriDelimiter="#"> <header>aRoutingSlipHeader</header> </routingSlip> </route> </camelContext> {code} h3. Ignore invalid endpoints *Available as of Camel 2.3* The [Routing Slip] now supports {{ignoreInvalidEndpoints}} which the [Recipient List] also supports. You can use it to skip endpoints which are invalid. {code} |
Ignore invalid endpoints
Available as of Camel 2.3
The Routing Slip now supports ignoreInvalidEndpoints
which the Recipient List also supports. You can use it to skip endpoints which are invalid.
Code Block |
---|
from("direct:a").routingSlip("myHeader").ignoreInvalidEndpoints();
{code}
|
And
...
in
...
Spring
...
XML
...
its
...
an
...
attribute
...
on
...
the
...
recipient
...
list
...
tag.
Code Block |
---|
} <route> <from uri="direct:a"/> <routingSlip ignoreInvalidEndpoints="true"/> <header>myHeader</header> </routingSlip> </route> {code} |
Then
...
lets
...
say
...
the
...
myHeader
...
contains
...
the
...
following
...
two
...
endpoints
...
direct:foo,xxx:bar
...
.
...
The
...
first
...
endpoint
...
is
...
valid
...
and
...
works.
...
However
...
the
...
2nd
...
is
...
invalid
...
and
...
will
...
just
...
be
...
ignored.
...
Camel
...
logs
...
at
...
INFO
...
level,
...
so
...
you
...
can
...
see
...
why
...
the
...
endpoint
...
was
...
invalid.
...
Expression
...
supporting
...
Available
...
as
...
of
...
Camel
...
2.4
...
The
...
...
...
now
...
supports
...
to
...
take
...
the
...
expression
...
parameter
...
as
...
the
...
...
...
does.
...
You
...
can
...
tell
...
Camel
...
the
...
expression
...
that
...
you
...
want
...
to
...
use
...
to
...
get
...
the
...
routing
...
slip.
Code Block |
---|
} from("direct:a").routingSlip(header("myHeader")).ignoreInvalidEndpoints(); {code} |
And
...
in
...
Spring
...
XML
...
its
...
an
...
attribute
...
on
...
the
...
recipient
...
list
...
tag.
Code Block |
---|
} <route> <from uri="direct:a"/> <!--NOTE from Camel 2.4.0, you need to specify the expression element inside of the routingSlip element --> <routingSlip ignoreInvalidEndpoints="true"> <header>myHeader</header> </routingSlip> </route> {code} h4. Further Examples For further examples of this pattern in use you could look at the [routing slip test cases|http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip]. {include:Using This Pattern} |
Further Examples
For further examples of this pattern in use you could look at the routing slip test cases.
Include Page | ||||
---|---|---|---|---|
|