Skip to content

Commit 2418c29

Browse files
committed
[#4765] fix node name to be harmonized with xa node name
1 parent a534b96 commit 2418c29

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

docs/src/main/asciidoc/transaction.adoc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,22 @@ include::duration-format-note.adoc[]
186186

187187
The default value is 60 seconds.
188188

189+
== Configuring transaction node name identifier
190+
191+
Narayana, as the underlaying transaction manager, has an concept of unique node identifier.
192+
This is important if you consider to use XA transactions with involve multiple resources.
193+
194+
The node name identifier plays a crucial part in the identification of a transaction.
195+
The node name identifier is forged into the transaction id when the transaction is created.
196+
Based on the node name identifier the transaction manager is capable to recognized the XA tranaction
197+
counterparts created in database or JMS broker. The identifier makes possible for the transaction manager
198+
to roll-back the transaction counterparts during recovery.
199+
200+
The node name identifier needs to be unique per transaction manager deployment.
201+
And the node identifier needs to be stable over the transaction manager restarts.
202+
203+
The node name identifier may be configured via the property `quarkus.transaction-manager.node-name`.
204+
189205
== Why always having a transaction manager?
190206

191207
Does it work everywhere I want to?::
@@ -225,4 +241,3 @@ It's not a mess in Quarkus :)
225241
Resource-level was introduced to support JPA in a non managed environment.
226242
But Quarkus is both lean and a managed environment so we can safely always assume we are in JTA mode.
227243
The end result is that the difficulties of running Hibernate ORM + CDI + a transaction manager in Java SE mode are solved by Quarkus.
228-

extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/NarayanaJtaRecorder.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package io.quarkus.narayana.jta.runtime;
22

33
import java.lang.reflect.Field;
4+
import java.util.Collections;
45
import java.util.Properties;
56

67
import org.jboss.logging.Logger;
78

89
import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
910
import com.arjuna.ats.arjuna.common.arjPropertyManager;
1011
import com.arjuna.ats.arjuna.coordinator.TxControl;
12+
import com.arjuna.ats.jta.common.jtaPropertyManager;
1113
import com.arjuna.common.util.propertyservice.PropertiesFactory;
1214

1315
import io.quarkus.runtime.annotations.Recorder;
@@ -23,7 +25,8 @@ public void setNodeName(final TransactionManagerConfiguration transactions) {
2325

2426
try {
2527
arjPropertyManager.getCoreEnvironmentBean().setNodeIdentifier(transactions.nodeName);
26-
TxControl.setXANodeName(transactions.xaNodeName.orElse(transactions.nodeName));
28+
jtaPropertyManager.getJTAEnvironmentBean().setXaRecoveryNodes(Collections.singletonList(transactions.nodeName));
29+
TxControl.setXANodeName(transactions.nodeName);
2730
} catch (CoreEnvironmentBeanException e) {
2831
e.printStackTrace();
2932
}
@@ -46,6 +49,7 @@ public void setDefaultProperties(Properties properties) {
4649

4750
public void setDefaultTimeout(TransactionManagerConfiguration transactions) {
4851
transactions.defaultTransactionTimeout.ifPresent(defaultTimeout -> {
52+
arjPropertyManager.getCoordinatorEnvironmentBean().setDefaultTimeout((int) defaultTimeout.getSeconds());
4953
TxControl.setDefaultTimeout((int) defaultTimeout.getSeconds());
5054
});
5155
}

extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/TransactionManagerConfiguration.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ public final class TransactionManagerConfiguration {
1818
@ConfigItem(defaultValue = "quarkus")
1919
public String nodeName;
2020

21-
/**
22-
* The XA node name used by the transaction manager
23-
*/
24-
@ConfigItem()
25-
public Optional<String> xaNodeName;
26-
2721
/**
2822
* The default transaction timeout
2923
*/

0 commit comments

Comments
 (0)