<?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: Java Service Task and HttpClient in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204718#M157848</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, good and well documented explanation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just for validation: if you do this on Activiti 5.15, does it happen also? I have a hunch it might be due some 'logic' that was added there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, the async true/false that you tried worries me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you hook up jvisualvm to the instance and see if it has indeed 100 threads at least blocked?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Nov 2014 13:12:47 GMT</pubDate>
    <dc:creator>jbarrez</dc:creator>
    <dc:date>2014-11-05T13:12:47Z</dc:date>
    <item>
      <title>Java Service Task and HttpClient</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204714#M157844</link>
      <description>Hi all,I try to write a custom java service task which uses one http client to make one call per service task to an external custom api. PoolingHttpClientConnectionManager &amp;gt; CloseableHTTPClient &amp;gt; Java Service task (async) &amp;gt; 100 * HttpPost / HttpGetThe problem with this is: When I execute mo</description>
      <pubDate>Sun, 02 Nov 2014 13:27:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204714#M157844</guid>
      <dc:creator>martinfranz</dc:creator>
      <dc:date>2014-11-02T13:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Java Service Task and HttpClient</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204715#M157845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Update: I almost solved the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I forgot to mention that I run actviti-rest and activiti-explorer next together in one tomcat instance. Both use the same mysql "activiti" schema. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I double checked the processEngineConfiguration in both application context files and realized that my activate-rest uses &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;jobExecutorActivate = false. So I set this to true in both context files. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What happens now: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Start 100 process instances of a simple process containing a timer intermediate event and my service task via REST API.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Login to activiti-exlporer as admin and can see 100 timer jobs firing in x minutes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. ACT_RU_JOB from mysql also shows me these 100 jobs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Than the timer event occurs and i can see in ACT_RU_JOB that the jobs are done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5. After 3-4 minutes all jobs are done and ACT_RU_JOB is empty. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6. Check the network traffic on the target API side and realized that all 100 calls where made. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7. Everything OK&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;8. Try to login into activate-explorer again. Freeze! Communication failure. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nothing happens here. Activiti-explorer is out of reach. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But activit-rest works as aspected. (same time same machine) I can serve task or process definitions via rest api without any problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Restart activiti-explorer via tomcat manager does not work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Shutdown tomcat. Killall java. Startup tomcat. Works! Activit-explorer is now running again. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;JAVA_OPTS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Xms1024m -Xmx2048m -XX&lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://connect.hyland.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;ermSize=32m -XX:MaxPermSize=512m -Xss2m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Djava.awt.headless=true&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Nov 2014 22:09:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204715#M157845</guid>
      <dc:creator>martinfranz</dc:creator>
      <dc:date>2014-11-02T22:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Java Service Task and HttpClient</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204716#M157846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm you are not the first one reporting this problem. It seems there is a fundamental problem with the job executor + Activiti Explorer in the latest releases. But so far, we haven't found the cause yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for digging into this, much appreciated. So your analysis points in the direction of the threadpool on the Tomcat rather than the database connection pool?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 10:59:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204716#M157846</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2014-11-03T10:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Java Service Task and HttpClient</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204717#M157847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could it be a problem that both the activiti-explorer as well as the activiti-rest app running on one tomcat instance? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I mean - with this setup you have two running activiti engines pointing to the same database. Pooling Jobs from one table? Could this work without any problems? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In tomcat you can specify an executor with a max thread size. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I made another test:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Stop activiti-explorer &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Start 400 process instances via activiti-rest. (in a for loop, whit a delay of 1 second per iteration)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The process definition here is quit simple:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;StartEvent &amp;gt; Timer Caching Event &amp;gt; Java Service Task &amp;gt; User Task &amp;gt; End Event &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. ACT_RU_JOB now shows 400 entries (400 timers - they all should fire at the same time) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Timer event fires and the number of entries in ACT_RU_JOB slowly begins to decrease. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5. After 12 Minutes all Jobs are done. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6. Startup activiti-explorer via tomcat manager.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7. Everything works as aspected. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem with this test for me is that the execution takes to long. It feels like all process instances run in sequence - not parallel. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried async true and false on the java service task. Same result. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Normally there should be at least 100 http client executions at the same time. But here there is just one by one. … But this could also be a problem within the connection pool ore with my java service task implementation themselves. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I make some more tests an keep you up to date. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards from Nuremberg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 13:37:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204717#M157847</guid>
      <dc:creator>martinfranz</dc:creator>
      <dc:date>2014-11-03T13:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Java Service Task and HttpClient</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204718#M157848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, good and well documented explanation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just for validation: if you do this on Activiti 5.15, does it happen also? I have a hunch it might be due some 'logic' that was added there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, the async true/false that you tried worries me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you hook up jvisualvm to the instance and see if it has indeed 100 threads at least blocked?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 13:12:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204718#M157848</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2014-11-05T13:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Java Service Task and HttpClient</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204719#M157849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So first of all - sorry for mention that so late - i am currently using Version 5.15.1. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And the second thing: After a bit more digging into this problem I would say that activiti does his job well. My problem here was how I used the HttpClient and also the misunderstanding how Java Service Tasks are executed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just imagine the following scenario: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You have a Java Service Task creating and executing a http client directly in the execute method. That could not work. Even the apache docs for http client say that you should never use multiple instances of http clients. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; What happens here: The http client execution blocks the thread which executes the Java Service Task. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; You want recognize this as long as your Service Task comes after a User Task. In this case it is definitely not possible that multiple user execute their task absolutely synchron. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; You definitely will recognize this if your Service Task comes a the beginning of a process or after a timer event. In this case it could happens that the Service Task is executed a 100 times at the same time. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I ended up with the following setup: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Create a global connection pool for all your http client executions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Limit the max client connections! (Less is more)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Create a global instance of a http client using the connection pool as well as other strategy implementations. (keep alive, connection reuse)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. In your Java Service Task create the desired http method with headers etc as well as a new thread which executes your method with your single instance http client. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tested this scenario with 400 concurrent executions - means 400 process instances starting at the same time. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; Start Event &amp;gt; Timer Event &amp;gt; Java Service Task &amp;gt; User Task. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Results:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. After the 400 timers fired activiti needed just 2 seconds the generate the 400 User Task. (No blocking anymore)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. The connection pool with max 20 connections needed about 2 minutes for executing all requests. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I feel save now using the http client within a service task &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is just one more thing i have not tested jet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have started this post because my initial problem was the usage of acitvit rest and activiti explorer in one tomcat instance with on db. I don't know much about the core functionality of the activati engine but could it be possible that two job executors pulling jobs form the same table &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;won't work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 21:05:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204719#M157849</guid>
      <dc:creator>martinfranz</dc:creator>
      <dc:date>2014-11-05T21:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Java Service Task and HttpClient</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204720#M157850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, thanks for posting this all back. Very good information for many people!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Two job executors normally have no problems pulling from the same database (it was designed for that).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Nov 2014 10:44:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/java-service-task-and-httpclient/m-p/204720#M157850</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2014-11-10T10:44:35Z</dc:date>
    </item>
  </channel>
</rss>

