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
commit c6c0b1ba6cb2ebc338dc545e07bb217e2632a7c3 Author: Claus Ibsen <[email protected]> AuthorDate: Wed Feb 25 13:30:14 2026 +0100 CAMEL-16861: Update docs --- .../pages/using-exchange-pattern-annotations.adoc | 62 +++++++++------------- .../modules/ROOT/pages/uuidgenerator.adoc | 52 +++++++++++------- 2 files changed, 58 insertions(+), 56 deletions(-) diff --git a/docs/user-manual/modules/ROOT/pages/using-exchange-pattern-annotations.adoc b/docs/user-manual/modules/ROOT/pages/using-exchange-pattern-annotations.adoc index b86fc5f56236..84a13da4ff2e 100644 --- a/docs/user-manual/modules/ROOT/pages/using-exchange-pattern-annotations.adoc +++ b/docs/user-manual/modules/ROOT/pages/using-exchange-pattern-annotations.adoc @@ -1,11 +1,10 @@ = Using Exchange Pattern Annotations -Invoking InOut methods for ref:components:eips:requestReply-eip.adoc[request/reply] when working with xref:pojo-producing.adoc[POJO Producing] is typically synchronous. As such, the caller will block until the server returns a result. +Invoking InOut methods for xref:components:eips:requestReply-eip.adoc[request/reply] when +working with xref:pojo-producing.adoc[POJO Producing] is typically synchronous. +As such, the caller will block until the server returns a result. -[NOTE] -==== -InOut means that there is an In message for the input and an Out for the output/result. -==== +InOut means that there is an In message for the input and an Out for the output/result. [NOTE] ==== @@ -14,18 +13,15 @@ Other books, posts and reference guides may use the terms In/Out and In/Only for You can also implement support for xref:components:eips:event-message.adoc[Event Messages] with Apache Camel, using the InOnly xref:exchange-pattern.adoc[pattern]. These are often called "fire and forget" (i.e., like sending a JMS message but not waiting for any response). -Since version 1.5 Camel supports annotations for specifying the message -exchange pattern on Java methods, classes or interfaces. +== Specifying InOnly and InOut methods -[[UsingExchangePatternAnnotations-SpecifyingInOnlymethods]] -== Specifying InOnly methods - -Typically the InOut pattern is what most users want, but you can +Typically, the InOut pattern is what most users want, but you can customize to use InOnly using an annotation. For instance: -[source,syntaxhighlighter-pre] +[source,java] ---- public interface Foo { + Object someInOutMethod(String input); String anotherInOutMethod(Cheese input); @@ -35,16 +31,16 @@ public interface Foo { ---- The above code shows three methods on an interface: + * the first two use the default InOut mechanism -* the third one, `someInOnlyMethod` uses the InOnly annotation to specify it as being a one-way method call. +* the third one, `someInOnlyMethod` uses the `@InOnly` annotation to specify it as being a one-way method call. -[[UsingExchangePatternAnnotations-Classlevelannotations]] == Class level annotations You can also use class level annotations to default all methods in an interface to a pattern: -[source,syntaxhighlighter-pre] +[source,java] ---- @InOnly public interface Foo { @@ -55,22 +51,21 @@ public interface Foo { Apache Camel will detect annotations on base classes or interfaces. For instance, suppose you created a client side proxy for the following code: -[source,syntaxhighlighter-pre] +[source,java] ---- public class MyFoo implements Foo { ... } ---- -In this case, the methods inherited from Foo would be InOnly. - -[[UsingExchangePatternAnnotations-Overloadingaclasslevelannotation]] -== Overloading a class level annotation +In this case, the methods inherited from Foo would all be `@InOnly`. +=== Overloading a class level annotation -You can overload a class level annotation on specific methods. Suppose you have a class or interface with many InOnly methods, but you want to annote just one or two methods as InOut. You can do it like this: +You can overload a class level annotation on specific methods. Suppose you have a class or interface with many `@InOnly` methods, but you want to annotate just one or two methods as `@InOut`. +You can do it like this: -[source,syntaxhighlighter-pre] +[source,java] ---- @InOnly public interface Foo { @@ -82,38 +77,31 @@ public interface Foo { } ---- -In the above `Foo` interface the only the `someInOutMethod` will be InOut. +In the above `Foo` interface only the `someInOutMethod` will be `@InOut`, and all the others will be `@InOnly`. -[[UsingExchangePatternAnnotations-Usingyourownannotations]] -== Using your own annotations +== Using your own annotations for exchange patterns You might want to create your own annotations to represent a group of different bits of metadata; such as combining synchrony, concurrency and -transaction behaviour. +transaction behavior. In this case you can annotate your annotation with the `@Pattern` annotation to the default exchange pattern you wish to use. -For example, lets say we want to create our own annotation called -`@MyAsyncService`: +For example, lets say we want to create our own annotation called `@MyAsyncService`: -[source,syntaxhighlighter-pre] +[source,java] ---- @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) - -// lets add the message exchange pattern to it +// specify the message pattern @Pattern(ExchangePattern.InOnly) - -// lets add some other annotations - maybe transaction behaviour? - public @interface MyAsyncService { } ---- -Now we can use this annotation, and Camel will figure out the correct -exchange pattern. +Now we can use this annotation, and Camel will figure out the correct exchange pattern. -[source,syntaxhighlighter-pre] +[source,java] ---- public interface Foo { void someInOnlyMethod(Document input); diff --git a/docs/user-manual/modules/ROOT/pages/uuidgenerator.adoc b/docs/user-manual/modules/ROOT/pages/uuidgenerator.adoc index 14f80a59d919..a3205a44992d 100644 --- a/docs/user-manual/modules/ROOT/pages/uuidgenerator.adoc +++ b/docs/user-manual/modules/ROOT/pages/uuidgenerator.adoc @@ -5,22 +5,47 @@ Camel supports third-party UUID generator(s). A useful scenario is to use a simple counter for testing purpose. With this, it is easier to correlate the exchanges in the log/debugger. -Camel uses UUIDs in the exchange and message ids, and other unique ids -it uses. +Camel uses UUIDs in the exchange and message ids, and other unique ids it uses. You only have to implement `org.apache.camel.spi.UuidGenerator` and tell Camel, that it should use your custom implementation: -== Configuring UuidGenerator +== Standard UUID Generators -[source,java] +Camel comes with the following implementations out of the box: + +* `org.apache.camel.support.ClassicUuidGenerator`: this is the classic Camel 2.x generator +* `org.apache.camel.support.DefaultUuidGenerator`: default generator (32 chars) optimized for Camel usage +* `org.apache.camel.support.ShortUuidGenerator`: Is 50% the size of the default (16 chars) optimized for Camel usage +* `org.apache.camel.support.SimpleUuidGenerator`: This implementation uses +internally a `java.util.concurrent.atomic.AtomicLong` and increases the +ID for every call by one. Starting with 1 as the first id. +* `org.apache.camel.support.RandomUuidGenerator`: type 4 (pseudo randomly generated) UUID. +The UUID is generated using a cryptographically strong pseudo random number generator. + +You can configure which standard generator to use in `application.properties`: + +[source,properties] ---- -getContext().setUuidGenerator(new MyCustomUuidGenerator()); +camel.main.uuidGenerator = simple ---- -Camel will configure this UUID generator by doing a lookup in the Spring -bean registry to find the bean of the type `org.apache.camel.spi.UuidGenerator`. +=== Configuring custom UuidGenerator + +You can implement a custom `UuidGenerator` which you can set up in Camel to use: + +[tabs] +==== +Java:: ++ +[source,java] +---- +camelContext.setUuidGenerator(new MyCustomUuidGenerator()); +---- + +Spring XML:: ++ [source,xml] ---- <bean id="simpleUuid" class="org.apache.camel.support.SimpleUuidGenerator" /> @@ -33,15 +58,4 @@ bean registry to find the bean of the type `org.apache.camel.spi.UuidGenerator`. </camelContext> ---- -== Standard UUID Generators - -Camel comes with the following implementations out of the box: - -* `org.apache.camel.support.ClassicUuidGenerator`: this is the classic Camel 2.x generator -* `org.apache.camel.support.DefaultUuidGenerator`: default generator (32 chars) optimized for Camel usage -* `org.apache.camel.support.ShortUuidGenerator`: Is 50% the size of the default (16 chars) optimized for Camel usage -* `org.apache.camel.support.SimpleUuidGenerator`: This implementation uses -internally a `java.util.concurrent.atomic.AtomicLong` and increases the -ID for every call by one. Starting with 1 as the first id. -* `org.apache.camel.support.RandomUuidGenerator`: type 4 (pseudo randomly generated) UUID. -The UUID is generated using a cryptographically strong pseudo random number generator. \ No newline at end of file +====
