<div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 19, 2016 at 10:02 PM, Stephan Knitelius <span dir="ltr">&lt;<a href="mailto:stephan@knitelius.com" target="_blank">stephan@knitelius.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Well as discussed in another mail, the concurrency spec is a bit ambiguous about context propagation, it&#39;s not explicitly forbidden. <br><br>Would a new context also belong into the concurrency spec?</blockquote><div><br></div><div>I think so. Such context is intended for concurrency (threading), and there&#39;s a strong precedent for that the spec that owns a concept defines the context. E.g. JTA defines the @Transactional context, JSF the @FlowScoped one, MVC @RedirectScoped, etc.</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Sa., 19. März 2016 at 21:57, arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com" target="_blank">arjan.tijms@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br><br>On Saturday, March 19, 2016, Stephan Knitelius &lt;<a href="mailto:stephan@knitelius.com" target="_blank">stephan@knitelius.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I would certainly agree with the assertion that in general it&#39;s not advisable to execute a request with multiple threads and that usually single threaded execution is sufficient.<br><br>However I don&#39;t think ignoring it is an option. Concurrent operations can be launched even from CDI beans. Yet we don&#39;t properly support context propagation nor a context spanning all threads launched from a request.</blockquote><div><br></div><div>That really sounds like a very useful proposal. Kinda like a session scope, but for a select group of threads.</div><div><br></div><div>Like so many other things, logically you&#39;d say such thing should be placed in the concurrency spec. Feels weird to put things in another less logical place just because there are no plans do a concurrency spec update.</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>I know that changing @requestScoped is probably out of the question, but at least we should consider adding a new context spanning all threads and defining a logical solution for context propagation that can be explained to the end user.<br> <br><br><br><div class="gmail_quote"><div dir="ltr">On Fr., 11. März 2016 at 17:17, Mark Struberg &lt;<a>struberg@yahoo.de</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Yes, but certain things in EE are assumed to be handled on a single thread. And if you run on a servr then this is really not a blocker most times. If I get many paralllel requests hitting my box then I do not need async handling _that_ often. The whole overhead for setting up the new thread, etc often heavily exceeds the benefits.<br>
So I would not put too much energy into it…<br>
<br>
LieGrue,<br>
strub<br>
<br>
&gt; Am 11.03.2016 um 15:44 schrieb Reza Rahman &lt;<a>reza_rahman@lycos.com</a>&gt;:<br>
&gt;<br>
&gt; This is essentially in keeping with the minimalist nature of the EE concurrency JSR. I believe most of it is left to vendors to do the right thing for users. May be a good idea is this language can be tightened up.<br>
&gt;<br>
&gt;&gt; On Mar 11, 2016, at 6:01 AM, Mark Struberg &lt;<a>struberg@yahoo.de</a>&gt; wrote:<br>
&gt;&gt; E<br>
&gt;&gt; From the servlet spec:<br>
&gt;&gt;<br>
&gt;&gt; „Java Enterprise Edition features such as Section 15.2.2, “Web Application Environment” on page 15-174 and Section 15.3.1, “Propagation of Security Identity in EJBTM Calls” on page 15-176 are available only to threads executing the initial request or when the request is dispatched to the container via the AsyncContext.dispatch method. Java Enterprise Edition features may be available to other threads operating directly on the response object via the AsyncContext.start(Runnable) method.“<br>
&gt;&gt;<br>
&gt;&gt; check „available only to threads executing the initial request“<br>
&gt;&gt;<br>
&gt;&gt; Also if you look at the servlet AsyncContext then all the wording is written as MAY and not as MUST.<br>
&gt;&gt;<br>
&gt;&gt; LieGrue,<br>
&gt;&gt; strub<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; Am 10.03.2016 um 19:52 schrieb Romain Manni-Bucau &lt;<a>rmannibucau@gmail.com</a>&gt;:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi Mark,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; think 2.3.3.4 states the opposite.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Romain Manni-Bucau<br>
&gt;&gt;&gt; @rmannibucau |  Blog | Github | LinkedIn | Tomitriber<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; 2016-03-10 19:43 GMT+01:00 Mark Struberg &lt;<a>struberg@yahoo.de</a>&gt;:<br>
&gt;&gt;&gt; Back from JavaLand conference, so sorry for not kicking in earlier.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I not quite get the argumentation chain. It’s that all triggered by async servlet requests? And isn’t the servlet spec also saying that all the request param etc may max be assigned to a single thread AT A TIME!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Means that it might not be on multiple threads in parallel, but the data is allowed to get moved from one thread to another (disapearing from the first one), right?<br>
&gt;&gt;&gt; Would really need to dig into the wording of the async servlets spec again, maybe has this in the back of his head?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; LieGrue,<br>
&gt;&gt;&gt; strub<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Am 08.03.2016 um 14:43 schrieb Romain Manni-Bucau &lt;<a>rmannibucau@gmail.com</a>&gt;:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi guys,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; following request scope thread and to center the discussion on the thread safety part: do we work on this?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Background: @RequestScoped is often used as a ThreadLocal instance solution. A lot of SE or Batch implementations rely on it from what I saw as well as async implementations reusing existing business logic with this thread safety constraint.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Proposal: providing a @ThreadScoped implementation is cheap for CDI and implemenation and would avoid the headache we can have with @RequestScoped. Will also remove the quite dark side of the spec regarding servlet request and request scope since now we would have a more natural solution for all of these situation so @RequestScoped goals wouldn&#39;t collide as much.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Questions:<br>
&gt;&gt;&gt;&gt; - is it automatically started as request scoped is (JMS, @Async, ...)? Alternative could be some configuration in beans.xml (merged accross the app):<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; &lt;beans&gt;<br>
&gt;&gt;&gt;&gt; &lt;scopes&gt;<br>
&gt;&gt;&gt;&gt;   &lt;thread&gt;<br>
&gt;&gt;&gt;&gt;     &lt;active&gt;JMS&lt;/active&gt;<br>
&gt;&gt;&gt;&gt;     &lt;active&gt;ASYNCHONOUS&lt;/active&gt;<br>
&gt;&gt;&gt;&gt;   &lt;/thread&gt;<br>
&gt;&gt;&gt;&gt; &lt;/scopes&gt;<br>
&gt;&gt;&gt;&gt; &lt;/beans&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; - start/stop API (this is typically an API the user should be able to control for its own threads)<br>
&gt;&gt;&gt;&gt; - CDI 2.*0*?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; wdyt?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Romain Manni-Bucau<br>
&gt;&gt;&gt;&gt; @rmannibucau |  Blog | Github | LinkedIn | Tomitriber<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt;&gt; <a>cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; <a>cdi-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;&gt;<br>
&gt;&gt; Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; <a>cdi-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
&gt;<br>
&gt; Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
<br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a>cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.</blockquote></div>
</blockquote>
</blockquote></div>
</div></div></blockquote></div><br></div></div>