<div dir="ltr">I don&#39;t think that has anything to do with Undertow, when you call that method it is out of Undertow&#39;s hands (unless you are trying to do something like reading the request from the exchange in the async task, that would be racey). Assuming you are not doing anything like that then it is likey some kind of unrelated bug in your code.<div><br></div><div>Stuart</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 26, 2018 at 4:29 PM, Nabeel Imtiaz <span dir="ltr">&lt;<a href="mailto:nimtiazm@gmail.com" target="_blank">nimtiazm@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi Stuart,<br><br></div>Here&#39;s the pattern:<br><br>```<br></div><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;Menlo&quot;;font-size:9pt"><span style="color:rgb(0,0,128)">public void </span>handleRequest...<pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;Menlo&quot;;font-size:9pt">{</pre></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;Menlo&quot;;font-size:9pt;margin-left:40px"><span style="color:rgb(0,0,128)">if </span>(exchange.isInIoThread())<br>{<br>   exchange.dispatch(<span style="color:rgb(0,0,128)">this</span>);<br>   <span style="color:rgb(0,0,128)">return</span>;<br>}<br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;Menlo&quot;;font-size:9pt;margin-left:40px">//do some I/O intensive work<br>//...<br><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;Menlo&quot;;font-size:9pt;margin-left:40px">CompletableFuture.supplyAsync(<wbr>.../*send email with logged exception handling*/...) //#A<br><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;Menlo&quot;;font-size:9pt">exchange.getResponseSender().<wbr>send(responseJson);</pre></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;Menlo&quot;;font-size:9pt">}</pre>```<br><br></div><div>The line #A is inconsistent. The task in #A is executed by a thread in common forkjoin pool and may be that could be the reason? I&#39;m not sure.<br><br></div><div>Maybe using one of undertow&#39;s worker threads might solve it? Is there a way to do so? All I want is to return response to the client immediately and execute delayable work in the background thread.<br><br></div><div>Thanks.<br></div><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 26, 2018 at 4:50 AM, Stuart Douglas <span dir="ltr">&lt;<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">How are you running the task? If you just submit it to the worker it should just run like any normal executor.<div><div><br></div><div>Stuart<br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-4914933201435467598h5">On Mon, Mar 26, 2018 at 3:31 AM, Nabeel Imtiaz <span dir="ltr">&lt;<a href="mailto:nimtiazm@gmail.com" target="_blank">nimtiazm@gmail.com</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-4914933201435467598h5"><div dir="ltr"><div><div><div><div>Hi,<br><br></div>I&#39;m trying to perform expensive tasks (like sending email/sms etc) as an async task (using CompletableFuture API) after my undertow worker completes and i&#39;m about to respond to the client. These tasks are supposed to work like fire and forget and I don&#39;t want to wait until the task completes and then respond to the client.<br><br></div>I&#39;ve noticed that sometimes the task doesn&#39;t execute and sometimes it does. It&#39;s inconsistent and hard to reproduce. Is there a way to be able to perform these async tasks consistently? May be i&#39;m using wrong thread-pool? Or may be there&#39;s already a way in Undertow to do such tasks.<br><br></div>Please comment.<br><br></div>Thanks.<br></div>
<br></div></div>______________________________<wbr>_________________<br>
undertow-dev mailing list<br>
<a href="mailto:undertow-dev@lists.jboss.org" target="_blank">undertow-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailma<wbr>n/listinfo/undertow-dev</a><br></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>