Package org.apache.camel.builder
Class NotifyBuilder
java.lang.Object
org.apache.camel.builder.NotifyBuilder
A builder to build an expression based on
EventNotifier
notifications about
Exchange
being routed.
This builder can be used for testing purposes where you want to know when a test is supposed to be done. The idea is
that you can build an expression that explains when the test is done. For example when Camel have finished routing 5
messages. You can then in your test await for this condition to occur.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionand()
Prepares to append an additional expression using the and operator.create()
Creates the expression this builder should use for matching.void
destroy()
De-registers this builder from itsCamelContext
.filter()
Optionally a filter to only allow matchingExchange
to be used for matching.filter
(org.apache.camel.Predicate predicate) Optionally a filter to only allow matchingExchange
to be used for matching.Optionally a from endpoint which means that this expression should only be based onExchange
which is originated from the particular endpoint(s).fromCurrentRoute
(String routeId) Optionally a from current route which means that this expression should only be based onExchange
which is the current route(s).Optionally a from route which means that this expression should only be based onExchange
which is originated from the particular route(s).boolean
matches()
Does all the expression match?boolean
Does all the expression match?boolean
Does all the expressions match?not()
Prepares to append an additional expression using the not operator.or()
Prepares to append an additional expression using the or operator.void
reset()
Resets the notifier.toString()
waitTime
(long waitTime) Specifies the wait time in millis to use in thematchesWaitTime()
method.wereSentTo
(String endpointUri) Optionally a sent to endpoint which means that this expression should only be based onExchange
which has been sent to the given endpoint uri.whenAllDoneMatches
(org.apache.camel.Predicate predicate) Sets a condition that all doneExchange
should match thePredicate
whenAllReceivedMatches
(org.apache.camel.Predicate predicate) Sets a condition that all receivedExchange
should match thePredicate
whenAnyDoneMatches
(org.apache.camel.Predicate predicate) Sets a condition that any doneExchange
should match thePredicate
whenAnyReceivedMatches
(org.apache.camel.Predicate predicate) Sets a condition that any receivedExchange
should match thePredicate
whenBodiesDone
(Object... bodies) Sets a condition that the bodies is expected to be done in the order as well.whenBodiesReceived
(Object... bodies) Sets a condition that the bodies is expected to be received in the order as well.whenCompleted
(int number) Sets a condition when number ofExchange
has been completed.whenDone
(int number) Sets a condition when number ofExchange
is done being processed.whenDoneByIndex
(int index) Sets a condition when tne n'th (by index)Exchange
is done being processed.whenDoneNotSatisfied
(org.apache.camel.spi.NotifyBuilderMatcher matcher) Sets a condition when the provided matcher (such as mock endpoint) is not satisfied based onExchange
being sent to it when they are done.whenDoneSatisfied
(org.apache.camel.spi.NotifyBuilderMatcher matcher) Sets a condition when the provided matcher (such as mock endpoint) is satisfied based onExchange
being sent to it when they are done.whenExactBodiesDone
(Object... bodies) Sets a condition that the bodies is expected to be done in the order as well.whenExactBodiesReceived
(Object... bodies) Sets a condition that the bodies is expected to be received in the order as well.whenExactlyCompleted
(int number) Sets a condition when number ofExchange
has been completed.whenExactlyDone
(int number) Sets a condition when number ofExchange
is done being processed.whenExactlyFailed
(int number) Sets a condition when number ofExchange
has failed.whenFailed
(int number) Sets a condition when number ofExchange
has failed.whenReceived
(int number) Sets a condition when number ofExchange
has been received.whenReceivedNotSatisfied
(org.apache.camel.spi.NotifyBuilderMatcher matcher) Sets a condition when the provided matcher (such as mock endpoint) is not satisfied based onExchange
being sent to it when they are received.whenReceivedSatisfied
(org.apache.camel.spi.NotifyBuilderMatcher matcher) Sets a condition when the provided matcher (such as mock endpoint) is satisfied based onExchange
being sent to it when they are received.
-
Constructor Details
-
NotifyBuilder
public NotifyBuilder(org.apache.camel.CamelContext context) Creates a new builder.- Parameters:
context
- the Camel context
-
-
Method Details
-
from
Optionally a from endpoint which means that this expression should only be based onExchange
which is originated from the particular endpoint(s).- Parameters:
endpointUri
- uri of endpoint or pattern (see the EndpointHelper javadoc)- Returns:
- the builder
- See Also:
-
EndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)
-
fromRoute
Optionally a from route which means that this expression should only be based onExchange
which is originated from the particular route(s).- Parameters:
routeId
- id of route or pattern (see the EndpointHelper javadoc)- Returns:
- the builder
- See Also:
-
EndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)
-
fromCurrentRoute
Optionally a from current route which means that this expression should only be based onExchange
which is the current route(s).- Parameters:
routeId
- id of route or pattern (see the EndpointHelper javadoc)- Returns:
- the builder
- See Also:
-
EndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)
-
filter
Optionally a filter to only allow matchingExchange
to be used for matching.- Parameters:
predicate
- the predicate to use for the filter- Returns:
- the builder
-
filter
Optionally a filter to only allow matchingExchange
to be used for matching.- Returns:
- the builder
-
wereSentTo
Optionally a sent to endpoint which means that this expression should only be based onExchange
which has been sent to the given endpoint uri. Notice theExchange
may have been sent to other endpoints as well. This condition will match if theExchange
has been sent at least once to the given endpoint.- Parameters:
endpointUri
- uri of endpoint or pattern (see the EndpointHelper javadoc)- Returns:
- the builder
- See Also:
-
EndpointHelper.matchEndpoint(org.apache.camel.CamelContext, String, String)
-
whenReceived
Sets a condition when number ofExchange
has been received. The number matching is at least based which means that if more messages received it will match also.- Parameters:
number
- at least number of messages- Returns:
- the builder
-
whenDone
Sets a condition when number ofExchange
is done being processed. The number matching is at least based which means that if more messages received it will match also. The difference between done and completed is that done can also include failed messages, where as completed is only successful processed messages.- Parameters:
number
- at least number of messages- Returns:
- the builder
-
whenDoneByIndex
Sets a condition when tne n'th (by index)Exchange
is done being processed. The difference between done and completed is that done can also include failed messages, where as completed is only successful processed messages.- Parameters:
index
- the message by index to be done- Returns:
- the builder
-
whenCompleted
Sets a condition when number ofExchange
has been completed. The number matching is at least based which means that if more messages received it will match also. The difference between done and completed is that done can also include failed messages, where as completed is only successful processed messages.- Parameters:
number
- at least number of messages- Returns:
- the builder
-
whenFailed
Sets a condition when number ofExchange
has failed. The number matching is at least based which means that if more messages received it will match also.- Parameters:
number
- at least number of messages- Returns:
- the builder
-
whenExactlyDone
Sets a condition when number ofExchange
is done being processed. messages, where as completed is only successful processed messages.- Parameters:
number
- exactly number of messages- Returns:
- the builder
-
whenExactlyCompleted
Sets a condition when number ofExchange
has been completed. The difference between done and completed is that done can also include failed messages, where as completed is only successful processed messages.- Parameters:
number
- exactly number of messages- Returns:
- the builder
-
whenExactlyFailed
Sets a condition when number ofExchange
has failed.- Parameters:
number
- exactly number of messages- Returns:
- the builder
-
whenAnyReceivedMatches
Sets a condition that any receivedExchange
should match thePredicate
- Parameters:
predicate
- the predicate- Returns:
- the builder
-
whenAnyDoneMatches
Sets a condition that any doneExchange
should match thePredicate
- Parameters:
predicate
- the predicate- Returns:
- the builder
-
whenAllReceivedMatches
Sets a condition that all receivedExchange
should match thePredicate
- Parameters:
predicate
- the predicate- Returns:
- the builder
-
whenAllDoneMatches
Sets a condition that all doneExchange
should match thePredicate
- Parameters:
predicate
- the predicate- Returns:
- the builder
-
whenBodiesReceived
Sets a condition that the bodies is expected to be received in the order as well. This condition will discard any additional messages. If you need a more strict condition then usewhenExactBodiesReceived(Object...)
- Parameters:
bodies
- the expected bodies- Returns:
- the builder
- See Also:
-
whenBodiesDone
Sets a condition that the bodies is expected to be done in the order as well. This condition will discard any additional messages. If you need a more strict condition then usewhenExactBodiesDone(Object...)
- Parameters:
bodies
- the expected bodies- Returns:
- the builder
- See Also:
-
whenExactBodiesReceived
Sets a condition that the bodies is expected to be received in the order as well. This condition is strict which means that it only expect that exact number of bodies- Parameters:
bodies
- the expected bodies- Returns:
- the builder
- See Also:
-
whenExactBodiesDone
Sets a condition that the bodies is expected to be done in the order as well. This condition is strict which means that it only expect that exact number of bodies- Parameters:
bodies
- the expected bodies- Returns:
- the builder
- See Also:
-
whenDoneSatisfied
Sets a condition when the provided matcher (such as mock endpoint) is satisfied based onExchange
being sent to it when they are done. The idea is that you can use mock endpoints (or other matchers) for setting fine grained expectations and then use that together with this builder. The mock provided does NOT have to already exist in the route. You can just create a new pseudo mock and this builder will send the doneExchange
to it. So its like adding the mock to the end of your route(s).- Parameters:
matcher
- the matcher such as mock endpoint- Returns:
- the builder
-
whenReceivedSatisfied
Sets a condition when the provided matcher (such as mock endpoint) is satisfied based onExchange
being sent to it when they are received. The idea is that you can use mock endpoints (or other matchers) for setting fine grained expectations and then use that together with this builder. The mock provided does NOT have to already exist in the route. You can just create a new pseudo mock and this builder will send the doneExchange
to it. So its like adding the mock to the end of your route(s).- Parameters:
matcher
- the matcher such as mock endpoint- Returns:
- the builder
-
whenReceivedNotSatisfied
Sets a condition when the provided matcher (such as mock endpoint) is not satisfied based onExchange
being sent to it when they are received. The idea is that you can use mock endpoints (or other matchers) for setting fine grained expectations and then use that together with this builder. The mock provided does NOT have to already exist in the route. You can just create a new pseudo mock and this builder will send the doneExchange
to it. So its like adding the mock to the end of your route(s).- Parameters:
matcher
- the matcher such as mock endpoint- Returns:
- the builder
-
whenDoneNotSatisfied
Sets a condition when the provided matcher (such as mock endpoint) is not satisfied based onExchange
being sent to it when they are done. The idea is that you can use mock endpoints (or other matchers) for setting fine grained expectations and then use that together with this builder. The mock provided does NOT have to already exist in the route. You can just create a new pseudo mock and this builder will send the doneExchange
to it. So its like adding the mock to the end of your route(s).- Parameters:
matcher
- the matcher such as mock endpoint- Returns:
- the builder
-
and
Prepares to append an additional expression using the and operator.- Returns:
- the builder
-
or
Prepares to append an additional expression using the or operator.- Returns:
- the builder
-
not
Prepares to append an additional expression using the not operator.- Returns:
- the builder
-
waitTime
Specifies the wait time in millis to use in thematchesWaitTime()
method. -
create
Creates the expression this builder should use for matching. You must call this method when you are finished building the expressions.- Returns:
- the created builder ready for matching
-
destroy
public void destroy()De-registers this builder from itsCamelContext
. Once destroyed, this instance will not function again. -
matches
public boolean matches()Does all the expression match? This operation will return immediately which means it can be used for testing at this very moment.- Returns:
- true if matching, false otherwise
-
matches
Does all the expression match? This operation will wait until the match is true or otherwise a timeout occur which means false will be returned.- Parameters:
timeout
- the timeout valuetimeUnit
- the time unit- Returns:
- true if matching, false otherwise due to timeout
-
matchesWaitTime
public boolean matchesWaitTime()Does all the expressions match? This operation will wait until the match is true or otherwise a timeout occur which means false will be returned. The timeout value is by default 10 seconds.- Returns:
- true if matching, false otherwise due to timeout
-
reset
public void reset()Resets the notifier. -
toString
-