Remoting allows your transactions to span several microservices, so rollback and commit are done across JVMs.
Bind the endpoint
In your favourite JAX-RS stack: configure an instance of
com.atomikos.remoting.twopc.AtomikosRestPort:
- Export it on some URL, say BASE_URL
- The endpoint will then be listening on BASE_URL/atomikos
Test the endpoint
Just load the address
BASE_URL/atomikos in your browser.
You should see the following:
Hello from Atomikos!
Set the URL in your jta.properties
Now set property:
com.atomikos.icatch.rest_port_url to the URL above. In other words: each service should include its own AtomikosRestPort URL in the startup properties. Your safest choice is the IP address, not the DNS name - so you avoid the need for a load balancer with session affinity.
IMPORTANT: If you don't set this property then our TransactionAwareRestContainerFilter will try to guess it. This will work in simple cases, but in general requires sticky sessions to make 2-phase commit work. So in that case you will need a load balancer that offers sticky session behaviour. Otherwise you may get errors like this: "Prepare failed because one or more resources refused to commit.". The same can happen if you set a DNS name rather than an IP address.