2016-05-31 2 views
2

commonj.work.WorkManagerを@Asynchronousというタグの付いたメソッドの処理に使用する必要があります。そうのような非同期の仕事を@Asynchronousメソッドを定義する際にWorkManagerを指定する

@Resource(mappedName = "vm/myWorkManager") 
private WorkManager myWorkManager; 

...とスケジュール::私たちは以前にワークマネージャを定義し、使用してそれらを注入して、強化していたWebLogic 12.1.3アプリで

rjscWorkManager.schedule(new DetailWork(businessId)); 

@Asynchronousメソッドを定義して、非同期コードがCDIインジェクションの恩恵を受けるようにしたいと思いますが、作業に割り当てるスレッドの数を制御したいと思っています。これは、アプリケーション全体のワークマネージャを定義することによってのみ達成できますか? @AsynchronousおよびWork Managerに関するEJB仕様またはWebLogicのマニュアルには何も表示されません。

はあなたが のweblogic-ejb-jar.xmlのでワークマネージャにEJBを割り当てることにより、@Asynchronousメソッドに割り当てられたスレッドの数を制限することができ

答えて

2

<?xml version="1.0" encoding="UTF-8"?> 
<weblogic-ejb-jar 
    xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd"> 

    <!-- Define which work manager the EJB(s) should use --> 
    <weblogic-enterprise-bean> 
    <ejb-name>MyService</ejb-name> 
    <dispatch-policy>myWorkManager</dispatch-policy> 
    </weblogic-enterprise-bean> 

    <!-- Other EJBs could use the same work manager... --> 

    <!-- Define the work manager --> 
    <work-manager> 
    <!-- Name --> 
    <name>myWorkManager</name> 
    <!-- Min Threads - Guarantees the minimum number of threads the server will allocate to requests --> 
    <min-threads-constraint> 
     <name>myWorkManager-MinThreads-Constraint</name> 
     <count>5</count> 
    </min-threads-constraint> 
    <!-- Max Threads - Guarantees the maximum number of threads the server will allocate to requests --> 
    <max-threads-constraint> 
     <name>myWorkManager-MaxThreads-Constraint</name> 
     <count>100</count> 
    </max-threads-constraint> 
    <!-- Capacity - Causes the server to reject requests only when it has reached its capacity --> 
    <capacity> 
     <name>myWorkManager-Capacity-Constraint</name> 
     <count>-1</count> 
    </capacity> 
    </work-manager> 
</weblogic-ejb-jar> 

詳細はここで見つけることができます:

https://roundwheeltech.wordpress.com/2016/06/07/assigning-ejbs-to-work-managers/

関連する問題