...
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="mongoBean" class="com.mongodb.Mongo"> <constructor-arg name="host" value="${mongodb.host}" /> <constructor-arg name="port" value="${mongodb.port}" /> </bean> </beans> |
In case you are using a 3.x MongoDB instance you have to use the following bean
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="mongoBean" class="com.mongodb.MongoClient">
<constructor-arg name="host" value="${mongodb.host}" />
<constructor-arg name="port" value="${mongodb.port}" />
</bean>
</beans> |
Sample route
The following route defined in Spring XML executes the operation dbStats on a collection.
...
- MongoDB website
- NoSQL Wikipedia article
- MongoDB Java driver API docs - current version
- Unit tests for more examples of usage
https://github.com/apache/camel/blob/master/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc