How external clients notify Oozie workflow with HTTP callback

风格不统一 提交于 2019-12-05 21:30:54

Have a look at the Oozie SSH action implementation. It is just one class, relatively simple (but a bit messy), and shows how to create a callback URL:

String callbackPost = ignoreOutput ? "_" : 
getOozieConf().get(HTTP_COMMAND_OPTIONS).replace(" ", "%%%");

String callBackUrl = Services.get().get(CallbackService.class)
                .createCallBackUrl(action.getId(), EXT_STATUS_VAR);

The URL is then passed to a shell script as an argument. The script later just invokes curl on that URL. The external status id is for example PID of the executed process that is returned back to Oozie via the callback. It must not be empty/null.

Hints if you decide to delve into the code: although it looks like the code is executed synchronously, it is in fact executed asynchronously by means of running the shell script in the background.

The callback is processed by Oozie's CallbackServlet:

dagEngine.processCallback(actionId, callbackService.getExternalStatus(queryString), props);

According to the IBM DW Article

When Oozie starts a task, it provides a unique callback HTTP URL to the task, and notifies that URL when it is complete. If the task fails to invoke the callback URL, Oozie can poll the task for completion.

The CallbackService.java has the methods for generating the callback url for sending it to th action and parsing it when the action makes a call back.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!