You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by "Teggart, Brian" <BT...@UNUM.COM> on 2014/10/30 10:51:23 UTC

TimerManagers and WorkManagers in JEE..

Hi Guys,
I am trying to convert an existing app from websphere to TomEE.
I am trying to create references in web.xml to workManager and timerManager resources such as

<resource-ref id="ResourceRef_wm_JMSWorkManager">
        <res-ref-name>wm/JMSWorkManager</res-ref-name>
        <res-type>commonj.work.WorkManager</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

     <resource-ref id="ResourceRef_tm_default">
        <res-ref-name>tm/default</res-ref-name>
        <res-type>commonj.timers.TimerManager</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Unshareable</res-sharing-scope>
    </resource-ref>


I have followed the following instructions for common in tomcat:-

http://commonj.myfoo.de/install.shtml

I downloaded the distro jar files, and added them to my ${Tomee_Install}/lib folder.
I then added resources to my tomee.xml file for the tomee server:-

<Resource id="wm/JMSWorkManager" type="commonj.work.WorkManager"
                                  factory-name="de.myfoo.commonj.work.FooWorkManagerFactory">
              minThreads=1
              maxThreads=10
       </Resource>
On server startup, I am seeing the following output:-
Oct 30, 2014 9:39:30 AM org.apache.openejb.OpenEJB$Instance <init>
SEVERE: OpenEJB has encountered a fatal error and cannot be started: Assembler failed to build the container system.
org.apache.openejb.OpenEJBException: Failed Configuring Service(id=wm/JMSWorkManager): Cannot determine a provider for Resource(id=wm/JMSWorkManager, type=commonj.work.WorkManager, provider=null).

I have not configured the resource correctly for TOMEE and I was wondering if you could help me with the syntax?
The example given on the websites hasn't got the newer syntax:-

http://commonj.myfoo.de/tuning.shtml .

I am also seeing newer implementations for thread/timer management in TOMEE, such as the following resources.
<Resource id="wm/default" type="javax.enterprise.concurrent.ManagedExecutorService"/>
  <Resource id="wm/default" type="ManagedExecutorService"/>
  <Resource id="wm/default" type="ManagedScheduledExecutorService"/>
  <Resource id="wm/default" type="javax.enterprise.concurrent.ManagedScheduledExecutorService"/>
  <Resource id="wm/default" type="javax.enterprise.concurrent.ManagedThreadFactory"/>

Should I try these instead, and if so, would I need to change my web.xml to work with these implementations? (I am guessing the answer here is yes...)

I don't see any samples on the site for these resources, although they should be straightforward..
Many thanks for your time and help,
Brian.







Re: TimerManagers and WorkManagers in JEE..

Posted by Brian Teggart <BT...@UNUM.COM>.
The implementation class I found for the factory was
org.apache.openejb.concurrencyutilities.ee.factory.ManagedScheduledExecutorServiceImplFactory.

It worked fine when I used this. Thanks.

<Resource  id="mes/JMS" factory-name="create" 

class-name="org.apache.openejb.concurrencyutilities.ee.factory.ManagedScheduledExecutorServiceImplFactory" 
	type="javax.enterprise.concurrent.ManagedExecutorService">
		Core=1    
		Max=8    
		KeepAlive=5s
		Queue=15
	</Resource>



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/TimerManagers-and-WorkManagers-in-JEE-tp4672678p4673180.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: TimerManagers and WorkManagers in JEE..

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

you can go at the end here
https://git-wip-us.apache.org/repos/asf?p=tomee.git;a=blob;f=container/openejb-core/src/main/resources/META-INF/org.apache.openejb/service-jar.xml;h=a9148548490817f41377ec8a85438bedf21d1b30;hb=ae8f512c5655dfd9024353c5a46340c6de07edf3
then you can just check classes and setters:
https://git-wip-us.apache.org/repos/asf?p=tomee.git;a=blob;f=container/openejb-core/src/main/java/org/apache/openejb/resource/thread/ManagedExecutorServiceImplFactory.java;h=198bcb293d4cc18f511cfd3552714fbb033eafb2;hb=HEAD
or https://git-wip-us.apache.org/repos/asf?p=tomee.git;a=blob;f=container/openejb-core/src/main/java/org/apache/openejb/resource/thread/ManagedScheduledExecutorServiceImplFactory.java;h=05f4597dd24dd252a64eb82178f4fc8700c6a41c;hb=HEAD


Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau


2014-12-06 13:52 GMT+01:00 Brian Teggart <BT...@unum.com>:
> In order to use the CommonJ workManagers and TimerManagers, I had to rework
> the factory methods for the class
> de.myfoo.commonj.work.FooWorkManagerFactory to fit with TomEE.
> I was going down a road that wasn't very appealing.
>
> I want to use the ManagedThreadFactory and ManagedExecutorService to create
> my threads/ timer jobs instead. In the version of Tomee that I am
> using(1.7.1), I can reference the classes like you say, by adding the
> openejb-concurrency-utilities and api jar files to my lib folder. The
> following references work.
>
> <Resource  id="mtf/Transformer"
> type="javax.enterprise.concurrent.ManagedThreadFactory"/>
> Resource  id="mses/ManagedScheduledExecutorService"
> type="javax.enterprise.concurrent.ManagedScheduledExecutorService"/>
>
>
> However, I cant find any info on how to tune the ManagedThreadFactory to run
> x concurrent threads. Do you have an example as to how tune the
> ManagedThreadFactory , to say run 4 concurrent threads?
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/TimerManagers-and-WorkManagers-in-JEE-tp4672678p4673173.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: TimerManagers and WorkManagers in JEE..

Posted by Brian Teggart <BT...@UNUM.COM>.
In order to use the CommonJ workManagers and TimerManagers, I had to rework
the factory methods for the class
de.myfoo.commonj.work.FooWorkManagerFactory to fit with TomEE.
I was going down a road that wasn't very appealing.

I want to use the ManagedThreadFactory and ManagedExecutorService to create
my threads/ timer jobs instead. In the version of Tomee that I am
using(1.7.1), I can reference the classes like you say, by adding the
openejb-concurrency-utilities and api jar files to my lib folder. The
following references work.

<Resource  id="mtf/Transformer"
type="javax.enterprise.concurrent.ManagedThreadFactory"/>
Resource  id="mses/ManagedScheduledExecutorService"
type="javax.enterprise.concurrent.ManagedScheduledExecutorService"/>


However, I cant find any info on how to tune the ManagedThreadFactory to run
x concurrent threads. Do you have an example as to how tune the
ManagedThreadFactory , to say run 4 concurrent threads?



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/TimerManagers-and-WorkManagers-in-JEE-tp4672678p4673173.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: TimerManagers and WorkManagers in JEE..

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

we have some users who managed to use commonj in tomee (you should
find answers on the list IIRC).

About javax.*.concurrent.* you need to add
openejb-concurrency-utilities and api jar jar to make it working but
it can be a nicer replacement since it is standard and will be built
in in TomEE 2.



Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau


2014-10-30 10:51 GMT+01:00 Teggart, Brian <BT...@unum.com>:
> Hi Guys,
> I am trying to convert an existing app from websphere to TomEE.
> I am trying to create references in web.xml to workManager and timerManager resources such as
>
> <resource-ref id="ResourceRef_wm_JMSWorkManager">
>         <res-ref-name>wm/JMSWorkManager</res-ref-name>
>         <res-type>commonj.work.WorkManager</res-type>
>         <res-auth>Container</res-auth>
>         <res-sharing-scope>Shareable</res-sharing-scope>
>     </resource-ref>
>
>      <resource-ref id="ResourceRef_tm_default">
>         <res-ref-name>tm/default</res-ref-name>
>         <res-type>commonj.timers.TimerManager</res-type>
>         <res-auth>Container</res-auth>
>         <res-sharing-scope>Unshareable</res-sharing-scope>
>     </resource-ref>
>
>
> I have followed the following instructions for common in tomcat:-
>
> http://commonj.myfoo.de/install.shtml
>
> I downloaded the distro jar files, and added them to my ${Tomee_Install}/lib folder.
> I then added resources to my tomee.xml file for the tomee server:-
>
> <Resource id="wm/JMSWorkManager" type="commonj.work.WorkManager"
>                                   factory-name="de.myfoo.commonj.work.FooWorkManagerFactory">
>               minThreads=1
>               maxThreads=10
>        </Resource>
> On server startup, I am seeing the following output:-
> Oct 30, 2014 9:39:30 AM org.apache.openejb.OpenEJB$Instance <init>
> SEVERE: OpenEJB has encountered a fatal error and cannot be started: Assembler failed to build the container system.
> org.apache.openejb.OpenEJBException: Failed Configuring Service(id=wm/JMSWorkManager): Cannot determine a provider for Resource(id=wm/JMSWorkManager, type=commonj.work.WorkManager, provider=null).
>
> I have not configured the resource correctly for TOMEE and I was wondering if you could help me with the syntax?
> The example given on the websites hasn't got the newer syntax:-
>
> http://commonj.myfoo.de/tuning.shtml .
>
> I am also seeing newer implementations for thread/timer management in TOMEE, such as the following resources.
> <Resource id="wm/default" type="javax.enterprise.concurrent.ManagedExecutorService"/>
>   <Resource id="wm/default" type="ManagedExecutorService"/>
>   <Resource id="wm/default" type="ManagedScheduledExecutorService"/>
>   <Resource id="wm/default" type="javax.enterprise.concurrent.ManagedScheduledExecutorService"/>
>   <Resource id="wm/default" type="javax.enterprise.concurrent.ManagedThreadFactory"/>
>
> Should I try these instead, and if so, would I need to change my web.xml to work with these implementations? (I am guessing the answer here is yes...)
>
> I don't see any samples on the site for these resources, although they should be straightforward..
> Many thanks for your time and help,
> Brian.
>
>
>
>
>
>