This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit ed41d445b77988eaa08b120c18c768c3791ce299 Author: Andrea Cosentino <[email protected]> AuthorDate: Fri Aug 2 12:45:28 2019 +0200 CAMEL-13792 - Rename components to default names, Camel-mongodb3 to camel-mongodb - Docs and regen --- apache-camel/pom.xml | 4 +- apache-camel/src/main/descriptors/common-bin.xml | 2 +- bom/camel-bom/pom.xml | 6 +- .../src/main/docs/mongodb-component.adoc | 10 +- components/readme.adoc | 4 +- docs/components/modules/ROOT/nav.adoc | 2 +- .../modules/ROOT/pages/infinispan-component.adoc | 575 ++++++++++++++++++++- ...godb3-component.adoc => mongodb-component.adoc} | 80 +-- docs/user-manual/modules/ROOT/pages/index.adoc | 2 +- parent/pom.xml | 4 +- platforms/spring-boot/components-starter/pom.xml | 1 - .../camel-spring-boot-dependencies/pom.xml | 6 +- 12 files changed, 631 insertions(+), 65 deletions(-) diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index d72f2ba..ba58248 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -999,12 +999,12 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb-gridfs</artifactId> + <artifactId>camel-mongodb</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb</artifactId> + <artifactId>camel-mongodb-gridfs</artifactId> <version>${project.version}</version> </dependency> <dependency> diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index f9d89a3..90abf7a 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -220,8 +220,8 @@ <include>org.apache.camel:camel-mina2</include> <include>org.apache.camel:camel-mllp</include> <include>org.apache.camel:camel-mock</include> - <include>org.apache.camel:camel-mongodb-gridfs</include> <include>org.apache.camel:camel-mongodb</include> + <include>org.apache.camel:camel-mongodb-gridfs</include> <include>org.apache.camel:camel-mqtt</include> <include>org.apache.camel:camel-msv</include> <include>org.apache.camel:camel-mustache</include> diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml index 6f9e416..f1ed1c8 100644 --- a/bom/camel-bom/pom.xml +++ b/bom/camel-bom/pom.xml @@ -1920,17 +1920,17 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb-gridfs</artifactId> + <artifactId>camel-mongodb</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb-gridfs-starter</artifactId> + <artifactId>camel-mongodb-gridfs</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb</artifactId> + <artifactId>camel-mongodb-gridfs-starter</artifactId> <version>${project.version}</version> </dependency> <dependency> diff --git a/components/camel-mongodb/src/main/docs/mongodb-component.adoc b/components/camel-mongodb/src/main/docs/mongodb-component.adoc index 455d892..ef3f9de 100644 --- a/components/camel-mongodb/src/main/docs/mongodb-component.adoc +++ b/components/camel-mongodb/src/main/docs/mongodb-component.adoc @@ -133,7 +133,7 @@ When using Spring Boot make sure to use the following Maven dependency to have s ---- <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb3-starter</artifactId> + <artifactId>camel-mongodb-starter</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> @@ -147,10 +147,10 @@ The component supports 4 options, which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *camel.component.mongodb3.basic-property-binding* | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | Boolean -| *camel.component.mongodb3.enabled* | Enable mongodb3 component | true | Boolean -| *camel.component.mongodb3.mongo-connection* | Set a client used for connection: all endpoints generated from the component will share this connection bean. The option is a com.mongodb.MongoClient type. | | String -| *camel.component.mongodb3.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean +| *camel.component.mongodb.basic-property-binding* | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | Boolean +| *camel.component.mongodb.enabled* | Whether to enable auto configuration of the mongodb component. This is enabled by default. | | Boolean +| *camel.component.mongodb.mongo-connection* | Set a client used for connection: all endpoints generated from the component will share this connection bean. The option is a com.mongodb.MongoClient type. | | String +| *camel.component.mongodb.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean |=== // spring-boot-auto-configure options: END diff --git a/components/readme.adoc b/components/readme.adoc index d56bae2..d857c24 100644 --- a/components/readme.adoc +++ b/components/readme.adoc @@ -574,8 +574,8 @@ Number of Components: 297 in 234 JAR artifacts (0 deprecated) | link:camel-mock/src/main/docs/mock-component.adoc[Mock] (camel-mock) + `mock:name` | 1.0 | The mock component is used for testing routes and mediation rules using mocks. -| link:camel-mongodb3/src/main/docs/mongodb3-component.adoc[MongoDB] (camel-mongodb3) + -`mongodb3:connectionBean` | 2.19 | Component for working with documents stored in MongoDB database. +| link:camel-mongodb/src/main/docs/mongodb-component.adoc[MongoDB] (camel-mongodb) + +`mongodb:connectionBean` | 2.19 | Component for working with documents stored in MongoDB database. | link:camel-mongodb-gridfs/src/main/docs/mongodb-gridfs-component.adoc[MongoDB GridFS] (camel-mongodb-gridfs) + `mongodb-gridfs:connectionBean` | 2.18 | Component for working with MongoDB GridFS. diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc index 0f375ae..eaf1bea 100644 --- a/docs/components/modules/ROOT/nav.adoc +++ b/docs/components/modules/ROOT/nav.adoc @@ -237,7 +237,7 @@ * xref:mllp-component.adoc[MLLP Component] * xref:mock-component.adoc[Mock Component] * xref:mongodb-gridfs-component.adoc[MongoDB GridFS Component] -* xref:mongodb3-component.adoc[MongoDB Component] +* xref:mongodb-component.adoc[MongoDB Component] * xref:mqtt-component.adoc[MQTT Component] * xref:msv-component.adoc[MSV Component] * xref:mustache-component.adoc[Mustache Component] diff --git a/docs/components/modules/ROOT/pages/infinispan-component.adoc b/docs/components/modules/ROOT/pages/infinispan-component.adoc index 3729d9a..b12c1c7 100644 --- a/docs/components/modules/ROOT/pages/infinispan-component.adoc +++ b/docs/components/modules/ROOT/pages/infinispan-component.adoc @@ -10,8 +10,21 @@ store and data grid platform written in Java. Infinispan requires at least Java 8. -Maven users will need to add the following dependency to their `pom.xml` -for this component: +The `camel-infinispan` component includes the following features: + +* *Local Camel Consumer* - Receives cache change notifications and sends them to be processed. +This can be done synchronously or asynchronously, and is also supported with a replicated or distributed cache. + +* *Local Camel Producer* - A producer creates and sends messages to an endpoint. +The `camel-infinispan` producer uses ``GET``, ``PUT``, ``REMOVE``, and `CLEAR` operations. +The local producer is also supported with a replicated or distributed cache. + +* *Remote Camel Producer* - In Remote Client-Server mode, the Camel producer can send messages using Hot Rod. + +* *Remote Camel Consumer* - In Client-Server mode, receives cache change notifications and sends them to be processed. +The events are processed asynchronously. + +If you use Maven, you must add the following dependency to your `pom.xml`: [source,xml] ------------------------------------------------------------ @@ -153,6 +166,257 @@ The component supports 23 options, which are listed below. |=== // spring-boot-auto-configure options: END +== Camel Operations +This section lists all available operations, along with their header information. + +.Put Operations +[cols="40%,60%", frame="all", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.PUT +| *Context*: Embedded / Remote + +*Description*: Puts a key/value pair in the cache, optionally with expiration + +*Required Headers*: CamelInfinispanKey, CamelInfinispanValue + +*Optional Headers*: CamelInfinispanLifespanTime, CamelInfinispanLifespanTimeUnit, CamelInfinispanMaxIdleTime, CamelInfinispanMaxIdleTimeUnit, CamelInfinispanIgnoreReturnValues + +*Result Header*: CamelInfinispanOperationResult + +| InfinispanOperation.PUTASYNC +| *Description*: Asynchronously puts a key/value pair in the cache, optionally with expiration + + +| InfinispanOperation.PUTIFABSENT +| *Description*: Puts a key/value pair in the cache if it did not exist, optionally with expiration + + +| InfinispanOperation.PUTIFABSENTASYNC +| *Description*: Asynchronously puts a key/value pair in the cache if it did not exist, optionally with expiration + +|=== + +.Put All Operations +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.PUTALL +| *Context*: Embedded / Remote + +*Description*: Adds multiple entries to a cache, optionally with expiration + +*Required Headers*: CamelInfinispanMap + +*Optional Headers*: CamelInfinispanLifespanTime, CamelInfinispanLifespanTimeUnit, CamelInfinispanMaxIdleTime, CamelInfinispanMaxIdleTimeUnit + +*Result Header*: None + +| CamelInfinispanOperation.PUTALLASYNC +| *Description*: Asynchronously adds multiple entries to a cache, optionally with expiration + +|=== + +.Get Operations +[cols="40%,60%", frame="all", options="header"] +|=== +|Operation Name +|Description + +| InfinispanOperation.GET +| *Context*: Embedded / Remote + +*Description*: Retrieves the value associated with a specific key from the cache + +*Required Headers*: CamelInfinispanKey + +*Optional Headers*: None + +*Result Header*: None + +| InfinispanOperation.GETORDEFAULT +| *Context*: Embedded / Remote + +*Description*: Retrieves the value, or default value, associated with a specific key from the cache + +*Required Headers*: CamelInfinispanKey + +*Optional Headers*: None + +*Result Header*: None +|=== + +.Contains Key Operation +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.CONTAINSKEY +| *Context*: Embedded / Remote + +*Description*: Determines whether a cache contains a specific key + +*Required Headers*: CamelInfinispanKey + +*Optional Headers*: None + +*Result Header*: CamelInfinispanOperationResult +|=== + +.Contains Value Operation +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.CONTAINSVALUE +| *Context*: Embedded / Remote + +*Description*: Determines whether a cache contains a specific value + +*Required Headers*: CamelInfinispanKey + +*Optional Headers*: None + +*Result Headers*: None +|=== + +.Remove Operations +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.REMOVE +| *Context*: Embedded / Remote + +*Description*: Removes an entry from a cache, optionally only if the value matches a given one + +*Required Headers*: CamelInfinispanKey + +*Optional Headers*: CamelInfinispanValue + +*Result Header*: CamelInfinispanOperationResult + +| InfinispanOperation.REMOVEASYNC +| *Description*: Asynchronously removes an entry from a cache, optionally only if the value matches a given one + +|=== + +.Replace Operations +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.REPLACE +| *Context*: Embedded / Remote + +*Description*: Conditionally replaces an entry in the cache, optionally with expiration + +*Required Headers*: CamelInfinispanKey, CamelInfinispanValue, CamelInfinispanOldValue + +*Optional Headers*: CamelInfinispanLifespanTime, CamelInfinispanLifespanTimeUnit, CamelInfinispanMaxIdleTime, CamelInfinispanMaxIdleTimeUnit, CamelInfinispanIgnoreReturnValues + +*Result Header*: CamelInfinispanOperationResult + +| InfinispanOperation.REPLACEASYNC +| *Description*: Asynchronously conditionally replaces an entry in the cache, optionally with expiration + +|=== + +.Clear Operations +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.CLEAR +| *Context*: Embedded / Remote + +*Description*: Clears the cache + +*Required Headers*: None + +*Optional Headers*: None + +*Result Header*: None + +| InfinispanOperation.CLEARASYNC +| *Context*: Embedded / Remote + +*Description*: Asynchronously clears the cache + +*Required Headers*: None + +*Optional Headers*: None + +*Result Header*: None +|=== + +.Size Operation +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.SIZE +| *Context*: Embedded / Remote + +*Description*: Returns the number of entries in the cache + +*Required Headers*: None + +*Optional Headers*: None + +*Result Header*: CamelInfinispanOperationResult +|=== + +.Stats Operation +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.STATS +| *Context*: Embedded / Remote + +*Description*: Returns statistics about the cache + +*Required Headers*: None + +*Optional Headers*: None + +*Result Header*: CamelInfinispanOperationResult +|=== + +.Query Operation +[cols="40%,60%", options="header"] +|=== +| Operation Name +| Description + +| InfinispanOperation.QUERY +| *Context*: Remote + +*Description*: Executes a query on the cache + +*Required Headers*: CamelInfinispanQueryBuilder + +*Optional Headers*: None + +*Result Header*: CamelInfinispanOperationResult +|=== + +[NOTE] +==== +Any operations that take `CamelInfinispanIgnoreReturnValues` will receive a null result. +==== @@ -189,6 +453,7 @@ from("direct:start") .to("infinispan?cacheContainer=#cacheContainer"); ---- + * Retrieve a specific key from a named cache: + [source,java] @@ -247,6 +512,310 @@ from("direct:start") ---- + +=== XML examples + +Routing can also be performed using XML configuration. +The following example demonstrates `camel-infinispan` `local-camel-producer`, a camel route that sends data to an embedded cache created by the `local-cache` module. + +[source,java,options="nowrap"] +---- +<camelContext id="local-producer" xmlns="http://camel.apache.org/schema/blueprint"> + <route> + <from uri="timer://local?fixedRate=true&period=5000"/> + <setHeader headerName="CamelInfinispanKey"> + <constant>CamelTimerCounter</constant> + </setHeader> + <setHeader headerName="CamelInfinispanValue"> + <constant>CamelTimerCounter</constant> + </setHeader> + <to uri="infinispan://foo?cacheContainer=#cacheManager"/> + <to uri="log:local-put?showAll=true"/> + </route> +</camelContext> +---- + + +The provided example requires you to instantiate the [class]``cacheManager``. + +You can instantiate the [class]``cacheManager`` bean for Spring XML as follows: + +[source,xml,options="nowrap"] +---- +<bean id="cacheManager" class="org.infinispan.manager.DefaultCacheManager" init-method="start" destroy-method="stop"> + <constructor-arg type="java.lang.String" value="infinispan.xml"/> +</bean> +---- + + +The following demonstrates how to instantiate the [class]``cacheManager`` bean using Blueprint XML. + +[source,xml,options="nowrap"] +---- +<bean id="cacheManager" class="org.infinispan.manager.DefaultCacheManager" init-method="start" destroy-method="stop"> + <argument value="infinispan.xml" /> +</bean> +---- + +[NOTE] +==== +Both the Spring XML and Blueprint XML examples use the configuration file [path]_infinispan.xml_ + for configuration of the cache. This file must be present on the classpath. +==== + + +== Remote Query + +When executing remote queries the cacheManager must be an instance of ``RemoteCacheManager``, and an example configuration utilizing a `RemoteCacheManager` is found below for both Java and blueprint.xml: + +.Using only Java +==== +[source,java,options="nowrap"] +---- +from("direct:start") + .setHeader(InfinispanConstants.OPERATION, InfinispanConstants.QUERY) + .setHeader(InfinispanConstants.QUERY_BUILDER, + new InfinispanQueryBuilder() { + public Query build(QueryFactory<Query> queryFactory) { + return queryFactory.from(User.class).having("name").like("%abc%") + .build(); + } + }) + .to("infinispan://localhost?cacheContainer=#cacheManager&cacheName=remote_query_cache") ; +---- +==== + +.Using Blueprint and Java +==== +.Java [class]``RemoteCacheManagerFactory`` class: +[source,java,options="nowrap"] +---- +public class RemoteCacheManagerFactory { + ConfigurationBuilder clientBuilder; + public RemoteCacheManagerFactory(String hostname, int port) { + clientBuilder = new ConfigurationBuilder(); + clientBuilder.addServer() + .host(hostname).port(port); + } + public RemoteCacheManager newRemoteCacheManager() { + return new RemoteCacheManager(clientBuilder.build()); + } +} +---- +.Java [class]``InfinispanQueryExample`` class: +[source,java,options="nowrap"] +---- +public class InfinispanQueryExample { + public InfinispanQueryBuilder getBuilder() { + return new InfinispanQueryBuilder() { + public Query build(QueryFactory<Query> queryFactory) { + return queryFactory.from(User.class) + .having("name") + .like("%abc%") + .build(); + } + } + } +} +---- +.blueprint.xml: +[source,xml,options="nowrap"] +---- +<bean id=”remoteCacheManagerFactory” class=“com.datagrid.RemoteCacheManagerFactory”> + <argument value=”localhost”/> + <argument value="11222”/> +</bean> + +<bean id=”cacheManager” + factory-ref=”remoteCacheManagerFactory” + factory-method=“newRemoteCacheManager”> +</bean> + +<bean id="queryBuilder" class="org.example.com.InfinispanQueryExample"/> + +<camelContext id="route" xmlns="http://camel.apache.org/schema/blueprint"> + <route> + <from uri="direct:start"/> + <setHeader headerName="CamelInfinispanOperation"> + <constant>CamelInfinispanOperationQuery</constant> + </setHeader> + <setHeader headerName="CamelInfinispanQueryBuilder"> + <method ref="queryBuilder" method="getBuilder"/> + </setHeader> + <to uri="infinispan://localhost?cacheContainer=#cacheManager&cacheName=remote_query_cache"/> + </route> +</camelContext> +---- +==== + +The `remote_query_cache` is an arbitrary name for a cache that holds the data, and the results of the query will be a list of domain objects stored as a `CamelInfinispanOperationResult` header. + +In addition, there are the following requirements: + +* The [class]``RemoteCacheManager`` must be configured to use [class]``ProtoStreamMarshaller``. +* The [class]``ProtoStreamMarshaller`` must be registered with the [class]``RemoteCacheManager``'s serialization context. +* The .proto descriptors for domain objects must be registered with the remote Data Grid server. + + +== Custom Listeners for Embedded Cache + +Custom Listeners for an embedded cache can be registered through the [parameter]``customListener`` parameter as shown below: + +.Using Java + +[source,java,options="nowrap"] +---- +from("infinispan://?cacheContainer=#myCustomContainer&cacheName=customCacheName&customListener=#myCustomListener") + .to("mock:result"); +---- + +.Using Blueprint + +[source,xml,options="nowrap"] +---- +<bean id="myCustomContainer" org.infinispan.manager.DefaultCacheManager" + init-method="start" destroy-method="stop"> + <argument value="infinispan.xml" /> +</bean> + +<bean id="myCustomListener" class="org.example.com.CustomListener"/> + +<camelContext id="route" xmlns="http://camel.apache.org/schema/blueprint"> + <route> + <from uri="infinispan://?cacheContainer=#myCustomContainer&cacheName=customCacheName&customListener=#myCustomListener"/> + <to uri="mock:result"/> + </route> +</camelContext> +---- + + +The instance of [class]``myCustomListener`` must exist. +Users are encouraged to extend the [class]``org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedCustomListener`` and annotate the resulting class with the `@Listener` annotation from [package]#org.infinispan.notifications# +. + +[NOTE] +==== +Custom filters and converters for embedded caches are currently not supported. +==== + + +== Custom Listeners for Remote Cache + +Custom listeners for a remote cache can be registered in the same way as an embedded cache, with the exception that [parameter]``sync=false`` must be present. +For instance: + +.Using only Java +==== +[source,java,options="nowrap"] +---- +from(infinispan://?cacheContainer=#cacheManager&sync=false&customListener=#myCustomListener") + .to(mock:result); +---- +==== + +.Using Blueprint and Java +==== +.Java class: +[source,java,options="nowrap"] +---- + +public class RemoteCacheManagerFactory { + ConfigurationBuilder clientBuilder; + public RemoteCacheManagerFactory(String hostname, int port) { + clientBuilder = new ConfigurationBuilder(); + clientBuilder.addServer() + .host(hostname).port(port); + } + public RemoteCacheManager newRemoteCacheManager() { + return new RemoteCacheManager(clientBuilder.build()); + } +} +---- +.blueprint.xml: +[source,xml,options="nowrap"] +---- +<bean id=”remoteCacheManagerFactory” class=“com.datagrid.RemoteCacheManagerFactory”> + <argument value=”localhost”/> + <argument value="11222”/> +</bean> + +<bean id=”cacheManager” + factory-ref=”remoteCacheManagerFactory” + factory-method=“newRemoteCacheManager”> +</bean> + +<bean id="myCustomListener" class="org.example.com.CustomListener"/> + +<camelContext id="route" xmlns="http://camel.apache.org/schema/blueprint"> + <route> + <from uri="infinispan://?cacheContainer=#cacheManager&sync=false&customListener=#myCustomListener"/> + <to uri="mock:result"/> + </route> +</camelContext> +---- +==== + +The instance of [class]``myCustomListener`` must exist. +Users are encouraged to extend the [class]``org.apache.camel.component.infinispan.remote.InfinispanRemoteCustomListener`` class and annotate the resulting class with ``@ClientListener``; this annotation is found in [package]#org.infinispan.client.hotrod.annotation# +. + +Remote listeners may also be associated with custom filters and converters as shown below: +[source,java,options="nowrap"] +---- +@ClientListener(includeCurrentState=true, filterFactoryName = "static-filter-factory", converterFactoryName = "static-converter-factory") + private static class MyCustomListener extends InfinispanRemoteCustomListener { +} +---- + +In order to use custom filters or converters classes annotated with `@NamedFactory` must be implemented. +A skeleton that implements the necessary methods is shown below: +[source,java,options="nowrap"] +---- +import org.infinispan.notifications.cachelistener.filter; + +@NamedFactory(name = "static-converter-factory") +public static class StaticConverterFactory implements CacheEventConverterFactory { + @Override + public CacheEventConverter<Integer, String, CustomEvent> getConverter(Object[] params) { + ... + } + + static class StaticConverter implements CacheEventConverter<Integer, String, CustomEvent>, Serializable { + @Override + public CustomEvent convert(Integer key, String previousValue, Metadata previousMetadata, + String value, Metadata metadata, EventType eventType) { + ... + } + } +} + +@NamedFactory(name = "static-filter-factory") +public static class StaticCacheEventFilterFactory implements CacheEventFilterFactory { + @Override + public CacheEventFilter<Integer, String> getFilter(final Object[] params) { + ... + } + + static class StaticCacheEventFilter implements CacheEventFilter<Integer, String>, Serializable { + @Override + public boolean accept(Integer key, String previousValue, Metadata previousMetadata, + String value, Metadata metadata, EventType eventType) { + ... + } + } +} +---- + +Custom filters and converters must be registered with the server. +. + +[NOTE] +==== +In order to listen for remote HotRod events the cacheManager must be of type [class]``RemoteCacheManager`` and instantiated. +==== + + + == Using the Infinispan based idempotent repository In this section we will use the Infinispan based idempotent repository. @@ -291,8 +860,6 @@ XML file as well: </camelContext> ---- -== Using the Infinispan based route policy - == See Also * Configuring Camel diff --git a/docs/components/modules/ROOT/pages/mongodb3-component.adoc b/docs/components/modules/ROOT/pages/mongodb-component.adoc similarity index 92% rename from docs/components/modules/ROOT/pages/mongodb3-component.adoc rename to docs/components/modules/ROOT/pages/mongodb-component.adoc index 9c55c50..ef3f9de 100644 --- a/docs/components/modules/ROOT/pages/mongodb3-component.adoc +++ b/docs/components/modules/ROOT/pages/mongodb-component.adoc @@ -1,9 +1,9 @@ -[[mongodb3-component]] +[[mongodb-component]] = MongoDB Component *Available as of Camel version 2.19* -Note: Camel MongoDB3 component Use the Mongo Driver for Java 3.x. +Note: Camel MongoDB component Use the Mongo Driver for Java 3.x. If your are looking for previews versions look the Camel MongoDB component. According to Wikipedia: "NoSQL is a movement promoting a loosely defined @@ -38,7 +38,7 @@ for this component: ------------------------------------------------------------ <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb3</artifactId> + <artifactId>camel-mongodb</artifactId> <version>x.y.z</version> <!-- use the same version as your Camel core version --> </dependency> @@ -48,7 +48,7 @@ for this component: [source,java] --------------------------------------------------------------------------------------------------------------- -mongodb3:connectionBean?database=databaseName&collection=collectionName&operation=operationName[&moreOptions...] +mongodb:connectionBean?database=databaseName&collection=collectionName&operation=operationName[&moreOptions...] --------------------------------------------------------------------------------------------------------------- == MongoDB options @@ -77,7 +77,7 @@ The MongoDB component supports 3 options, which are listed below. The MongoDB endpoint is configured using URI syntax: ---- -mongodb3:connectionBean +mongodb:connectionBean ---- with the following path and query parameters: @@ -133,7 +133,7 @@ When using Spring Boot make sure to use the following Maven dependency to have s ---- <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb3-starter</artifactId> + <artifactId>camel-mongodb-starter</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> @@ -147,10 +147,10 @@ The component supports 4 options, which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *camel.component.mongodb3.basic-property-binding* | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | Boolean -| *camel.component.mongodb3.enabled* | Enable mongodb3 component | true | Boolean -| *camel.component.mongodb3.mongo-connection* | Set a client used for connection: all endpoints generated from the component will share this connection bean. The option is a com.mongodb.MongoClient type. | | String -| *camel.component.mongodb3.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean +| *camel.component.mongodb.basic-property-binding* | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | Boolean +| *camel.component.mongodb.enabled* | Whether to enable auto configuration of the mongodb component. This is enabled by default. | | Boolean +| *camel.component.mongodb.mongo-connection* | Set a client used for connection: all endpoints generated from the component will share this connection bean. The option is a com.mongodb.MongoClient type. | | String +| *camel.component.mongodb.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean |=== // spring-boot-auto-configure options: END @@ -194,7 +194,7 @@ The following route defined in Spring XML executes the operation <route> <from uri="direct:start" /> <!-- using bean 'mongoBean' defined above --> - <to uri="mongodb3:mongoBean?database=${mongodb.database}&collection=${mongodb.collection}&operation=getDbStats" /> + <to uri="mongodb:mongoBean?database=${mongodb.database}&collection=${mongodb.collection}&operation=getDbStats" /> <to uri="direct:result" /> </route> --------------------------------------------------------------------------------------------------------------------------- @@ -215,7 +215,7 @@ http://www.mongodb.org/display/DOCS/Java+Types[http://www.mongodb.org/display/DO [source,java] ------------------------------------------------------------------------------ from("direct:findById") - .to("mongodb3:myDb?database=flights&collection=tickets&operation=findById") + .to("mongodb:myDb?database=flights&collection=tickets&operation=findById") .to("mock:resultFindById"); ------------------------------------------------------------------------------ @@ -238,7 +238,7 @@ Example with no query (returns any object of the collection): [source,java] ------------------------------------------------------------------------------------ from("direct:findOneByQuery") - .to("mongodb3:myDb?database=flights&collection=tickets&operation=findOneByQuery") + .to("mongodb:myDb?database=flights&collection=tickets&operation=findOneByQuery") .to("mock:resultFindOneByQuery"); ------------------------------------------------------------------------------------ @@ -248,7 +248,7 @@ Example with a query (returns one matching result): ------------------------------------------------------------------------------------ from("direct:findOneByQuery") .setHeader(MongoDbConstants.CRITERIA, Filters.eq("name", "Raul Kripalani")) - .to("mongodb3:myDb?database=flights&collection=tickets&operation=findOneByQuery") + .to("mongodb:myDb?database=flights&collection=tickets&operation=findOneByQuery") .to("mock:resultFindOneByQuery"); ------------------------------------------------------------------------------------ @@ -271,7 +271,7 @@ Example with no query (returns all object in the collection): [source,java] ----------------------------------------------------------------------------- from("direct:findAll") - .to("mongodb3:myDb?database=flights&collection=tickets&operation=findAll") + .to("mongodb:myDb?database=flights&collection=tickets&operation=findAll") .to("mock:resultFindAll"); ----------------------------------------------------------------------------- @@ -281,7 +281,7 @@ Example with a query (returns all matching results): ----------------------------------------------------------------------------- from("direct:findAll") .setHeader(MongoDbConstants.CRITERIA, Filters.eq("name", "Raul Kripalani")) - .to("mongodb3:myDb?database=flights&collection=tickets&operation=findAll") + .to("mongodb:myDb?database=flights&collection=tickets&operation=findAll") .to("mock:resultFindAll"); ----------------------------------------------------------------------------- @@ -317,7 +317,7 @@ Example with option outputType=MongoIterable and batch size : from("direct:findAll") .setHeader(MongoDbConstants.BATCH_SIZE).constant(10) .setHeader(MongoDbConstants.CRITERIA, Filters.eq("name", "Raul Kripalani")) - .to("mongodb3:myDb?database=flights&collection=tickets&operation=findAll&outputType=MongoIterable") + .to("mongodb:myDb?database=flights&collection=tickets&operation=findAll&outputType=MongoIterable") .to("mock:resultFindAll"); ----------------------------------------------------------------------------- @@ -351,7 +351,7 @@ collection. [source,java] ------------------------------------------------------------------------------------------------------------------------------------ -// from("direct:count").to("mongodb3:myDb?database=tickets&collection=flights&operation=count&dynamicity=true"); +// from("direct:count").to("mongodb:myDb?database=tickets&collection=flights&operation=count&dynamicity=true"); Long result = template.requestBodyAndHeader("direct:count", "irrelevantBody", MongoDbConstants.COLLECTION, "dynamicCollectionName"); assertTrue("Result is not of type Long", result instanceof Long); ------------------------------------------------------------------------------------------------------------------------------------ @@ -385,7 +385,7 @@ the creation of Bson. It retrieves all fields except `_id` and [source,java] ---------------------------------------------------------------------------------------------------------------------------- -// route: from("direct:findAll").to("mongodb3:myDb?database=flights&collection=tickets&operation=findAll") +// route: from("direct:findAll").to("mongodb:myDb?database=flights&collection=tickets&operation=findAll") Bson fieldProjection = Projection.exclude("_id", "boringField"); Object result = template.requestBodyAndHeader("direct:findAll", ObjectUtils.NULL, MongoDbConstants.FIELDS_PROJECTION, fieldProjection); ---------------------------------------------------------------------------------------------------------------------------- @@ -396,7 +396,7 @@ the creation of Bson. It retrieves all fields except `_id` and [source,java] ---------------------------------------------------------------------------------------------------------------------------- -// route: from("direct:findAll").to("mongodb3:myDb?database=flights&collection=tickets&operation=findAll") +// route: from("direct:findAll").to("mongodb:myDb?database=flights&collection=tickets&operation=findAll") Bson fieldProjection = Projection.exclude("_id", "boringField"); Object result = template.requestBodyAndHeader("direct:findAll", ObjectUtils.NULL, MongoDbConstants.FIELDS_PROJECTION, fieldProjection); ---------------------------------------------------------------------------------------------------------------------------- @@ -411,7 +411,7 @@ the creation of Bson. It retrieves all fields except `_id` and [source,java] ---------------------------------------------------------------------------------------------------------------------------- -// route: from("direct:findAll").to("mongodb3:myDb?database=flights&collection=tickets&operation=findAll") +// route: from("direct:findAll").to("mongodb:myDb?database=flights&collection=tickets&operation=findAll") Bson sorts = Sorts.descending("_id"); Object result = template.requestBodyAndHeader("direct:findAll", ObjectUtils.NULL, MongoDbConstants.SORT_BY, sorts); ---------------------------------------------------------------------------------------------------------------------------- @@ -430,7 +430,7 @@ to a single field, based on the `documentTimestamp` field: .setHeader(MongoDbConstants.SORT_BY).constant(Sorts.descending("documentTimestamp")) .setHeader(MongoDbConstants.FIELDS_PROJECTION).constant(Projection.include("documentTimestamp")) .setBody().constant("{}") -.to("mongodb3:myDb?database=local&collection=myDemoCollection&operation=findOneByQuery") +.to("mongodb:myDb?database=local&collection=myDemoCollection&operation=findOneByQuery") .to("direct:aMyBatisParameterizedSelect"); ---------------------------------------------------------------------------------------------------------------------------- @@ -450,7 +450,7 @@ Example: [source,java] ----------------------------------------------------------------------------- from("direct:insert") - .to("mongodb3:myDb?database=flights&collection=tickets&operation=insert"); + .to("mongodb:myDb?database=flights&collection=tickets&operation=insert"); ----------------------------------------------------------------------------- The operation will return a WriteResult, and depending on the @@ -512,7 +512,7 @@ For example: [source,java] --------------------------------------------------------------------------- from("direct:insert") - .to("mongodb3:myDb?database=flights&collection=tickets&operation=save"); + .to("mongodb:myDb?database=flights&collection=tickets&operation=save"); --------------------------------------------------------------------------- ==== update @@ -565,7 +565,7 @@ field equals true by setting the value of the "scientist" field to [source,java] ------------------------------------------------------------------------------------------------------------------------------------------ -// route: from("direct:update").to("mongodb3:myDb?database=science&collection=notableScientists&operation=update"); +// route: from("direct:update").to("mongodb:myDb?database=science&collection=notableScientists&operation=update"); Bson filterField = Filters.eq("filterField", true); String updateObj = Updates.set("scientist", "Darwin"); Object result = template.requestBodyAndHeader("direct:update", new Bson[] {filterField, Document.parse(updateObj)}, MongoDbConstants.MULTIUPDATE, true); @@ -573,7 +573,7 @@ Object result = template.requestBodyAndHeader("direct:update", new Bson[] {filte [source,java] ------------------------------------------------------------------------------------------------------------------------------------------ -// route: from("direct:update").to("mongodb3:myDb?database=science&collection=notableScientists&operation=update"); +// route: from("direct:update").to("mongodb:myDb?database=science&collection=notableScientists&operation=update"); Maps<String, Object> headers = new HashMap<>(2); headers.add(MongoDbConstants.MULTIUPDATE, true); headers.add(MongoDbConstants.FIELDS_FILTER, Filters.eq("filterField", true)); @@ -584,7 +584,7 @@ Object result = template.requestBodyAndHeaders("direct:update", updateObj, heade [source,java] ------------------------------------------------------------------------------------------------------------------------------------------ -// route: from("direct:update").to("mongodb3:myDb?database=science&collection=notableScientists&operation=update"); +// route: from("direct:update").to("mongodb:myDb?database=science&collection=notableScientists&operation=update"); String updateObj = "[{\"filterField\": true}, {\"$set\", {\"scientist\", \"Darwin\"}}]"; Object result = template.requestBodyAndHeader("direct:update", updateObj, MongoDbConstants.MULTIUPDATE, true); @@ -603,7 +603,7 @@ collection: [source,java] ------------------------------------------------------------------------------------------------------------------ -// route: from("direct:remove").to("mongodb3:myDb?database=science&collection=notableScientists&operation=remove"); +// route: from("direct:remove").to("mongodb:myDb?database=science&collection=notableScientists&operation=remove"); Bson conditionField = Filters.eq("conditionField", true); Object result = template.requestBody("direct:remove", conditionField); ------------------------------------------------------------------------------------------------------------------ @@ -660,12 +660,12 @@ body. [source,java] ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- -// route: from("direct:aggregate").to("mongodb3:myDb?database=science&collection=notableScientists&operation=aggregate"); +// route: from("direct:aggregate").to("mongodb:myDb?database=science&collection=notableScientists&operation=aggregate"); List<Bson> aggregate = Arrays.asList(match(or(eq("scientist", "Darwin"), eq("scientist", group("$scientist", sum("count", 1))); from("direct:aggregate") .setBody().constant(aggregate) - .to("mongodb3:myDb?database=science&collection=notableScientists&operation=aggregate") + .to("mongodb:myDb?database=science&collection=notableScientists&operation=aggregate") .to("mock:resultAggregate"); ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -693,7 +693,7 @@ List<Bson> aggregate = Arrays.asList(match(or(eq("scientist", "Darwin"), eq("sci from("direct:aggregate") .setHeader(MongoDbConstants.BATCH_SIZE).constant(10) .setBody().constant(aggregate) - .to("mongodb3:myDb?database=science&collection=notableScientists&operation=aggregate&outputType=MongoIterable") + .to("mongodb:myDb?database=science&collection=notableScientists&operation=aggregate&outputType=MongoIterable") .split(body()) .streaming() .to("mock:resultAggregate"); @@ -732,7 +732,7 @@ Usage example: [source,java] --------------------------------------------------------------------------------------------------------- -// from("direct:getDbStats").to("mongodb3:myDb?database=flights&collection=tickets&operation=getDbStats"); +// from("direct:getDbStats").to("mongodb:myDb?database=flights&collection=tickets&operation=getDbStats"); Object result = template.requestBody("direct:getDbStats", "irrelevantBody"); assertTrue("Result is not of type Document", result instanceof Document); --------------------------------------------------------------------------------------------------------- @@ -772,7 +772,7 @@ Usage example: [source,java] ----------------------------------------------------------------------------------------------------------- -// from("direct:getColStats").to("mongodb3:myDb?database=flights&collection=tickets&operation=getColStats"); +// from("direct:getColStats").to("mongodb:myDb?database=flights&collection=tickets&operation=getColStats"); Object result = template.requestBody("direct:getColStats", "irrelevantBody"); assertTrue("Result is not of type Document", result instanceof Document); ----------------------------------------------------------------------------------------------------------- @@ -789,7 +789,7 @@ Collection parameter is not use for this operation. [source,java] -------------------------------------------------------------------------------- -// route: from("command").to("mongodb3:myDb?database=science&operation=command"); +// route: from("command").to("mongodb:myDb?database=science&operation=command"); DBObject commandBody = new BasicDBObject("hostInfo", "1"); Object result = template.requestBody("direct:command", commandBody); -------------------------------------------------------------------------------- @@ -807,7 +807,7 @@ For example: [source,java] ----------------------------------------------------------------------------------------------------------------------------- -// from("direct:insert").to("mongodb3:myDb?database=flights&collection=tickets&operation=insert"); +// from("direct:insert").to("mongodb:myDb?database=flights&collection=tickets&operation=insert"); Object result = template.requestBodyAndHeader("direct:insert", "irrelevantBody", MongoDbConstants.OPERATION_HEADER, "count"); assertTrue("Result is not of type Long", result instanceof Long); ----------------------------------------------------------------------------------------------------------------------------- @@ -881,7 +881,7 @@ An example: [source,java] ----------------------------------------------------------------------------------------------------- -from("mongodb3:myDb?database=flights&collection=cancellations&tailTrackIncreasingField=departureTime") +from("mongodb:myDb?database=flights&collection=cancellations&tailTrackIncreasingField=departureTime") .id("tailableCursorConsumer1") .autoStartup(false) .to("mock:test"); @@ -935,7 +935,7 @@ the last processed value under the "lastTrackingValue" field [source,java] ----------------------------------------------------------------------------------------------------------------------------------- -from("mongodb3:myDb?database=flights&collection=cancellations&tailTrackIncreasingField=departureTime&persistentTailTracking=true" + +from("mongodb:myDb?database=flights&collection=cancellations&tailTrackIncreasingField=departureTime&persistentTailTracking=true" + "&persistentId=cancellationsTracker") .id("tailableCursorConsumer2") .autoStartup(false) @@ -949,7 +949,7 @@ field: [source,java] ----------------------------------------------------------------------------------------------------------------------------------- -from("mongodb3:myDb?database=flights&collection=cancellations&tailTrackIncreasingField=departureTime&persistentTailTracking=true" + +from("mongodb:myDb?database=flights&collection=cancellations&tailTrackIncreasingField=departureTime&persistentTailTracking=true" + "&persistentId=cancellationsTracker&tailTrackDb=trackers&tailTrackCollection=camelTrackers" + "&tailTrackField=lastProcessedDepartureTime") .id("tailableCursorConsumer3") @@ -971,7 +971,7 @@ It could be easily specified using XML DSL configuration: [source,xml] ------------- <route id="filterConsumer"> - <from uri="mongodb3:myDb?consumerType=changeStreams&database=flights&collection=tickets"/> + <from uri="mongodb:myDb?consumerType=changeStreams&database=flights&collection=tickets"/> <to uri="mock:test"/> <routeProperty key="streamFilter" value="{'$match':{'$or':[{'fullDocument.stringValue': 'specificValue'}]}}"/> @@ -981,7 +981,7 @@ It could be easily specified using XML DSL configuration: Java configuration: [source,java] ------------- -from("mongodb3:myDb?consumerType=changeStreams&database=flights&collection=tickets") +from("mongodb:myDb?consumerType=changeStreams&database=flights&collection=tickets") .routeProperty("streamFilter", "{'$match':{'$or':[{'fullDocument.stringValue': 'specificValue'}]}}") .to("mock:test"); ------------- diff --git a/docs/user-manual/modules/ROOT/pages/index.adoc b/docs/user-manual/modules/ROOT/pages/index.adoc index 789ae29..b9905c0 100644 --- a/docs/user-manual/modules/ROOT/pages/index.adoc +++ b/docs/user-manual/modules/ROOT/pages/index.adoc @@ -333,7 +333,7 @@ camel routes without them knowing ** xref:components::micrometer-component.adoc[Micrometer] ** xref:components::mina2-component.adoc[Mina2] ** xref:components::mllp-component.adoc[MLLP] -** xref:components::mongodb3-component.adoc[MongoDB] +** xref:components::mongodb-component.adoc[MongoDB] ** xref:components::mongodb-gridfs-component.adoc[MongoDB GridFS] ** xref:components::mqtt-component.adoc[MQTT] ** xref:components::msv-component.adoc[MSV] diff --git a/parent/pom.xml b/parent/pom.xml index a12b288..07be10e 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -1713,12 +1713,12 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb-gridfs</artifactId> + <artifactId>camel-mongodb</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb</artifactId> + <artifactId>camel-mongodb-gridfs</artifactId> <version>${project.version}</version> </dependency> <dependency> diff --git a/platforms/spring-boot/components-starter/pom.xml b/platforms/spring-boot/components-starter/pom.xml index e39603d..c5cdd9a 100644 --- a/platforms/spring-boot/components-starter/pom.xml +++ b/platforms/spring-boot/components-starter/pom.xml @@ -274,7 +274,6 @@ <module>camel-mock-starter</module> <module>camel-mongodb-gridfs-starter</module> <module>camel-mongodb-starter</module> - <module>camel-mongodb-starter</module> <module>camel-mqtt-starter</module> <module>camel-msv-starter</module> <module>camel-mustache-starter</module> diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml index 67fc4ec..c1281f8 100644 --- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml +++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml @@ -2145,17 +2145,17 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb-gridfs</artifactId> + <artifactId>camel-mongodb</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb-gridfs-starter</artifactId> + <artifactId>camel-mongodb-gridfs</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-mongodb</artifactId> + <artifactId>camel-mongodb-gridfs-starter</artifactId> <version>${project.version}</version> </dependency> <dependency>
