JBoss AS 7部署顺序和时序 [英] JBoss AS 7 deployment order and timing

查看:250
本文介绍了JBoss AS 7部署顺序和时序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题在这里一般的部署顺序,特别是时间。



我有一个耳朵1,通过一个bean和一些队列提供一些功能。在standalone.xml中配置队列。另一个耳朵2使用这个服务从ear1。



所以依赖关系看起来像:ear1< - ear2



所以我配置了ear 2的部署结构来依靠ear 1,现在部署顺序本身是正确的。

 <?xml version =1.0encoding =UTF-8?> 
< jboss-deployment-structure>
< deployment>
<依赖关系>
< module name =deployment.ear1.ear/>
< / dependencies>
< / deployment>
< / jboss-deployment-structure>

现在的部署顺序是正确的,但是现在我有一个竞争条件是由于(I猜测)没有从耳朵1中初始化bean。



当我延迟部署ear2时,一切正常。





UPDATE



我试图指定包含要使用的服务的实际bean jar。这也不行。它看起来像:

 <?xml version =1.0encoding =UTF-8?> 
< jboss-deployment-structure>
< deployment>
<依赖关系>
< module name =deployment.ear1.ear.bean.jar/>
< / dependencies>
< / deployment>
< / jboss-deployment-structure>


解决方案

你现在可能知道, JBoss 7.2中将引入依赖关系。

我与其他EAR使用的一个EAR定义服务有同样的问题。我已经通过在standalone.xml中完全关闭自动部署来解决这个问题:

 < subsystem xmlns =urn:jboss:域:部署扫描器:1.1\" > 
< deployment-scanner path =deploymentsative-to =jboss.server.base.dirscan-interval =5000auto-deploy-zipped =falseauto-deploy-expanding =假/>
< / subsystem>

在启动JBoss之前,在单独的线程中运行以下脚本。脚本创建一个部署列表,并使用JBoss 7部署扫描器标记文件以指定的顺序部署它们。即它为第一次部署创建.dodeploy标记,然后等待直到它被部署,然后为第二次部署等创建.dodeploy标记。

 #!/ bin / bash 
函数contains(){
local n = $#
local value = $ {!n}
for(( i = 1; i< $#; i ++)){
if [$ {!i}==$ {value}];那么
echoy
return 0
fi
}
echon
return 1
}


DD =/ home / martinv / jboss-as-7.1.1.Final / standalone / deployments
ORDER_FILE =/ home / martinv / order.txt

echo[MDC]手动部署控制
echo[MDC] -------------------------
echo[MDC]删除标记
rm -f $ DD / *。dodeploy $ DD / *。isdeploying $ DD / *。已部署$ DD / *失败$ DD / *。undeployed $ DD / *。待处理$ DD / *。isundeploying

APPS_ALL =($(ls -1 $ DD | grep'.ear $ \ | .jar $ \ | .war $ \ | .sar $' )

APPS_ORDER =($(cat $ ORDER_FILE))

echo[MDC] $ {#APPS_ALL [@]} $ DD中的应用程序:$ {APPS_ALL [ @ $} $ $ {APPS_ORDER [@]}$ {APPS_ORDER [@]}

$ {APPS_ALL [ @]}
do
如果[$(包含$ {APPS_ORDER [@]}$ APP)==n];然后
APPS_ORDER =($ {APPS_ORDER [@]}$ APP)
fi
done

echo[MDC] $ order $ APPS_ORDER [@]}应用程式:$ {APPS_ORDER [@]}

为$ {APPS_ORDER [@]}
do
echo[MDC]计划部署:$ APP
touch$ DD / $ APP.dodeploy
while [! -f$ DD / $ APP.deployed-a! -f$ DD / $ APP.failed]; do
sleep 1
done
RESULT =`ls -1 $ DD | egrep$ APP.failed | $ APP.deployed`
echo[MDC]已完成部署$ APP,结果:$ RESULT
done
pre>

I have an issue here with deployment order in general and the timing in particular.

I have an ear 1 which provides some functionality via a bean and some queues. The queues are configured in the standalone.xml. Another ear 2 which uses this service from ear1.

So the dependency looks like: ear1 <-- ear2

So I configured the deployment structure of ear 2 to depend on ear 1 and the deployment order itself is correct now.

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="deployment.ear1.ear" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

The deployment order is correct now, but what I now have is a race condition due to a (I guess) not initialized bean from ear 1.

When I delay the deployment of ear2, everything works fine.

Does anyone know how to control the timing of the deployment. Can one specify not only the order of the deployments via jboss-deployment-structure.xml, but also the lifecycle which needs to be reach to start the next deployments?

UPDATE

I tried to specify the actual bean jar which contains the service to be used. This is not working, too. It looks like:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <dependencies>
            <module name="deployment.ear1.ear.bean.jar" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

解决方案

As you probably know by now, the inter-ear depenendencies will be introduced in JBoss 7.2.
I had the same issue with one EAR defining services used by other EARs. I have solved this by completely turning off auto-deploy in standalone.xml:

    <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
        <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-zipped="false" auto-deploy-exploded="false"/>
    </subsystem>

And running the following script in separate thread just before starting JBoss. The script creates a list of deployments and deploys them in specified order using JBoss 7 deployment scanner marker files. I.e. It creates .dodeploy marker for 1st deployment, then waits until it gets deployed, then creates .dodeploy marker for 2nd deployment etc.

#!/bin/bash
function contains() {
    local n=$#
    local value=${!n}
    for ((i=1;i < $#;i++)) {
        if [ "${!i}" == "${value}" ]; then
            echo "y"
            return 0
        fi
    }
    echo "n"
    return 1
}


DD="/home/martinv/jboss-as-7.1.1.Final/standalone/deployments"
ORDER_FILE="/home/martinv/order.txt"

echo "[MDC] Manual deployment control"
echo "[MDC] -------------------------"
echo "[MDC] Removing markers"
rm -f $DD/*.dodeploy $DD/*.isdeploying $DD/*.deployed $DD/*.failed $DD/*.undeployed $DD/*.pending $DD/*.isundeploying

APPS_ALL=( $( ls -1 $DD | grep '.ear$\|.jar$\|.war$\|.sar$' ) )

APPS_ORDER=( $( cat $ORDER_FILE ) )

echo "[MDC] ${#APPS_ALL[@]} apps in $DD: ${APPS_ALL[@]}"
echo "[MDC] Order defined for ${#APPS_ORDER[@]} apps: ${APPS_ORDER[@]}"

for APP in "${APPS_ALL[@]}"
do
    if [ $(contains "${APPS_ORDER[@]}" $APP) == "n" ]; then
        APPS_ORDER=("${APPS_ORDER[@]}" "$APP")
    fi
done

echo "[MDC] Final order of ${#APPS_ORDER[@]} apps: ${APPS_ORDER[@]}"

for APP in "${APPS_ORDER[@]}"
do
    echo "[MDC] Scheduled for deploy: $APP"
    touch "$DD/$APP.dodeploy"
    while [ ! -f "$DD/$APP.deployed" -a ! -f "$DD/$APP.failed" ]; do
        sleep 1
    done
    RESULT=`ls -1 $DD | egrep "$APP.failed|$APP.deployed"`
    echo "[MDC] Finished deploying $APP, result: $RESULT"
done

这篇关于JBoss AS 7部署顺序和时序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆