rvypandey Posted November 19, 2023 Share Posted November 19, 2023 Hi there, I'm looking for a solution where I'm creating schedules in JasperServer UI, and I need to poll (on a scheduled basis) whether job was successful - report generated, or job failed. In case of job failed, I'm recording the instance via a NodeJS app into my DB, and providing a capability to re-trigger these failed jobs. I understand that there is already a support for restarting failed jobs - , but my requirement is also to track these separately. I've tried reportsExecution Service and it does not return any content - 204. Is there a way to achieve this? Thanks, Ravi Pandey Link to comment Share on other sites More sharing options...
Domenico Donofrio Posted November 20, 2023 Share Posted November 20, 2023 Hello, in order to get a job status you can use the following API: /rest_v2/jobs/<jobID>/state/ It will return the state descriptor of the job, for example: <state> <nextFireTime>2022-03-29T18:01:00-07:00</nextFireTime> <previousFireTime>2022-03-28T18:01:00-07:00</previousFireTime> <value>NORMAL</value> </state> Hope it helps 1 Link to comment Share on other sites More sharing options...
rvypandey Posted November 20, 2023 Author Share Posted November 20, 2023 Thanks for your response @ddonofr, but this I've already tried: - get list of all jobs - http://<host>:<port>/jasperserver[-pro]/rest_v2/jobs?<arguments> - get each jobs details - http://<host>:<port>/jasperserver[-pro]/rest_v2/jobs/<jobID> - get each jobs state - http://<host>:<port>/jasperserver[-pro]/rest_v2/jobs/<jobID>/state But this only tells us what happened with the job, and not whether report was generated when this job ran or not. ---- As a POC, I altered the code to throw error (created custom function) and used that in jrxml. The error is successfully thrown for the report (when run via scheduler), and the report never generates. Error - Quote 2023-11-20T17:03:00,257 ERROR SecureExceptionHandlerImpl,JasperServerScheduler_Worker-2:125 - There was an error on the server. Try again or contact site administrators. (Error UID: bd87d516-6488-4816-befe-5529d0439dba). Error evaluating expression for source text: CONVERT_TO_QUOTED_STRING($P{AgentName}) com.jaspersoft.jasperserver.api.JSException: Error filling report ... Caused by: java.lang.IllegalArgumentException: Deliberately thrown error at NSA_CFS_Reporting.CustomFunctions.CONVERT_TO_QUOTED_STRING(CustomFunctions.java:80) at Rascher_1700407681143_653130.evaluate(Rascher_1700407681143_653130:109) at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:313) ... 39 more But the job still is in NORMAL state - Quote Jobs Status for jobId - 5344 successful! - {"previousFireTime":"2023-11-20T17:03:00+05:30","nextFireTime":"2023-11-20T17:08:00+05:30","value":"NORMAL"} I want to know that when the job ran, was the report generated or was there any error? Thanks, Ravi Pandey Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now