4

I am trying out to pick up a JSON file from filesystem and am trying to insert the file to MarkLogic database.

<route id="file_upload">
  <!-- incoming requests from the file is routed -->
  <from uri="file:/E:/camel/input"/>
  <to uri="http://localhost:8005/v1/documents?uri/patents/test.json"/>
</route>

Username and password is : admin/admin for MarkLogic REST instance running on 8005

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
Vikram
  • 635
  • 1
  • 9
  • 29
  • 2
    You did not ask a question. (Also, you're missing an equal sign between the `uri` request parameter name and its value in your "to" element.) – kcoleman Aug 02 '16 at 19:35
  • @kcoleman Thanks. I added the equals. I am getting an target invocation exception. I want to insert values to marklogic without using the mlcp component with the java/rest api of marklogic. How can i achieve that. Is there any working example so that i can have a look at it ! – Vikram Aug 03 '16 at 09:22

1 Answers1

5

There are examples of Camel/MarkLogic integration at https://github.com/rjrudin/ml-camel-client . Those just use mlcp (as an embedded library) and XCC - I'll add a REST API example right now and reply back.

https://github.com/rjrudin/marklogic-camel-demo shows further integration, though the config is in Java instead of XML (I find Java to be easier to work with in Camel) - note how the HTTP headers and querystring need to be passed in as Camel headers, not as part of the URI - https://github.com/rjrudin/marklogic-camel-demo/blob/master/src/main/java/org/example/util/RunCamel.java#L76 . That's documented in the Camel http4 page as well - http://camel.apache.org/http4.html

rjrudin
  • 2,108
  • 9
  • 7
  • Here's an example of file -> REST API - https://github.com/rjrudin/ml-camel-client/blob/master/src/main/resources/META-INF/camel-routes.xml#L35 . Note that it's assuming XML as the content type, and it's doing a POST, so you get a MarkLogic-generated URI. But this is just a starting point, you can customize it based on all of the parameters that /v1/documents supports. – rjrudin Aug 03 '16 at 12:41
  • Thanks for the example and links provided. Please keep me posted if you add an rest-api example it helps even more. – Vikram Aug 03 '16 at 13:48
  • Can you help me with an example on adding metadata to the document that we are going to Insert and post it to a specific URI ?? – Vikram Aug 10 '16 at 14:16
  • Do you mean metadata, as in permissions or collections, or as additional elements in the document? – rjrudin Aug 19 '16 at 11:53
  • adding properties to the document like last-modified and adding the document to a User specific URI rather than marklogic creating a URI for us... – Vikram Aug 22 '16 at 11:43
  • last-modified is controlled by the database - see the Database config page for your database, there's a radio button for turning last-modified on/off. And to control the URI, send a PUT instead of a POST - see http://docs.marklogic.com/REST/PUT/v1/documents – rjrudin Aug 24 '16 at 01:32