What is the basic difference between xdmp:spawn and xdmp:invoke a function in Marklogic.

 Aha.....

Before understanding xdmp:spawn-function and xdmp:invoke-function in Marklogic, we need to understand synchronous & asynchronous terms. Also, we need to know what is the main server, task server, and Transactions in the Marklogic.

So I'm posting here the simple definition of each term that I mentioned here. 

Synchronous and Asynchronous Task:

  • Synchronous: In synchronous operations tasks are performed one at a time and you can't move the following task until the current task is finished.
  • Asynchronous: In asynchronous operations, you can move to another task before the previous one finishes.
  • Main Server:
  • Task server:
  • Transactions:

Now,  We need to know what asynchronous functions & asynchronous functions in Marklogic are:

Asynchronous Functions:

  • xdmp:spawn: Place the specified module/query on the task queue for evaluation. This function places the specified module in the task queue to be processed. The module will be evaluated when the task server has the available resources to process it. Tasks are processed in the order in which they are added to the queue.
  • xdmp:spawn-function: The xdmp:spawn-function function places the specified function value in the task queue to be processed. The function will be executed when the task server has the available resources to process it. The tasks are processed in the order in which they are added to the queue.
Once both above functions are called, these cannot be rolled back, even if the transaction from which it is called does not complete. 

Synchronous Function:

  • xdmp:eval: Returns the result of evaluating a string as an XQuery module
  • xdmp:invoke: Returns the result of evaluating an XQuery or Server-Side JavaScript module at the given path.
  • xdmp:invoke-function: The XQuery version of this function (xdmp:invoke-function) can only be used to invoke XQuery functions. The Server-Side JavaScript version of this function (xdmp.invoke function) can only be used to invoke JavaScript functions.

Comments

Popular posts from this blog

What is universal index and range index?

MarkLogic server architecture.