This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 38288385dda Update sample eip docs (#17957)
38288385dda is described below
commit 38288385dda7d0dd9813dfdb347a0459ec8a3e14
Author: thomas-gantenbein-tga
<[email protected]>
AuthorDate: Sun May 4 13:14:16 2025 +0200
Update sample eip docs (#17957)
---
.../main/docs/modules/eips/images/eip/Sample.png | Bin 0 -> 10165 bytes
.../main/docs/modules/eips/pages/sample-eip.adoc | 53 ++++++++++++++++++---
2 files changed, 47 insertions(+), 6 deletions(-)
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/images/eip/Sample.png
b/core/camel-core-engine/src/main/docs/modules/eips/images/eip/Sample.png
new file mode 100644
index 00000000000..26e351805f1
Binary files /dev/null and
b/core/camel-core-engine/src/main/docs/modules/eips/images/eip/Sample.png differ
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/sample-eip.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/sample-eip.adoc
index d483c5e700d..6c80afd2fb5 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/sample-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/sample-eip.adoc
@@ -2,17 +2,16 @@
:doctitle: Sample
:shortname: sample
:description: Extract a sample of the messages passing through a route
-:since:
+:since:
:supportlevel: Stable
:tabs-sync-option:
A sampling throttler allows you to extract a sample of the exchanges from the
traffic through a route.
-image::eip/WireTap.gif[image]
+image::eip/Sample.png[image]
-The Sample EIP works similar to a wire tap, but instead of tapping every
message, the sampling will
-select a single message in a given time period. This selected message is
allowed to pass through,
-and all other messages are stopped.
+The Sample EIP selects a single message in a given time period or every nth
message.
+This selected message is allowed to pass through, and all other messages are
stopped.
== Options
// eip options: START
@@ -65,7 +64,7 @@ Java::
[source,java]
----
from("direct:sample")
- .sample(5, TimeUnit.SECONDS)
+ .sample(Duration.of(5, ChronoUnit.SECONDS))
.to("direct:sampled");
----
@@ -109,3 +108,45 @@ XML::
</route>
----
====
+
+=== Sampling with wiretap
+
+The sampling throttler will stop all exchanges not included in the sample.
This may be undesirable if you want to
+perform custom processing on the sample while still allowing all 10 messages
to flow to an endpoint after the sample EIP.
+
+For this use case, you can combine the sample EIP with wiretap EIP. In the
example below, we sample every 10th message
+and send it to direct:sampleProcessing, while all 10 messages are still sent
to direct:regularProcessing.
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:start")
+ .wireTap("direct:sample")
+ .to("direct:regularProcessing")
+
+from("direct:sample")
+ .sample(10)
+ .to("direct:sampleProcessing");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="direct:start"/>
+ <wireTap uri="direct:sample"/>
+ <to uri="direct:regularProcessing"/>
+</route>
+
+<route>
+ <from uri="direct:sample"/>
+ <sample messageFrequency="10"/>
+ <to uri="direct:sampleProcessing"/>
+</route>
+----
+====
+