Set timeout for Webservice call

1,247 views
Skip to first unread message

Karl-Heinz Stöckler

unread,
Jun 19, 2015, 8:08:04 AM6/19/15
to camunda-...@googlegroups.com
Hi,

I have a Webservice Call (SOAP-WSDL).

        OptionStoreServiceLocator optionStoreServiceLocator = new OptionStoreServiceLocator();
       
IOptionStore optionStoreStub;

       
boolean result = optionStoreStub.upgradeProject(fabN, optionsArray, email, language); //call of Webservice Funktion



The service might take up to 1 hour, until it sends an response.

I always get an error, because of the response time... How can I set the response time?

Thank you
Karl

thorben....@camunda.com

unread,
Jun 19, 2015, 9:22:36 AM6/19/15
to camunda-...@googlegroups.com
Hi Karl,

What kind of an error do you get and how is it related to Camunda? Could you post an exception + stack trace?

Thanks,
Thorben

Karl-Heinz Stöckler

unread,
Jun 19, 2015, 11:13:57 AM6/19/15
to camunda-...@googlegroups.com
Hi,

it is not really an exception.
I get an warning
17:07:15,807 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper) ARJUNA012117: TransactionReaper::check timeout for TX 0:ffff0a31480e:18057fc5:55842e95:150 in state  RUN
17:07:15,812 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012095: Abort of action id 0:ffff0a31480e:18057fc5:55842e95:150 invoked while multiple threads active within it.
17:07:15,813 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012108: CheckedAction::check - atomic action 0:ffff0a31480e:18057fc5:55842e95:150 aborting with 1 threads active!
17:07:15,844 WARN  [com.arjuna.ats.arjuna] (Transaction Reaper Worker 0) ARJUNA012121: TransactionReaper::doCancellations worker Thread[Transaction Reaper Worker 0,5,main] successfully canceled TX 0:ffff0a31480e:18057fc5:55842e95:150

Thanks
Karl

Frank Langelage

unread,
Jun 19, 2015, 3:45:30 PM6/19/15
to camunda-...@googlegroups.com
Seems you're using JBoss / WildFly. JBoss / WildFly has a default transaction timeout of 5 minutes = 300 seconds.
You can modify the default or add this to your business method
@TransactionTimeout(value = 1, unit = TimeUnit.HOURS)
if you have CMT.
In case of BMT
transaction.setTransactionTimeout( Constants.ONE_HOUR_MS / 1000 );

Karl-Heinz Stöckler

unread,
Jun 20, 2015, 3:24:50 AM6/20/15
to camunda-...@googlegroups.com
Hi Frank,

yes you are right I am using JBOSS 7.3.0-alpha 3

What I did now is to set the property in the standalone.xml

        <subsystem xmlns="urn:jboss:domain:transactions:1.3">

           <core-environment>

               <process-id>

                   <uuid/>

               </process-id>

           </core-environment>

           <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>

            <coordinator-environment default-timeout="36000"/>

       </subsystem>


I am still not quite sure if it fixes the problem, cause the default value was 300 (which is 5 minutes), now I alwas got an response after about 4 minutes and 50 seconds...
But what I tried is to set the value to 60 (1 minute) then I got the warning already after one minute, so I guess this should work.

Thanks
Karl

Karl-Heinz Stöckler

unread,
Jun 21, 2015, 5:53:45 AM6/21/15
to camunda-...@googlegroups.com
Hi,

now I found out that this did not solve the problem :/

What I have is a class with an execute Methode, which is used by a service task.
And in the execute Methode I call a webservice, and the response of the webservice takes more than 5 minutes.

What I did was to add a Web Service Client  from the WSDL of the Webservice
and then I added a call to this webservice in the execution Methode.

public class xyz implements JavaDelegate{

   
public void execute(DelegateExecution delegateExecution) throws Exception {


OptionStoreServiceLocator optionStoreServiceLocator = new OptionStoreServiceLocator();
       
IOptionStore optionStoreStub;

       
boolean result = optionStoreStub.upgradeProject(fabN, optionsArray, email, language); //call of Webservice Funktion
   
   
}
}

Now after setting the default-timeout in the standalone.xml I do not get the warning anymore, but after 5 minutes I the system calls the webservice again.

Thanks Karl

Frank Langelage

unread,
Jun 21, 2015, 11:31:29 AM6/21/15
to camunda-...@googlegroups.com
Karl,

which systems calls what again?
I guess the xyz.execute is called only once by camunda engine. This seems to be a simple Java class, or POJO, no EJB.
And at this point, from my understanding, you're no in a JTA transaction yet.
So probably you're using a SLSB or so later in your OptionStore.
Which WebService implementation you're using for calling the webservice? The one provided by the JBoss AS or something else as part of your deployment unit?
Very likely that this has a timeout too and perhaps also something in OptionStore doing some retry?
You will have to find out how to modify the timeout of your webservice call.

As far as I remember the switch of JBossWS to Apache CXF was later, so you with your 7.3.0 server probably are using something else.

A piece of code I'm using to extend the timeout of the webservice calls to an infinite value:

package biz.mbisoftware.web.service;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

public class Helper
{
   
public static void modifyRecieveTimeout( final Object o )
   
{
       
Client client = ClientProxy.getClient( o );
       
HTTPConduit conduit = (HTTPConduit)client.getConduit();
       
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy
.setReceiveTimeout( 0 );
        conduit
.setClient( httpClientPolicy );
   
}
}


Regards, Frank

Frank Langelage

unread,
Jun 21, 2015, 11:54:32 AM6/21/15
to camunda-...@googlegroups.com
Add on: also in one of our previous releases where we were using JBoss AS 7.20 I used this piece of code.
So it could work for you too, if you're using the JBossWS version provided by the JBoss AS.

Your piece of code seems to be a bit incomplete, as IOptionStore optionStoreStub; is not initialized.
But this will be the object the Helper::modifyReceiveTimeout needs to be called with before you call the webservice itself certainly.

Karl-Heinz Stöckler

unread,
Jun 22, 2015, 3:29:43 AM6/22/15
to camunda-...@googlegroups.com
Hi Frank,

I am currently not on the machine where I am working with camunda.

You are right I forgot to copy one line in my piece of code.
The missing line is something like:
optionStoreStub = optionStoreServiceLocator.getHTTPBinding_IOptionStore();

I am not quite sure about how exactly the getBinding is called, I will take a look in the evening when I am on the machine where I am working with camunda.

The problem seems not to be in the xyz execute methode. Because I write some Logger messages to the console when the methode is called and also when the methode ends. And exatly after 5 minutes the execution methode is called again.
And then after the webservice finishes and a result is returned I get the result. But the problem is that I have two or more calles and this makes my process crash.

I found a way in the standalone.xml to set this time, but I do not know by heart which it was, I also will take a look in the evening. It worked, but I only tested it with a Webservice that takes exactly 6 minutes. But I think it solved the problem.

Thanks
Karl



thorben....@camunda.com

unread,
Jun 22, 2015, 3:36:27 AM6/22/15
to camunda-...@googlegroups.com
Hi Karl,

Some people also use the async service task pattern to implement long running web service calls. That way, the process engine does not need to keep a transaction troughout the invocation of the service call and you don't need to configure transaction timeouts, etc. Depending on your use case, it may be a suitable solution. You can find an example under [1].

Cheers,
Thorben

[1] https://github.com/camunda/camunda-bpm-examples/tree/master/servicetask/service-invocation-asynchronous

Karl-Heinz Stöckler

unread,
Jun 22, 2015, 3:38:46 PM6/22/15
to camunda-...@googlegroups.com
Hi,

now I can add the details to my previous posting:
IOptionStore optionStoreStub = optionStoreServiceLocator.getBasicHttpBinding_IOptionStore();

was the missing code.

And what I edited in the standalone.xml is the following:
in the following code part i set the instance-acquisition-timeout="50" from "5" to "50".
        <subsystem xmlns="urn:jboss:domain:ejb3:1.4">
           
<session-bean>
               
<stateless>
                   
<bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
               
</stateless>
               
<stateful default-access-timeout="5000" cache-ref="simple"/>
               
<singleton default-access-timeout="5000"/>
           
</session-bean>
           
<pools>
               
<bean-instance-pools>
                   
<strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="50" instance-acquisition-timeout-unit="MINUTES"/>
                   
<strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="50" instance-acquisition-timeout-unit="MINUTES"/>
               
</bean-instance-pools>
           
</pools>

And in the following codepart I have set the "lockTimeInMillis" to a higher value
           <job-executor>
               
<thread-pool-name>
                    job-executor-tp
               
</thread-pool-name>
               
<job-acquisitions>
                   
<job-acquisition name="default">
                       
<acquisition-strategy>
                            SEQUENTIAL
                       
</acquisition-strategy>
                       
<properties>
                           
<property name="lockTimeInMillis">
                                3000000
                           
</property>
                           
<property name="waitTimeInMillis">
                                5000
                           
</property>
                           
<property name="maxJobsPerAcquisition">
                                3
                           
</property>
                       
</properties>
                   
</job-acquisition>
               
</job-acquisitions>
           
</job-executor>

Additionally I had to edit the calling methode in the Binding Class. This Binding class has been created automatically out of the WSDL. In my case it was the BasicHttpBinding_IOptionStoreStub class. There I searched for my methode upgradeProject and there I added _call.setTimeout(3600000) where all the different properties are set to the call.

This solved my problem, I tested it with calling a webservice which took 12 minutes and it worked fine.

Thanks everybody for the help!
Karl
Reply all
Reply to author
Forward
0 new messages