How to make external system callings without transaction

Hi team!
I’m new using Flowable and I want to call the external system through HTTP in the service task to obtain information.
But I learned that all the logic in the service task will be within a database transaction.In order to avoid occupying database connection for a long time due to no response of external system calls,I want to make the call without transaction.

Hey @memo
you can achive that by using asynchronous tasks. The engine commits the current transaction before the async task and handels the async task as a new one. This also avoids calling the same APIs multiple times in case of rollbacks.

Greetings

Christopher

Hi @WelschChristopher
Do you mean the following flowable setting?

flowable:async=“true”

I tried to set the service task as async,but the HTTP calling is still in the transaction.

Or do you mean to use asynchronous threads or message queues to call external systems?
If so,there is many inconvenient places here when i need to obtain data from serveral different systems and then deal with these data.

I wish to control the granularity of transaction within a service task (or other task) by myself which means i can exclude the calling from the transaction.Is there any other solution?

Hey @memo

flowable:async=“true”

is correct.

can you share your process?

I wish to control the granularity of transaction within a service task (or other task) by myself which means i can exclude the calling from the transaction.Is there any other solution?

that’s what I want to achive with the async flag.
If you have multiple service tasks like:
“one task → async task → other task” the executions are split into 2 transaction.
The first one with “one task” and the second one with “async task → other task”.

Hi @WelschChristopher
My demo process is contains of two service task by sequence.
I wish to make external calling within the service task execute method without transaction.But this execute method is wrapped by transaction.

Hey @Memo
I tried to reproduce your example and the transaction works as I described earlier.
Can you share the XML of your process? Be default the engine does not handle/react on the actual http response.
You need to set the failStatusCodes for each http task.

 <serviceTask id="failGet" name="HTTP Task" flowable:type="http">
      <extensionElements>
        <flowable:field name="requestMethod">
          <flowable:string><![CDATA[GET]]></flowable:string>
        </flowable:field>
        <flowable:field name="requestUrl">
          <flowable:string><![CDATA[http://localhost:9798/api/fail?code=400]]></flowable:string>
        </flowable:field>
        <flowable:field name="failStatusCodes">
          <flowable:string><![CDATA[4XX]]></flowable:string>
        </flowable:field>
      </extensionElements>
    </serviceTask>

It might looks like 1 transaction in your case, because flowable does not rollback the second transaction.

Greeting

Christopher

Maybe you can use events. If you expect your HTTP tasks to take too long, you can pause your process, call a java component that handles the HTTP call, and sends an event to resume processing.
Pausing the process will commit and close the transaction and resuming it by the event will start a new transaction. Your HTTP call will remain out of both.

You can use signal events for example: BPMN 2.0 Constructs · Flowable Open Source Documentation

1 Like