[MarkLogic Dev General] (no subject)

Strawn, Shane Shane.Strawn at wolterskluwer.com
Mon Oct 27 08:29:36 PST 2008


Hello,

I have a somewhat convoluted issue to describe so I'll try to make
sense:

I have a Content Processing Framework process which watches a directory
for a file to be dropped on it.  This is a different database than my
main content database.

I have an xquery module which at the same time inserts a document into
the content database, and the above file into the CPF database in an
eval, like so:

	xdmp:document-insert( "process-me.xml", <data>...</data>)
	...
	xdmp:eval('xdmp:document-insert( "cpf-init.xml", 
		<target-uri>process-me.xml</target-uri>)', $options (:
setting db to content :) )

Now, since these are in different dbs, it sometimes occurs where the CPF
process will look for "process-me.xml" on the content db but not find
it, because it is not finished document-inserting.  I thought it should
complete the doc-insert before moving on to the eval in the module, but
it apparently doesn't due to the separate-transaction nature of the
situation?

I would like to find a way to loop or wait until my doc is fully
inserted within xquery, rather than the more complex tasks of modifying
the CPF pipeline or changing the interface to add another click-through
after the doc is inserted, if possible.  But I'm not sure how to
accomplish this or if it's realistic.

I've tried some (probably) stupid things such as:

Killing a set amount of time with a statement like 
	let $timekill := for $a in (1 to 10000000) return ()
...but this seems unreliable, and a waste of time if it doesn't need it;

Or a recursive function like
	define function check-doc-exists($uri as xs:string) { 
	if ( fn:exists(fn:doc($uri)) ) then fn:true() else
check-doc-exists($uri) }
...but this gives me Stack Overflow within seconds, or if I put my
timekiller in it, it never finds the doc even if it inserts while it is
running.

Is there something I can do here to create a loop which runs until it
can find the document?  Am I misunderstanding what is happening with the
transaction?  Just how wrong are my above ideas?

Thanks in advance for any guidance.

Shane Strawn
Wolters Kluwer Health

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20081027/cab0b0d2/attachment.html


More information about the General mailing list