Return-Path: X-Original-To: apmail-openwebbeans-user-archive@www.apache.org Delivered-To: apmail-openwebbeans-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43B3F111D2 for ; Fri, 11 Apr 2014 07:01:19 +0000 (UTC) Received: (qmail 14687 invoked by uid 500); 11 Apr 2014 07:01:18 -0000 Delivered-To: apmail-openwebbeans-user-archive@openwebbeans.apache.org Received: (qmail 14667 invoked by uid 500); 11 Apr 2014 07:01:18 -0000 Mailing-List: contact user-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@openwebbeans.apache.org Delivered-To: mailing list user@openwebbeans.apache.org Received: (qmail 14659 invoked by uid 99); 11 Apr 2014 07:01:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2014 07:01:16 +0000 X-ASF-Spam-Status: No, hits=0.3 required=5.0 tests=FREEMAIL_REPLY,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rmannibucau@gmail.com designates 209.85.216.54 as permitted sender) Received: from [209.85.216.54] (HELO mail-qa0-f54.google.com) (209.85.216.54) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2014 07:01:13 +0000 Received: by mail-qa0-f54.google.com with SMTP id w8so4957783qac.13 for ; Fri, 11 Apr 2014 00:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=91qgSKImUirGn/4qutzaiBJMRcbcl3H6qu+BE8nHt50=; b=zXaXcHRaDAaZ0juq5hoHN9NX8UiEBEqyccQ+WoH6XIksafQIxCtgrlAyT1VRXql7WQ bmjgfc3e24XMpxlvQRo5eXb/Tgm+T0HvvgiQ0PKeYmTtl4v4wzGdtr5foGZoaLH2gZ3J sSJO7ptXRWixgoIHraXx+bO7Iu5sxAuvQImlarambSQxwaifdKyER18dikwVqHJdPHOu v/nI93Qhtl1+mpsuJGZrOe6IXy8daFCMTlZopDlOwSD6amIYjVORug7SaPdzNvosTtdV J03PezcgRHip/9XPXFuB2xhhYUCnFMnSRj2SEmRW4fXSckj97UzCjdfpM10dp0eyCtpB tKeg== X-Received: by 10.224.104.1 with SMTP id m1mr26413672qao.51.1397199652232; Fri, 11 Apr 2014 00:00:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.96.49.133 with HTTP; Fri, 11 Apr 2014 00:00:32 -0700 (PDT) In-Reply-To: <1397199127.57467.YahooMailNeo@web28905.mail.ir2.yahoo.com> References: <1397144977.68542.YahooMailNeo@web28904.mail.ir2.yahoo.com> <1397159659.95715.YahooMailNeo@web28906.mail.ir2.yahoo.com> <1397166017.28079.YahooMailNeo@web28904.mail.ir2.yahoo.com> <1397199127.57467.YahooMailNeo@web28905.mail.ir2.yahoo.com> From: Romain Manni-Bucau Date: Fri, 11 Apr 2014 09:00:32 +0200 Message-ID: Subject: Re: Design - CDI and worker threads To: "user@openwebbeans.apache.org" , Mark Struberg Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org shouldn't work for sure in tomee *by default*. Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau 2014-04-11 8:52 GMT+02:00 Mark Struberg : > Concurrency utils is a completely different spec and IS broken as it does > _not_ define it properly. But for @Asynchronous it's perfectly well defin= ed > in the spec. > > I use this as thread starter for BatchEE and I've tested it in > * TomEE > * WAS-8.0.0.6 > * WAS-8.5.5.1 > * JBossAS-7.0.3.Final > * latest WildFly > > LieGrue, > strub > > > On Friday, 11 April 2014, 7:15, Romain Manni-Bucau > wrote: > > Ok about the spec but propagation doesnt work for sure (it is a kind of > issue for concurrency utilities) > You are right for the config but i just realize i was really not clear > (throw new TooLateException). If you sont configure the container, you ca= n > use a semaphore with 20 permits and the container block you to 10. So it = is > important to have a look too and it can be enough avoiding custom > potentially buggy code. > Le 10 avr. 2014 22:40, "Mark Struberg" a =E9crit : > > > >> But not propagated in async pool..and not in ejb 3.1 > Of course it is! > But you wont find this in the EJB spec - you need to look in the EE umbre= lla > spec and the CDI spec ;) > > >> Ps: you can configure async pool or stateless pool > Yes, some container allow to configure this. But I'm pretty sure there is > nothing in the spec which requires it. So I'd rather hack it myself. > > LieGrue, > strub > > > On Thursday, 10 April 2014, 23:18, Romain Manni-Bucau > wrote: > > Ps: you can configure async pool or stateless pool to limit concurrency > depending the container...but a semaphore enforces it portably >>Le 10 avr. 2014 22:15, "Romain Manni-Bucau" a =E9= crit >> : >> >>But not propagated in async pool..and not in ejb 3.1 >>>Le 10 avr. 2014 20:54, "Mark Struberg" a =E9crit : >>> >>> >>>> >>>>Nope, not right. >>>>The CDI spec mandates that @RequestScoped is active for all EJB calls. >>>> And every subsequent invocation as well of course. >>>> >>>>LieGrue, >>>>strub >>>> >>>> >>>>On Thursday, 10 April 2014, 17:52, Romain Manni-Bucau >>>> wrote: >>>> >>>>actually @Asynch doesn't mandates to start cdi contexts so request >>>>>scopes can or not be here but transactions are handled if you remove >>>>>transaction management. >>>>>Romain Manni-Bucau >>>>>Twitter: @rmannibucau >>>>>Blog: http://rmannibucau.wordpress.com/ >>>>>LinkedIn: http://fr.linkedin.com/in/rmannibucau >>>>>Github: https://github.com/rmannibucau >>>>> >>>>> >>>>> >>>>> >>>>>2014-04-10 17:49 GMT+02:00 Mark Struberg : >>>>>> Hi Lars-Fredrik! >>>>>> >>>>>> This is one of the rare situations where @Asynchronous is good >>>>>> >>>>>> @Stateless >>>>>> @TransactionManagement(TransactionManagementType.BEAN) >>>>>> public class ThreadExecutorEjb { >>>>>> >>>>>> @Asynchronous >>>>>> public void executeTask(Runnable work, Object config) { >>>>>> work.run(); >>>>>> } >>>>>> } >>>>>> >>>>>> The problem with this approach is that WAS is _really_ picky (and fa= r >>>>>> from >>>>>> the spec imo) when it comes to transactions. >>>>>> You might play a bit with the TransactionManagement and other stuff >>>>>> probably. >>>>>> >>>>>> LieGrue, >>>>>> strub >>>>>> On Thursday, 10 April 2014, 16:21, Romain Manni-Bucau >>>>>> wrote: >>>>>> >>>>>> Hmm deltaspike is a lib you can put in your app but if you really wa= nt >>>>>> to get rid of it you can copy >>>>>> >>>>>> https://git-wip-us.apache.org/repos/asf?p=3Ddeltaspike.git;a=3Dblob;= f=3Ddeltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/o= wb/OpenWebBeansContextControl.java;h=3D9e8ba98d46abc3843e8e5b872c882989a98f= e16a;hb=3DHEAD >>>>>> Romain Manni-Bucau >>>>>> Twitter: @rmannibucau >>>>>> Blog: http://rmannibucau.wordpress.com/ >>>>>> LinkedIn: http://fr.linkedin.com/in/rmannibucau >>>>>> Github: https://github.com/rmannibucau >>>>>> >>>>>> >>>>>> >>>>>> 2014-04-10 15:52 GMT+02:00 Lars-Fredrik Smedberg : >>>>>>> Hi >>>>>>> >>>>>>> Thanks for the hint, however I'm not able to use Deltaspike but onl= y >>>>>>> the >>>>>>> OpenWebbeans included with WebSphere 8.5.5.x... >>>>>>> >>>>>>> How can I do this with OpenWebbeans only? >>>>>>> >>>>>>> Regards >>>>>>> Lars-Fredrik >>>>>>> >>>>>>> >>>>>>> On Thu, Apr 10, 2014 at 3:47 PM, Romain Manni-Bucau >>>>>>> >>>>>>> wrote: >>>>>>>> >>>>>>>> Hi >>>>>>>> >>>>>>>> with CdiCtrl of deltaspike you can start/stop contexts. Decorate >>>>>>>> your >>>>>>>> executorService to do it and it should be fine: >>>>>>>> http://openwebbeans.apache.org/testing_cdictrl.html >>>>>>>> Romain Manni-Bucau >>>>>>>> Twitter: @rmannibucau >>>>>>>> Blog: http://rmannibucau.wordpress.com/ >>>>>>>> LinkedIn: http://fr.linkedin.com/in/rmannibucau >>>>>>>> Github: https://github.com/rmannibucau >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> 2014-04-10 15:37 GMT+02:00 Lars-Fredrik Smedberg >>>>>>>> : >>>>>>>> > Hi >>>>>>>> > >>>>>>>> > If I within a thread wishes to start asynchronous "jobs" using t= he >>>>>>>> > ExecutorService (and Executors.newFixedThreadPool(...)) and wait >>>>>>>> > for >>>>>>>> > the >>>>>>>> > Future-result within that same thread I run into the following >>>>>>>> > exception: >>>>>>>> > >>>>>>>> > "WebBeans context with scope type annotation @RequestScoped does >>>>>>>> > not >>>>>>>> > exist >>>>>>>> > within current thread" >>>>>>>> > >>>>>>>> > which is understandable since the managed bean passed used in th= e >>>>>>>> > Callable >>>>>>>> > passed to ExecutorService.submit(...) contains injected beans >>>>>>>> > iteself >>>>>>>> > that >>>>>>>> > are @RequestScoped. >>>>>>>> > >>>>>>>> > Is there any way around this? Suggestions on changing the design >>>>>>>> > perhaps? >>>>>>>> > >>>>>>>> > Regards >>>>>>>> > Lars-Fredrik Smedberg >>>>>>>> > >>>>>>>> > >>>>>>>> > -- >>>>>>>> > Med v=E4nlig h=E4lsning / Best regards >>>>>>>> > >>>>>>>> > Lars-Fredrik Smedberg >>>>>>>> > >>>>>>>> > STATEMENT OF CONFIDENTIALITY: >>>>>>>> > The information contained in this electronic message and any >>>>>>>> > attachments to this message are intended for the exclusive use o= f >>>>>>>> > the >>>>>>>> > address(es) and may contain confidential or privileged >>>>>>>> > information. If >>>>>>>> > you are not the intended recipient, please notify Lars-Fredrik >>>>>>>> > Smedberg >>>>>>>> > immediately at itsmeden@gmail.com, and destroy all copies of thi= s >>>>>>>> > message and any attachments. >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Med v=E4nlig h=E4lsning / Best regards >>>>>>> >>>>>>> Lars-Fredrik Smedberg >>>>>>> >>>>>>> STATEMENT OF CONFIDENTIALITY: >>>>>>> The information contained in this electronic message and any >>>>>>> attachments to this message are intended for the exclusive use of t= he >>>>>>> address(es) and may contain confidential or privileged information. >>>>>>> If >>>>>>> you are not the intended recipient, please notify Lars-Fredrik >>>>>>> Smedberg >>>>>>> immediately at itsmeden@gmail.com, and destroy all copies of this >>>>>>> message and any attachments. >>>>>> >>>>>> >>>>> >>>>> >>>> >> >> > > >