### Linux/UNIX Installation Output Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/general_procedures/operating_system_services.adoc Example output showing the registration of recovery and transaction services in system run-level directories. ```text Adding $JAVA_HOME (/opt/java) to $PATH in /opt/arjuna/ats-3.2/services/bin/solaris/recoverymanagerservice.sh Adding $JAVA_HOME (/opt/java) to $PATH in /opt/arjuna/ats-3.2/services/bin/solaris/transactionserverservice.sh Installing shutdown scripts into /etc/rcS.d: K01recoverymanagerservice K00transactionserverservice Installing shutdown scripts into /etc/rc0.d: K01recoverymanagerservice K00transactionserverservice Installing shutdown scripts into /etc/rc1.d: K01recoverymanagerservice K00transactionserverservice Installing shutdown scripts into /etc/rc2.d: K01recoverymanagerservice K00transactionserverservice Installing startup scripts into /etc/rc3.d: S98recoverymanagerservice S99transactionserverservice ``` -------------------------------- ### Start Application Server Management CLI Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/product/development_guide/tools.adoc Use this command to start the Management CLI on a non-Windows OS. Ensure you are in the application server's install directory. ```shell ./bin/jboss-cli.sh --connect controller=IP_ADDRESS ``` -------------------------------- ### Execute Linux/UNIX Service Installer Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/general_procedures/operating_system_services.adoc Run the installation script to configure start-up and shut-down scripts. ```shell ./install_service.sh ``` -------------------------------- ### Start Narayana Hello Client Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jts/trailmap.adoc Execute this command to start the Hello Client. Ensure the CLASSPATH is set correctly. ```shell java com.arjuna.demo.simple.HelloClient ``` -------------------------------- ### Start Narayana Hello Server Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jts/trailmap.adoc Execute this command to start the Hello Server. Ensure the CLASSPATH is set correctly. ```shell java com.arjuna.demo.simple.HelloServer ``` -------------------------------- ### Start EchoServer Source: https://github.com/jbosstm/narayana/blob/main/vertx/echo/README.md Command to start the EchoServer using the build script. Ensure Vert.x is in your PATH and dependencies are downloaded. ```bash ./build.sh EchoServer.java & ``` -------------------------------- ### Build and Run STM Vert.x Example Source: https://github.com/jbosstm/narayana/blob/main/vertx/shared/README.md Build the fat jar using Maven and run the example with specified properties. Ensure PROJECT_VERSION is set correctly. ```bash mvn clean package ``` ```bash PROJECT_VERSION= such as 5.4.1 java -jar target/stm-vertex-shared-${PROJECT_VERSION}.Final-SNAPSHOT-fat.jar -Dcom.arjuna.ats.arjuna.common.propertiesFile=jbossts-properties.xml ``` -------------------------------- ### Initialize and Destroy ORB and OA Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jts/trailmap.adoc Example of creating an ORB instance, getting the root POA, initializing the ORB and OA, performing work, and then destroying the OA and shutting down the ORB. Ensure proper exception handling. ```Java import com.arjuna.orbportability.ORB; import com.arjuna.orbportability.OA; public static void main(String[] args) { try { // Create an ORB instance ORB orb = ORB.getInstance("orb_test"); OA oa = OA.getRootOA( orb ); // Get the root POA orb.initORB(args, null); // Initialize the ORB oa.initOA(args); // Initialize the OA // Do Work oa.destroy(); // destroy the OA orb.shutdown(); // Shutdown the ORB } catch(Exception e) { } }; ``` -------------------------------- ### STM Vert.x Example Output Source: https://github.com/jbosstm/narayana/blob/main/vertx/shared/README.md Example output when running the STM Vert.x integration. Observe the initialization of transactional services and Verticles. ```text > Object name: 0:ffffc0a80011:d7f1:536e7c9b:0 > ARJUNA012163: Starting service com.arjuna.ats.arjuna.recovery.ActionStatusService on port 55282 > ARJUNA012337: TransactionStatusManagerItem host: 127.0.0.1 port: 55282 > ARJUNA012170: TransactionStatusManager started on port 55282 and host 127.0.0.1 with service com.arjuna.ats.arjuna.recovery.ActionStatusService > State value is: 11 > State value is: 12 > State value is: 13 > State value is: 14 > State value is: 15 > State value is: 16 > State value is: 17 > State value is: 18 > State value is: 19 > State value is: 20 > ClientVerticle initialised state: 20 > Succeeded in deploying verticle > SampleVerticle1 initialised state with: 21 > SampleVerticle1 SUCCEEDED! ``` -------------------------------- ### Start Banking Application Server Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jts/trailmap.adoc Command to start the banking application server using the JTS TXOJ demo. ```shell java com.arjuna.demo.jts.txojbank.BankServer ``` -------------------------------- ### ORB Portability API Example Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jts/trailmap.adoc Example demonstrating the usage of the ORB Portability API to initialize and manage an ORB and OA instance. ```APIDOC ## ORB Portability API Example ### Description This example illustrates how to use the ORB Portability API to create and initialize an ORB and its associated Object Adapter (OA). ### Method N/A (Illustrative Example) ### Endpoint N/A ### Request Example ```java import com.arjuna.orbportability.ORB; import com.arjuna.orbportability.OA; public static void main(String[] args) { try { // Create an ORB instance ORB orb = ORB.getInstance("orb_test"); OA oa = OA.getRootOA( orb ); // Get the root POA orb.initORB(args, null); // Initialize the ORB oa.initOA(args); // Initialize the OA // Do Work oa.destroy(); // destroy the OA orb.shutdown(); // Shutdown the ORB } catch(Exception e) { } }; ``` ### Response N/A (Illustrative Example) ``` -------------------------------- ### Start LogEditor for HornetQ Object Store Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/product/development_guide/tools.adoc Configure and start the LogEditor for HornetQ object stores by specifying the store directory and adaptor class. ```shell java -Dcom.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqJournalEnvironmentBean.storeDir="directory path" -Dcom.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.objectStoreType="com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqObjectStoreAdaptor" ``` -------------------------------- ### Start Banking Application Client Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jts/trailmap.adoc Command to start the banking application client in a separate window. ```shell java com.arjuna.demo.jts.txojbank.BankClient ``` -------------------------------- ### Start EchoClient Source: https://github.com/jbosstm/narayana/blob/main/vertx/echo/README.md Command to start the EchoClient. This will demonstrate transactional data modification. ```bash ./build.sh EchoClient.java ``` -------------------------------- ### Start the Recovery Manager Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/general_procedures/failure_recovery_administration.adoc Use this command to start the standalone Recovery Manager process. Ensure the JAR file is in the classpath. ```shell java com.arjuna.ats.arjuna.recovery.RecoveryManager ``` -------------------------------- ### Start Recovery Manager with Test Flag Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/general_procedures/failure_recovery_administration.adoc Starting the Recovery Manager with the -test flag will display a 'Ready' message upon initialization, useful for testing. ```shell java com.arjuna.ats.arjuna.recovery.RecoveryManager -test ``` -------------------------------- ### Recovery Manager Startup Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jts/trailmap.adoc Instructions on how to start the Narayana Recovery Manager process for crash recovery. ```APIDOC ## Recovery Manager Startup ### Description The Recovery Manager is a daemon process responsible for performing crash recovery for transactions. It scans the Object Store for failed transactions and re-activates them to ensure consistent results. ### Method N/A (Command Line) ### Endpoint N/A ### Command ```shell java com.arjuna.ats.arjuna.recovery.RecoveryManager ``` ### Description This command starts the Recovery Manager process. It will periodically scan the Object Store for transactions that may have failed and initiate recovery procedures. ``` -------------------------------- ### Transactional JDBC Example Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jta/examples.adoc Demonstrates basic usage of the transactional JDBC driver provided by the product. ```java include::{projectSourceDir}/jta/extras/jdbc_example.java[] ``` -------------------------------- ### Implement 2PC Participant prepare method Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/product/xts_guide/xts_api.adoc Example implementation of the prepare method for a 2PC participant. ```java include::{productSourceDir}/xts_guide/extras/example-prepare-method.java[] ``` -------------------------------- ### Transactional JDBC Driver Example Source: https://context7.com/jbosstm/narayana/llms.txt Shows how to use Narayana's transactional JDBC drivers to enlist database connections in JTA transactions. Ensure the correct driver prefix and properties are used for connection setup. ```java import com.arjuna.ats.jdbc.TransactionalDriver; import com.arjuna.ats.jta.UserTransaction; import java.sql.*; import java.util.Properties; public class JDBCTransactionExample { public static void main(String[] args) { Connection conn = null; Statement stmt = null; try { // Register the transactional JDBC driver Class.forName("com.arjuna.ats.jdbc.TransactionalDriver"); // Setup connection properties Properties dbProps = new Properties(); dbProps.put(TransactionalDriver.userName, "dbuser"); dbProps.put(TransactionalDriver.password, "dbpassword"); // For dynamic class instantiation (alternative to JNDI) dbProps.put(TransactionalDriver.dynamicClass, "com.arjuna.ats.internal.jdbc.drivers.PropertyFileDynamicClass"); // Connect using the transactional driver prefix "jdbc:arjuna:" // The driver wraps your actual JDBC connection for XA support conn = DriverManager.getConnection( "jdbc:arjuna:jdbc:postgresql://localhost:5432/mydb", dbProps); // Begin JTA transaction UserTransaction utx = com.arjuna.ats.jta.UserTransaction.userTransaction(); utx.begin(); // Create statement - automatically enlisted in transaction stmt = conn.createStatement(); // Execute transactional operations stmt.executeUpdate("INSERT INTO accounts (id, balance) VALUES (1, 1000)"); stmt.executeUpdate("INSERT INTO accounts (id, balance) VALUES (2, 500)"); // Transfer funds - atomic operation stmt.executeUpdate("UPDATE accounts SET balance = balance - 100 WHERE id = 1"); stmt.executeUpdate("UPDATE accounts SET balance = balance + 100 WHERE id = 2"); // Query within transaction sees uncommitted changes ResultSet rs = stmt.executeQuery("SELECT * FROM accounts"); while (rs.next()) { System.out.println("Account " + rs.getInt("id") + ": $" + rs.getInt("balance")); } // Commit - all database changes are made permanent atomically utx.commit(); } catch (Exception e) { try { // Rollback on error - all changes are undone com.arjuna.ats.jta.UserTransaction.userTransaction().rollback(); } catch (Exception ex) { ex.printStackTrace(); } e.printStackTrace(); } finally { try { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } } ``` -------------------------------- ### Account Creation Execution Output Source: https://github.com/jbosstm/narayana/blob/main/docs/src/main/asciidoc/project/jts/trailmap.adoc Example output showing the creation of a new account and the application of the one-phase commit optimization. ```shell Your choice : 1 - Create a new account - ------------------------ Name : Foo Initial balance : 1000 Beginning a User transaction to create account [ Connected to 192.168.0.2:4799 from local port 4924 ] Attempt to commit the account creation transaction /[ Resource for Foo : Commit one phase ] ``` -------------------------------- ### Configure Byteman Agent for Scripts Source: https://github.com/jbosstm/narayana/blob/main/XTS/localjunit/xtstest/README.md Configures the Byteman agent by supplying the relevant script file path as a command-line option to the JVM when starting the AS. `${BYTEMAN_HOME}` should point to the Byteman installation directory, and `${JBOSSTS_ROOT}` to the Narayana source tree root. ```bash export JAVA_OPTS="$JAVA_OPTS -javaagent:${BYTEMAN_HOME}/lib/byteman.jar=script:${JBOSSTS_ROOT}/XTS/trunk/sar/tests/dd/scripts/