简体   繁体   English

如何检查Wildfly 8.2.1是否以编程方式正确部署了我的应用程序?

[英]How to check if my Application was correctly deployed by Wildfly 8.2.1 programmatically?

I need to check the deployment status of my application which is deployed by Wildfly 8.2.1 programmatically (preferably java). 我需要检查Wildfly 8.2.1以编程方式(最好是java)部署的应用程序的部署状态。 As far I am concerned, there can be multiple ways to achieve this: 就我而言,可以通过多种方式实现这一目标:

  1. monitoring the semaphore files in the deployment folder (like if deployed there are .deployed files created for the war files). 监视部署文件夹中的信号文件(例如,如果已部署,则为war文件创建.deployed文件)。
  2. check by calling a rest service which is supposed to be available when the war file is successfully deployed 通过调用在成功部署war文件时应该可用的rest服务进行检查
  3. using JMX mbeans 使用JMX mbeans

There might be other ways too, which I am not yet aware of. 可能还有其他方式,我尚未意识到。 But I am more interested in learning the ways of using JMX mbeans . 但是我对学习使用JMX mbean的方式更感兴趣。 But unfortunately my online search is not giving me any good direction. 但不幸的是,我的在线搜索没有给我任何好的指导。 If anyone can shed some light to this that would be really helpful. 如果有人可以对此有所了解,那将是非常有帮助的。

You could use management operations to check to see if you're deployment exists. 您可以使用管理操作来检查是否存在部署。 It's a little old, but there's a tutorial on the deypted API. 它有些旧,但是有一个有关已开发API的教程

try (final ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getLocalHost(), 9990)) {
    final ModelNode op = Operations.createOperation("read-children-resources");
    op.get(ClientConstants.CHILD_TYPE).set(ClientConstants.DEPLOYMENT);
    final ModelNode result = client.execute(op);
    if (Operations.isSuccessfulOutcome(result)) {
        final ModelNode deployments = Operations.readResult(result);
        for (String deploymentName : deployments.keys()) {
            final ModelNode deploymentDetails = deployments.get(deploymentName);
            // do stuff
        }
    } else {
        throw new RuntimeException("Failed to list deployments: " + Operations.getFailureDescription(result).asString());
    }
}

From the result you can read various information about the deployment. 从结果中,您可以阅读有关部署的各种信息。 The output looks like: 输出如下:

{
    "content" => [{"hash" => bytes {
        0x77, 0x1f, 0x1a, 0xa1, 0x9e, 0x46, 0x11, 0x75,
        0x2f, 0x58, 0xce, 0x1b, 0x01, 0x29, 0x45, 0x43,
        0x16, 0x87, 0x22, 0x9a
    }}],
    "enabled" => true,
    "enabled-time" => 1443485828919L,
    "enabled-timestamp" => "2015-09-28 17:17:08,919 PDT",
    "name" => "batch-chunk.war",
    "owner" => undefined,
    "persistent" => true,
    "runtime-name" => "batch-chunk.war",
    "subdeployment" => undefined,
    "subsystem" => {
        "jaxrs" => undefined,
        "batch" => undefined,
        "undertow" => undefined
    }
}

If you wanted to see whether it was enabled you could do 如果您想查看是否已启用它,可以执行

if (!deploymentDetails.get("enabled")) {
    throw new RuntimeException(String.format("Deployment %s is not enabled", deploymentName);
}

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

相关问题 如何使用Eclipse停止Wildfly 8.2.1最终服务器上的应用程序-Java - How to stop application on Wildfly 8.2.1 final server using Eclipse - Java 如何“刷新” Wildfly中已部署的应用程序? - How to “refresh” a deployed application in Wildfly? Wildfly 8.2.1上部署的Java 8应用程序的元空间内存流量问题 - Metaspace memory concumption issues of Java 8 applications deployed on Wildfly 8.2.1 如何以编程方式检查JBoss5中是否部署了应用程序? - How to programmatically check if an application has deployed in JBoss5? Springboot 演示应用程序未在 Wildfly 上正确部署 - Springboot demo application doesn't get deployed correctly on Wildfly 我如何访问部署在我的 docker wildfly 图像上的应用程序 - how can i access my application deployed on my docker wildfly images 将Grails(2.2.4)应用程序从JBoss 5.1迁移到Wildfly 8.2.1 - Migrating Grails (2.2.4) application from JBoss 5.1 to Wildfly 8.2.1 如何为部署在 WildFly 9 中的应用程序设置 Log4j2? - How to setup Log4j2 for an application deployed in WildFly 9? 如何从已部署的应用程序中以编程方式更改 WildFly 日志记录级别 - How to change WildFly logging levels programatically from within deployed application 如何在 Wildfly-8.2.1.Final 上设置域名(或主机名) - How to set domain name (or host name) on Wildfly-8.2.1.Final
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM