Skip to content

Latest commit

 

History

History
68 lines (43 loc) · 1.41 KB

README.adoc

File metadata and controls

68 lines (43 loc) · 1.41 KB

Camel MongoDB Example

This example shows how to use Camel MongoDB component. There are three REST endpoints that will trigger the MongoDB component for reading and for writing.

Run a MongoDB instance

You need to have an instance of MongoDB server running locally.

You can run it as a Docker container:

docker run -d --name mongodb -p 27017:27017 mongo

Build

You will need to compile this example first:

$ mvn compile

Run the Camel integration

You can now run your application by executing:

$ mvn exec:java

Make some test call

You can insert an "hello" document by POSTing to /hello endpoint:

$ curl -X POST -H "Content-Type: application/json" -d '{"text":"Hello from Camel"}' http://localhost:8081/hello

The result of the query is of type:

$ Document{{text=Hello from Camel, _id=<document-id>}}

You can read all the documents by requesting to / endpoint:

$ curl localhost:8081

You can also read a single document by setting the id query parameter to the target <document-id>:

$ curl "localhost:8081/hello?id=<document-id>"

Help and contributions

If you hit any problem using Camel or have some feedback, then please let us know.

We also love contributors, so get involved :-)

The Camel riders!