0

I’m trying to implement two-phase commit transactions using Narayana REST-AT fully embedded in a Spring Boot application—no WildFly/JBoss server, no Docker Compose or external broker, just project dependencies—and deploy it on OpenShift using the default embedded Tomcat.

My question is simple:

Can I use Narayana REST-AT directly in a Spring Boot project with the built-in Tomcat so that it:

Exposes internal REST endpoints for transaction management (/transactions, /prepare, /commit, /rollback), and

Allows methods annotated with @Transactional(RestAtomicTransaction.TYPE) to participate in a global two-phase commit?

1 Answer 1

0

Although your question is pleasantly succinct I can only give a lengthy but complete response.

The REST-AT transaction manager (aka coordinator) API is exposed using standard REST endpoints [1] and transaction participants must also expose an API using standard REST endpoints [2]. The protocol that defines the comms between these two REST endpoints follows the HTTP standards and are defined in [3a]. It is possible to expose those two endpoints in the same application just like any other REST based application can but from a reliability stance it is better to separate the participant from the transaction manager.

Even though the REST-AT and JTA transaction models are semantically identical the APIs and transport protocol are different and as such the two models need to be "bridged" to enable JTA style transactions to participate in a REST-AT transaction [3b]. This piece of the puzzle is only integrated in WildFly and therefore using `@Transactional(RestAtomicTransaction.TYPE)` to facilitate participation in a global two-phase commit requires the app server. If there is a call from the community to make the bridge a standalone component then that is certainly possible.

I've just realised as I write this that when you wrote `@Transactional` you may not have intended the question as being specific to only JTA - we do support annotations for the REST-AT transaction model [3c] but since we've not had questions about it I doubt they have had much exposure, if you are so inclined then any experimentation you can do would be welcome, if you continue a conversation on zulip (https://narayana.zulipchat.com/) we can discuss more about that if need be. We are wanting to address the use of annotations and lack of users by providing a quarkus extension [3d], the more developers that contribute to that issue thread the more likely that it's priority can be raised.

If you are using JAX-RS then you can embed the coordinator by running an embedded JAX-RS server such as undertow [4] and register the JAX-RS resource, Coordinator.class, corresponding to the REST-AT transaction manager [5]. You will also need register your participant to handle the prepare/rollback/commit endpoints [5]. The participant/coordinator interactions are handled by a JAXRS filter, ServerSRAFilter, [5]. ServerSRAFilter is a recent addition and has not been used in anger so, depending on your needs, you may prefer to handle participant/coordinator interactions yourself as we do in the test suite [6].

The testsuite shows how to do various things, such as starting a coordinator etc [7].

[1] https://www.narayana.io//docs/project/index.html#client_responsibilities

[2] https://www.narayana.io//docs/project/index.html#%5C_service_responsibilities

[3a] https://github.com/jbosstm/documentation/blob/main/rts/docs/REST-Atomic_v2_draft_8_comments_sept_4.pdf

[3b] https://www.narayana.io//docs/project/index.html#%5C_jta_bridge

[3c] https://www.narayana.io//docs/api/org/jboss/jbossts/star/annotation/package-summary.html

[3d] https://github.com/quarkusio/quarkus/issues/15364

[4] https://docs.jboss.org/resteasy/docs/3.1.4.Final/javadocs/org/jboss/resteasy/plugins/server/undertow/UndertowJaxrsServer.html

[5] https://github.com/jbosstm/narayana/blob/7.2.2.Final/rts/at/tx/src/test/java/org/jboss/jbossts/star/test/SRATest.java#L62

[6] https://github.com/jbosstm/narayana/blob/7.2.2.Final/rts/at/tx/src/test/java/org/jboss/jbossts/star/test/SpecTest.java

[7] https://github.com/jbosstm/narayana/blob/7.2.2.Final/rts/at/tx/src/test/java/org/jboss/jbossts/star/test/BaseTest.java#L198

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.