See if it is helpful.
declare namespace status="http://marklogic.com/xdmp/status/server"; (:namespace
declaration for marklogic server status tracking:)
declare variable $requestUrl := xdmp:get-request-field("url"); (:get url from
http request:)
try
{
let $serverName:= "rest-http"
let $requestId := xdmp:server-status(
xdmp:host(),
xdmp:server($serverName)
)//status:request-id
let $cancelRequest :=
(
if(fn:contains($requestUrl,"somePath"))
then
(
fn:true()
,
xdmp:log(
fn:concat("Request-- ","' ",$requestId,"
'"," for the server::-- ","' ",$serverName," '", " has been cancelled!!")
,"notice"
)
,
xdmp:request-cancel(
xdmp:host(),
xdmp:server($serverName),
$requestId
)
)
else
(
xdmp:log(
fn:concat("Request-- ","' ",$requestId," '"," for
the server::-- ","' ",$serverName," '", " passed for processing!!")
,"info"
)
,
fn:false()
)
)
return if($cancelRequest)
then
(
xdmp:set-response-code(202,"Accepted")
,
"202 Accepted,Please wait!,another request for the same request is in
progress, hence cancelled your current request!"
)
else
()
}
catch ($exception)
{
xdmp:log($exception,"error")
}
________________________________
From: [email protected]
[[email protected]] on behalf of Kapoor, Pragya
[[email protected]]
Sent: Friday, May 22, 2015 4:45 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Get Request Id of the current request
Hi Geert,
I need to create a rest web service to cancel the request, based on user input.
so for that I need to find the request-id for the request and then use
xdmp:request-cancel
Thanks
Pragya
________________________________
From: [email protected]
<[email protected]> on behalf of Geert Josten
<[email protected]>
Sent: Friday, May 22, 2015 3:37 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Get Request Id of the current request
Hi Pragya,
You could also just call fn:error() to terminate the current request, and pass
through a descriptive message along side as well..
Cheers,
Geert
From: <Kapoor>, Pragya <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Friday, May 22, 2015 at 11:01 AM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Get Request Id of the current request
Hi,
Is there any way to find out the request-id of the current request sent to ML,
so that I can use the same request Id in xdmp:request-cancel.
Thanks
Pragya
"This e-mail and any attachments transmitted with it are for the sole use of
the intended recipient(s) and may contain confidential , proprietary or
privileged information. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this e-mail or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful."
"This e-mail and any attachments transmitted with it are for the sole use of
the intended recipient(s) and may contain confidential , proprietary or
privileged information. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this e-mail or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful."
This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient(s), please reply to the sender and
destroy all copies of the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email,
and/or any action taken in reliance on the contents of this e-mail is strictly
prohibited and may be unlawful. Where permitted by applicable law, this e-mail
and other e-mail communications sent to and from Cognizant e-mail addresses may
be monitored.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general