openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject Re: Design - CDI and worker threads
Date Thu, 10 Apr 2014 15:49:37 GMT
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 far 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 <rmannibucau@gmail.com> wrote:
 
Hmm deltaspike is a lib you can put in your app but if you really want
>to get rid of it you can copy
>https://git-wip-us.apache.org/repos/asf?p=deltaspike.git;a=blob;f=deltaspike/cdictrl/impl-owb/src/main/java/org/apache/deltaspike/cdise/owb/OpenWebBeansContextControl.java;h=9e8ba98d46abc3843e8e5b872c882989a98fe16a;hb=HEAD
>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 <itsmeden@gmail.com>:
>> Hi
>>
>> Thanks for the hint, however I'm not able to use Deltaspike but only 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 <rmannibucau@gmail.com>
>> 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 <itsmeden@gmail.com>:
>>> > Hi
>>> >
>>> > If I within a thread wishes to start asynchronous "jobs" using the
>>> > 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 the
>>> > 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änlig hälsning / 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 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 this
>>> > message and any attachments.
>>
>>
>>
>>
>> --
>> Med vänlig hälsning / 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 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 this
>> message and any attachments.
>
>
Mime
View raw message