Summary of "transaction" (or "job") processing:
- Client request doesn't wait for processing to be completed before getting response. Processing of request is queued/delayed, and can be looked up by client later.
- Client submits a "transaction id" when making the request. Client can use this "transaction id" to look up the status of the request processing, and get its result when completed.
- At cost of adding delay to getting an individual request response, transaction processing will increase the number of requests that Akula can handle simultaneously.
- Acts as a guarantee that the request was only processed once (or wasn't processed as at all), and allows response to be picked up later if mobile connectivity is lost during processing.
- Transaction processing is nicely distributed across a cluster environment (Akula1 takes request, Akula2 processes request, Akula3 serves result to client).
The transaction process is shown in the figure below:
The table below describes the transaction lifecycle:
|Description||Transaction record has been created and is available for use.||Request to endpoint with transaction ID was received. Request serialized to DB and JMS msg added.||Worker thread picked up JMS message and marks record as processing. Request is deserialized from DB and route is invoked.||Route has completed, and response is serialized to DB. Result is ready for pickup.|
|Msg in JMS Queue?||No||Yes||No||No|
|Request in DB?||No||Yes||Yes||Yes|
|Response in DB?||No||No||No||Yes|
The code example below shows how the transactional behavior of an endpoint may be configured:
Before a transaction can be created, it is necessary to define the number of "Worker Threads" used for the transaction process, as well as their ramp-up and scale-down behavior. One way to do this is to use app-properties (which are already manageable). However, an enhancement must be added to allow server-only app-properties to be overridden, as shown in the example below:
Creating a new queue for transaction processing:
Configuring the listener in Java Spring: