cancel
Showing results for 
Search instead for 
Did you mean: 

JobAcquisitionThread and JobExecutor

pganga
Champ in-the-making
Champ in-the-making
Hi Guys,
We are trying to replace the default job executor for a custom one that will use spring and the application server thread pool (commonj Work Manager). So we don't use any unmanaged threads.
Reviewing the code we notice that is using another unmanaged thread the one polling for available jobs (JobAcquisitionThread).
It is there a way to replace that component easily?
Which will be the best strategy to follow in this case?.

Thanks in advance.
16 REPLIES 16

bardioc
Champ in-the-making
Champ in-the-making
I've implemented this for both, the JobAquisitionThread and the actual job executor for commonj, because WebSphere Application Server does not like it at all, if threads are created without its knowledge. Actually I've rewritten the JobAquisitionThread to use the commonj TimerManager and the Job Executor to use the commonj WorkManager, both configurable via JNDI.

I'm currently trying to find a generalizable way to support different JobExecutor threading models, because other Appservers have different approches for this. There has been some work done already by Ronald van Kuijk (see ACT-34), but I'm unsure how fast this will be integrated.

My solution simply overrides the current JobExecutor (simple extend) in a programmatically done configuration of the Activiti Engine.

If interested I can explain in more detail how I've implemented this.

Maybe Ronald van Kuijk can shed some light on his previous work for ACT-34 and explain if the modifications done so far will somehow be included in Activity soon.

Regards,

Heiko

pganga
Champ in-the-making
Champ in-the-making
Hey Bardioc
I really appreciate your answer.
I was actually doing exactly that, extending the job executor and inside this one injecting a TaskExecutor.
This Task executor is configured trough spring and in development is just a simple ThreadPoolTaskExecutor but in
WAS is a WorkManagerTaskExecutor that will use the Threadpoll JNDI name to access it.

If interested I can explain in more detail how I've implemented this.
Please I am really interested in seeing your approach.

Thanks again.

meyerd
Champ on-the-rise
Champ on-the-rise
Just as an FYI, we have this ready in camunda fox with commercial support for webshere.

bardioc
Champ in-the-making
Champ in-the-making
Just as an FYI, we have this ready in camunda fox with commercial support for webshere.

Sounds great, allthough I think something like this, except the commercial support, should be part of Activiti itself. Right now it is not really compatible with application server in general. From my perspective the core embeddable engine is not really embeddable because of the lacking support for managed threads. These are necessary in almost all application servers and something we should include in Activiti.

Just my two cents 🙂

Heiko

PS: The company I'm working for might consider Camunda Fox, because of the commercial support. I'll check into that and get in touch with you guys.

bardioc
Champ in-the-making
Champ in-the-making
Hey Bardioc
I really appreciate your answer.
I was actually doing exactly that, extending the job executor and inside this one injecting a TaskExecutor.
This Task executor is configured trough spring and in development is just a simple ThreadPoolTaskExecutor but in
WAS is a WorkManagerTaskExecutor that will use the Threadpoll JNDI name to access it.

If interested I can explain in more detail how I've implemented this.
Please I am really interested in seeing your approach.

Thanks again.

I'll try to get those files and make them available as attachment to a note and PM you!

sebastian_s
Champ in-the-making
Champ in-the-making
Hello Heiko,

I could also use these files and would be happy if you could pm me, too.

Thanks in advance

Sebastian

pganga
Champ in-the-making
Champ in-the-making
I'll try to get those files and make them available as attachment to a note and PM you!

Great Thanks!, I'll be waiting.

bardioc
Champ in-the-making
Champ in-the-making
Hello again,

attached you find a maven project [attachment=1]activiti-websphere.zip[/attachment] that contains the support for WebSphere Application Server. It implements a custom Activiti Configuration based on the Spring Configuration object. The use of Spring here is important, as WebSphere contains a specific Transaction Manager support by using so called Units-of-Work. Spring provides support for this. The attached xml configuration [attachment=0]activiti.cfg.xml.zip[/attachment] shows how to use it.

Make sure you have included the dependency for activiti-spring as well, as it is mandatory for this. The only additional configuration parameter for WebSphere is the workManager JNDI-Name.


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />

    <bean id="processEngineConfiguration" class="org.activiti.websphere.WebSphereEngineConfiguration">    
        <property name="transactionManager"  ref="transactionManager" />
        <property name="jobExecutorWorkManagerJndiName" value="java:comp/env/wm/default" />
    </bean>
</beans>
It donates the JNDI name of the WorkManager to be used. It is optional, and if not specified, the given default value is used.

For the maven project to compile successfully, you need to provide an IBM specific reference to the com.ibm.ws.prereq.commonj-twm.jar-File, which contains the API code for the WorkManagers. You find this file in your WebSphere application servers 'plugin' directory and need to install it into your local repository:


mvn install:install-file -Dfile=com.ibm.ws.prereq.commonj-twm.jar -DgroupId=com.ibm.ws.prereq -DartifactId=commonj-twm -Dversion=1.1 -Dpackaging=jar
The implementation uses an ExecutionService for WorkManagers. The idea came to me while I saw that the default JobExecutor uses the ThreadPoolExecutor.

Attention: This module will only work for Activiti 5.9 or above, as the modifications introduced by JIRA ACT-34 are necessary.

The code is free of use. I would like to get a note if you find a mistake, error or something that could be done better.

Best regards,

Heiko

pganga
Champ in-the-making
Champ in-the-making
Hello again,

attached you find a maven project [attachment=1]activiti-websphere.zip[/attachment] that contains the support for WebSphere Application Server. It implements a custom Activiti Configuration based on the Spring Configuration object. The use of Spring here is important, as WebSphere contains a specific Transaction Manager support by using so called Units-of-Work. Spring provides support for this. The attached xml configuration [attachment=0]activiti.cfg.xml.zip[/attachment] shows how to use it.

Make sure you have included the dependency for activiti-spring as well, as it is mandatory for this. The only additional configuration parameter for WebSphere is the workManager JNDI-Name.


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" />

    <bean id="processEngineConfiguration" class="org.activiti.websphere.WebSphereEngineConfiguration">    
        <property name="transactionManager"  ref="transactionManager" />
        <property name="jobExecutorWorkManagerJndiName" value="java:comp/env/wm/default" />
    </bean>
</beans>
It donates the JNDI name of the WorkManager to be used. It is optional, and if not specified, the given default value is used.

For the maven project to compile successfully, you need to provide an IBM specific reference to the com.ibm.ws.prereq.commonj-twm.jar-File, which contains the API code for the WorkManagers. You find this file in your WebSphere application servers 'plugin' directory and need to install it into your local repository:


mvn install:install-file -Dfile=com.ibm.ws.prereq.commonj-twm.jar -DgroupId=com.ibm.ws.prereq -DartifactId=commonj-twm -Dversion=1.1 -Dpackaging=jar
The implementation uses an ExecutionService for WorkManagers. The idea came to me while I saw that the default JobExecutor uses the ThreadPoolExecutor.

Attention: This module will only work for Activiti 5.9 or above, as the modifications introduced by JIRA ACT-34 are necessary.

The code is free of use. I would like to get a note if you find a mistake, error or something that could be done better.

Best regards,

Heiko

Thank you very much.
I'll review and try to get ideas for my own stuff, also I will provide the requested feedback as well.