<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Session and RequestScoped CDI from Job in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176138#M129268</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All right, considering the future requirements where my approach might not be sufficient, I will go with your approach of @Async EJB method. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One other question: why did you change the AcquireJobRunnable to an EJB timer? &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Jul 2014 13:32:43 GMT</pubDate>
    <dc:creator>pkonyves</dc:creator>
    <dc:date>2014-07-04T13:32:43Z</dc:date>
    <item>
      <title>Session and RequestScoped CDI from Job</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176134#M129264</link>
      <description>When there is a job that is executed by a Job executor, there is no CDI SessionScoped and RequestScoped context. A few of our business logic CDI beans are session or request scoped, but I also want them to work when executed by the JobExecutor. I was thinking of programmaticaly creating and activati</description>
      <pubDate>Wed, 02 Jul 2014 07:21:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176134#M129264</guid>
      <dc:creator>pkonyves</dc:creator>
      <dc:date>2014-07-02T07:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Session and RequestScoped CDI from Job</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176135#M129265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;let me assume that you are using a JEE container and do not use Activiti in Java SE with CDI. If so, you suffer from the default implementation of the job executor. This job executor creates so called unmanaged threads, which are no longer controlled by the container and thus lack any support for container based services such as EJB or CDI scopes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please refer to my post here: &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/comment/23760#comment-23760" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/comment/23760#comment-23760&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've described what we did to have a job executor with managed threads under WebSphere, but the solution is JEE 6 compatible for other containers as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Simply using interceptors won't help you, better just change the job executor in a way that it will keep respectively create managed threads. If the Application Server supports the so called ManagedExecutorService, this would be even easier than the described implementation, but still creating the scopes by hand won't help you, cause you lack other features the container provides, such as transactions and EJBs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Heiko&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 20:49:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176135#M129265</guid>
      <dc:creator>bardioc</dc:creator>
      <dc:date>2014-07-02T20:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Session and RequestScoped CDI from Job</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176136#M129266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Bardioc,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your quick response. So as I understand, the essence to make the threads managed according to you is "lookup a local EJB via JNDI from our Job Executor and call a method annotated with @Asynchronous within it, passing in the ExecuteJobsRunable which is then executed within the asynchronous method"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One thing to note We don't use EJBs. What we use is: Activiti, CDI, JTA transaction manager. We try to avoid using EJBs (experimentally).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I found: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Transactions will be ok, because we set manually the TransactionManager in JtaProcessEngineConfiguration&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- CDI bean lookup will be ok, because Activiti sets the beanmanager in BeanManagerLookup statically (In JavaDelegate tasks I usually use ProgrammaticBeanLookup)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Because of the lack of Servlet request, there is no SessionScoped and RequestScoped context which I wanted to overcome by creating and activating these contexts in DelegateInterceptor with the method explained here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.jboss.org/weld/reference/latest/en-US/html_single/#d0e6020" rel="nofollow noopener noreferrer"&gt;http://docs.jboss.org/weld/reference/latest/en-US/html_single/#d0e6020&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;a&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you think it's feasible? Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 09:23:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176136#M129266</guid>
      <dc:creator>pkonyves</dc:creator>
      <dc:date>2014-07-03T09:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Session and RequestScoped CDI from Job</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176137#M129267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wonder why you want to avoid EJBs, but that is your decision. You would simply need a single EJB @Stateless bean with an @Asynchronous annotated method that you can call via CDI to pass in the ExecutableJobsRunnable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For one thing, this will only give you RequestScope and ApplicationScope. SessionScope however is a completely different area, cause EJB will only provide this for Stateful beans. I wonder why you rely on SessionScoped beans for Activiti. What is your Session in that case? After becoming asynchronous via a Timer, there is no longer an associated session.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise, feel free to just start the scopes and see if that works. I wonder how entity management and transactions will work out. Simply adding a JTA transaction manager does not give you container based transactions, cause in unmanaged threads, no container will open up a transaction neither commit or rollback.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Btw. to start your scopes, refer to DeltaSpike Container Ctrl which helps you to start scopes pretty easily, rather than directly using Weld. Otherwise you might be incompatible with other application servers.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 11:21:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176137#M129267</guid>
      <dc:creator>bardioc</dc:creator>
      <dc:date>2014-07-03T11:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Session and RequestScoped CDI from Job</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176138#M129268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All right, considering the future requirements where my approach might not be sufficient, I will go with your approach of @Async EJB method. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One other question: why did you change the AcquireJobRunnable to an EJB timer? &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2014 13:32:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/session-and-requestscoped-cdi-from-job/m-p/176138#M129268</guid>
      <dc:creator>pkonyves</dc:creator>
      <dc:date>2014-07-04T13:32:43Z</dc:date>
    </item>
  </channel>
</rss>

