1 2 Previous Next 20 Replies Latest reply on Feb 18, 2013 3:03 PM by marcgagnonpincourt

    Work Manager in AS7

    hostalp

      Hello,

      how can I define a custom work manager in AS7?

      It looks like the implementation is available via ironjacamar project (org.jboss.jca.core.workmanager.WorkManagerImpl), but there seems to be just some default-workmanager in the AS7 config and no option for defining another one.

        • 1. Re: Work Manager in AS7
          jesper.pedersen

          IronJacamar/Standalone has support for multiple work managers through different bootstrap context's.

           

          How much of this functionality we port over for AS 7.1 depends on users' use-cases.

           

          So describe yours - what are you looking to do, what settings do you need and so on.

          • 2. Re: Work Manager in AS7
            hostalp

            Hello,

             

            basically we use few work managers via Spring (org.springframework.jca.work.jboss.JBossWorkManagerTaskExecutor).

            For JBoss AS6 we had to fix it a little to get it to work (http://community.jboss.org/thread/160071).

             

            So the ability to define a work manager and use its managed threads for asynchronous work would be great..

             

            An example of our configuration for JBoss AS6:

             

             

            <deployment xmlns="urn:jboss:bean-deployer:2.0">
              <!-- ==================================================================== -->
              <!-- JBossCX setup, for J2EE connector architecture support               -->
              <!-- ==================================================================== -->
              <!-- My WORK MANAGER THREAD POOL - http://community.jboss.org/wiki/threadpoolconfiguration -->
              <threads xmlns="urn:jboss:threads:2.0">
                 <thread-group name="MyWorkManagerThreadGroup"/>
                 <thread-factory name="MyWorkManagerThreadFactory" thread-name-pattern="MyWorkManager-%t">
                    <thread-group name="MyWorkManagerThreadGroup"/>
                 </thread-factory>
                 <bounded-queue-thread-pool-executor name="MyWorkManagerThreadPool" blocking="true">
                  <!-- Bean deployment name of the thread factory that should be used to create the threads used by this executor. The target object should implement java.util.concurrent.ThreadFactory. If not specified, the system default thread factory is used -->
                    <thread-factory name="MyWorkManagerThreadFactory"/>
                    <!-- Fixed length of the task queue -->
                    <queue-length count="1024"/>
                    <!-- Size of the core pool size. If omitted, the value will be equal to the value given for the "max-threads" element -->
                    <core-threads count="1"/>
                    <!-- Maximum number of threads in the pool -->
                    <max-threads count="2"/>
                    <!-- Length of time after which idle threads will exit -->
                    <keepalive-time time="60" unit="seconds"/>
                 </bounded-queue-thread-pool-executor>
              </threads>
              <!-- My WORK MANAGER -->
              <bean name="MyWorkManager" class="org.jboss.resource.work.JBossWorkManager">
                 <!-- Expose via JMX -->  
                 <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.jca:service=MyWorkManager", exposedInterface=org.jboss.resource.work.JBossWorkManagerMBean.class)</annotation>
                 <!-- The thread pool -->
                 <property name="executor"><inject bean="MyWorkManagerThreadPool"/></property>
                 <!-- The xa terminator --> 
                 <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
              </bean>
            </deployment>
            
            • 3. Re: Work Manager in AS7
              jesper.pedersen

              I'll cook something up and we can take it from there.

              • 4. Re: Work Manager in AS7
                balaswd

                It worked in JBoss 5.1. Try it in your server..

                http://java-explorer.blogspot.in/2012/02/workmanager-in-jboss-510.html

                • 5. Re: Work Manager in AS7
                  jesper.pedersen

                  AS 7.1: Define a <jca:workmanager>, create a <jca:bootstrap-context> with a link to the <workmanager> using the name, then use <bootstrap-context> in your <resource-adapter> definition.

                  • 6. Re: Work Manager in AS7
                    jbertram

                    To be clear, org.springframework.jca.work.jboss.JBossWorkManagerTaskExecutor treats the JBoss javax.resource.spi.work.WorkManager implementation as if it was an implementation of JSR-237.  This is clear from the Spring documentation which states, "This is the JBoss equivalent of the CommonJ WorkManagerTaskExecutor adapter for WebLogic and WebSphere."  To my knowledge, this statement in inaccurate.  Our javax.resource.spi.work.WorkManager implementation is for JCA resource adapters (implied by the fact that javax.resource.spi.work.WorkManager is part of the JCA API) and not a general work manager as envisaged by JSR-237.  Although it was technically possible to get a reference to a javax.resource.spi.work.WorkManager implementation in previous versions of JBoss AS it was never designed for this. 

                    1 of 1 people found this helpful
                    • 7. Re: Work Manager in AS7
                      aminjava

                      Do we have any example for schema reference for workmanager configuration?

                      • 8. Re: Work Manager in AS7
                        jbertram

                        Check out docs/schema/jboss-as-jca_1_1.xsd.

                         

                        That said, I have a feeling you want to use a JCA WorkManager in a general context rather than from within a JCA Resource Adapter.  If that is so then you should read this comment.  In short, you should only use the JCA WorkManager from a JCA Resource Adapter.  It is not a general thread pooling solution.

                        • 9. Re: Work Manager in AS7
                          ludof

                          Hello,

                           

                               I'm also trying to define custom work manager with JBoss 7.2 wihtout sucess. We currently using JBoss 5.1 and we use jca-jboss-beans.xml, but we will now migrate under JBoss 7.

                           

                               Could you please post a sample of config file and source code to use this custom work manager ?

                           

                          Thanks,

                          ludof.

                          • 10. Re: Work Manager in AS7
                            nnanda

                            Hi Jesper,

                             

                            Can you please provide an elaborative sample? I am new to JBoss 7 and little confused.

                             

                            Thanks,

                            Niranjan

                            • 11. Re: Work Manager in AS7
                              jesper.pedersen

                              You shouldn't expose and use the WorkManager API directly in your application.

                               

                              You should implement a custom resource adapter which exposes the API that makes sense for your application, and then have the resource adapter use the WorkManager API internally.

                               

                              You can use our code generator to get started, or our Eclipse plugin. Download IronJamacar 1.1.0.Beta3, and see the user guide.

                               

                              Also search the IronJacamar test suite for examples of resource adapter implementations. However, keep in mind these for test cases, and may not represent the best practices for resource adapter development. F.ex. we did http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/workmanager/rars/dwm/ in order to test the WorkManager.

                               

                              You can always use the IronJacamar user forum to get help with your resource adapter development tasks.

                              • 12. Re: Work Manager in AS7
                                marcgagnonpincourt

                                Specification JSR-236 and JSR-237 make a lot of sense whenever an application needs to access external systems in parallel.

                                In our case, we query airlines for flights availability using web services APIs.

                                Using a ressource adapter for implementing this seems too much work and we used http://commonj.myfoo.de/ (with some bug fixes and adjustments).

                                Now, there is no way of doing this in jboss7? Nonsense!

                                JSR-237 addresses precisely the kind of situation we have to deal with.

                                So, yes, the workmanager API should be exposed to applications.

                                Please reconsider this decision.

                                By the way, you have just invalidated spring' WorkManagerTaskExecutor which is based on commonj...

                                There is a lot to like about jboss7 but this specific decision is simply wrong.

                                • 13. Re: Work Manager in AS7
                                  jbertram

                                  Specification JSR-236 and JSR-237 make a lot of sense whenever an application needs to access external systems in parallel.

                                  JSR-236 is still just a draft, and JSR-237 was withdrawn 5 years ago (apparently amid license and/or patent issues between IBM and BEA).

                                   

                                   

                                  Now, there is no way of doing this in jboss7? Nonsense!

                                  JSR-237 addresses precisely the kind of situation we have to deal with.

                                  It's true that you can no longer use the JCA WorkManager on tasks for which it was not designed, but JMS is a viable option for concurrent tasks and so is EJB 3.1's asynchronous session beans (which are backed by a configurable thread pool).

                                   

                                   

                                  By the way, you have just invalidated spring' WorkManagerTaskExecutor which is based on commonj...

                                  I already commented on this Spring component.  Simply put, it was always invalid.

                                  • 14. Re: Work Manager in AS7
                                    marcgagnonpincourt

                                    Thank you for these clarifications.

                                    Maybe someone should look at as many posts as possible and clarify thing:

                                    What are specs JSR-236 and 237, their state, explain the historical hacks around WorkManagers and that they are now designed to be used inside connectors only.

                                    That would get things straight for all developpers trying to access workmanagers.

                                     

                                    I understand we could use JMS but that would imply additional marshalling of potentially big objects.

                                    As for EJBs, I also understand it might be a solution technically but some places (including ours) made a choice of not using them (favoring a spring-only approach).

                                    ...Maybe it is time to reconsider this, though!

                                     

                                    There is a use case for wanting to use container managed threads and maybe the right solution is not to expose the WorkManager API after all...

                                    Rather, maybe there should be a new project: a generic web service JCA connector: one would use this connector along with some kind of XML descriptor:

                                    That descriptor would point to a WSDL and would state how many calls may be run simultaneously (throttling) and control other attributes.

                                    The caller of this connector would be an application that would otherwise have to manage threads in order to issue many WS calls.

                                     

                                    Ok, sounds too complicated... I suppose using JMS is the right way to go; an additional benefit being additional scalability.

                                     

                                    That would do the jobs for us while respecting the way workmanagers are now designed to be used in JB7.

                                    1 2 Previous Next