1

我使用“antcall” scriptlla 并发调用,但出现“javax.mail.Management InstanceNotFoundException”。我设置了10个并发,有时可以10个,有时只能升几个。

<target name="PAIR_CONN">
        <etl debug="true">
            <fileset file="Pair_Conn.xml" />
        </etl>
    </target>
    <target name="pair_conn_mult">
        <parallel threadCount='5'>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="1" />
            </antcall>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="2" />
            </antcall>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="3" />
            </antcall>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="4" />
            </antcall>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="0" />
            </antcall>
        </parallel>
    </target>

无法注销 mbean scriptella:type=etl,url="file:/informatica/infa861/oss_etl_523/src/ElectricCable/Pair_Conn.xml" javax.management.InstanceNotFoundException: scriptella:type=etl,url="file:/informatica/ infa861/oss_etl_523/src/ElectricCable/Pair_Conn.xml"

我查看scriptella源码,代码已经同步了,

public synchronized void register() {
    if (name != null) {
        throw new IllegalStateException("MBean already registered");
    }
    server = getMBeanServer();
    String url = ctx.getScriptFileURL().toString();
    System.out.println("LM:"+url);
    boolean registered = false;
    for (int i = 0; i < 1000; i++) {
        if (name == null || server.isRegistered(name)) {
            registered = true;
            name = toObjectName(url, i);
            System.out.println("LM:"+name);
        } else {
            registered = false;
            break;
        }
    }
    etlThread = Thread.currentThread();
    if (!registered) {
        try {
            server.registerMBean(this, name);
            started = new Date();
            LOG.info("Registered JMX mbean: " + name);
        } catch (Exception e) {
            throw new SystemException("Unable to register mbean " + name, e);
        }
    } else {
        throw new SystemException("Unable to register mbean for url " + url + ": too many equal tasks already registered");
    }
}

对于这种情况,您有什么建议?我应该尝试什么,或者我应该阅读什么才能找到解决方案?

4

1 回答 1

0

感谢您指出一个严重的错误。我已经打开JavaForge 票来跟踪这个问题。

作为一种解决方法,您可以切换到<java fork="true">任务以在分叉的 VM 中运行 Scriptella,因此 Ant 脚本将变成这样:

<path id="scriptella.class.path">
    <pathelement location="../../build/scriptella.jar"/>
</path>
<taskdef resource="antscriptella.properties" classpathref="scriptella.class.path"/>

<target name="PAIR_CONN">
    <java fork="yes" classname="scriptella.tools.launcher.EtlLauncher" classpathref="scriptella.class.path">
        <arg value="Pair_Conn.xml"/>
        <arg value="-d"/>
        <sysproperty key="g_flag" value="${g_flag}"/>
    </java>
</target>


<target name="pair_conn_mult">
    <parallel threadCount='5'>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="1" />
        </antcall>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="2" />
        </antcall>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="3" />
        </antcall>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="4" />
        </antcall>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="0" />
        </antcall>
    </parallel>
</target>
于 2013-03-11T13:30:09.407 回答