Search code examples
xquerymarklogic-10

I have a REST endpoint exposed in JAVA that I need to invoke through Marklogic- What can be the Best Way?


I have a REST endpoint with URL http://localhost:8080/notify/services/refesh/clauses-count exposed in Java that needs to be invoked through Marklogic whenever a new document is ingested into the MarkLogic database.

What would be the best Approach?


Solution

  • The best approach depends upon a lot of factors, including volume of traffic, how you expect to handle errors, performance, etc.

    If you want to invoke the REST endpoint from MarkLogic any time that a document is inserted, you could leverage any of the xdmp:http-* methods:

    You could make those calls within the code that is inserting the document, or if the documents might be inserted by something outside of your control and you still want to be able to make the REST calls, then you could implement a trigger or leverage the Content Processing Framework.

    There are pros and cons to either of them with regards to performance, guarantees and ability to survive a restart, etc.

    Another option would be to have the code/process responsible for inserting documents into MarkLogic also make the REST calls to the Java service.