简体   繁体   English

如何在 weblogic 12C 中使用 REST 异步部署应用程序?

[英]How to deploy asynchronously an application using REST in weblogic 12C?

I have been deploying a weblogic application using the REST api with the following snippet我一直在使用 REST api 和以下代码段部署 weblogic 应用程序

    curl --insecure -X POST  --user ${userpass} -F\"deployment=@${appFileName}\" -F\"model={name: '${appName}',  deploymentOptions: { retireGracefully: 'false', timeout: '0' } , ${appType} ${appPlanVersion} targets: [ ${appTargets} ]}\" ${wlhost}/management/wls/latest/deployments/application "

I have to wait until this curl ends, but sometimes the request times out because of server configuration.我必须等到这个 curl 结束,但有时由于服务器配置,请求超时。

so, I thought it would be better to do this operation asynchronously, I have read in the documentation that I can use header所以,我认为异步执行此操作会更好,我在文档中阅读了我可以使用 header

    -X Prefer:respond-async

but is not clear how to use it, I was not able to find an useful example, once I have added the header, the request is going to return a task URL like BODY:但不清楚如何使用它,我找不到有用的例子,一旦我添加了 header,请求将返回一个任务 URL,如 BODY:

    {
        "links": [{
            "rel": "job",
            "href": "http:\//localhost:7001/management/weblogic/latest/domainRuntime/deploymentManager/deploymentProgressObjects/fairShare"
        }],
        "operationType": 5,
        "state": "STATE_RUNNING",
        "applicationName": "fairShare",
        "progress": "processing",
        "completed": false
    }

how do I poll that job URL to know that the application was deployed and is active?如何轮询该作业 URL 以了解应用程序已部署且处于活动状态?

If you'll execute:如果你要执行:

curl --insecure -X GET --user ${userpass} ${wlhost}/management/tenant-monitoring/applications/${appName} curl --insecure -X GET --user ${userpass} ${wlhost}/management/tenant-monitoring/applications/${appName}

when application ${appName} is not deployed, you should get 404 Not Found.当应用程序 ${appName} 未部署时,您应该得到 404 Not Found。

when it's deployed, you should get a JSON similar to this:部署后,您应该得到一个类似于此的 JSON:

{
"body": {
    "item": {
        "name": "${appName}",
        "type": "ear",
        "state": "STATE_ACTIVE",
        "health": "HEALTH_WARN",
        "targetStates": [
            {
                "target": "wls",
                "state": "STATE_ACTIVE"
            }
        ],
        "dataSources": [],
        "workManagers": [
            {
                "pendingRequests": 0,
                "completedRequests": 125,
                "name": "default",
                "server": "wls"
            }
        ],
        "minThreadsConstraints": [],
        "maxThreadsConstraints": [],
        "requestClasses": []
    }
},
"messages": []
}

Tested (in Postman) on WebLogic 12.2.1.4在 WebLogic 12.2.1.4 上测试(在 Postman 中)

The answer is to use the request parameter _detached= true in the post URL, This will start the deployment asynchronously答案是在帖子URL中使用请求参数_detached=true,这样会异步启动部署

for an example, refer to this document.例如,请参阅此文档。

https://docs.oracle.com/middleware/1213/wls/WLRMR/management_wls_version_deployments_application.htm#WLRMR290 https://docs.oracle.com/middleware/1213/wls/WLRMR/management_wls_version_deployments_application.htm#WLRMR290

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM