The first example

Figure 6.1. Deploy model of an example with two dummy resource managers

Deploy model of an example with two dummy resource managers

Copy file EXAMPLE1.cob in your working dir:

[Shell terminal session]
tiian@ubuntu1404-64:/tmp$ cp /opt/lixa/share/doc/lixa-X.Y.Z/examples/cobol/EXAMPLE1.cob .
	

Substitute lixa-X.Y.Z with the actual version of the software you installed.

Set up your shell environment:

[Shell terminal session]
tiian@ubuntu1404-64:/tmp$ export PATH=$PATH:/opt/lixa/bin
tiian@ubuntu1404-64:/tmp$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lixa/lib
tiian@ubuntu1404-64:/tmp$ export COB_LDFLAGS=-Wl,--no-as-needed
	

Compile and link the COBOL example program:

[Shell terminal session]
tiian@ubuntu1404-64:/tmp$ cobc -x $(lixa-config -f -l) EXAMPLE1.cob
	

Check the output of the linker:

[Shell terminal session]
tiian@ubuntu1404-64:/tmp$ ldd EXAMPLE1
	linux-vdso.so.1 =>  (0x00007fffbd9fe000)
	libcob.so.1 => /usr/lib/libcob.so.1 (0x00007fe904068000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe903d62000)
	libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fe903aed000)
	libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007fe9038ca000)
	libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fe9036a1000)
	libdb-5.3.so => /usr/lib/x86_64-linux-gnu/libdb-5.3.so (0x00007fe9032fe000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe9030fa000)
	liblixac.so.0 => /opt/lixa/lib/liblixac.so.0 (0x00007fe902edf000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe902b19000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe9028fb000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fe9042a6000)
	libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007fe9026f6000)
	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fe9023ee000)
	libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007fe902087000)
	liblixab.so.0 => /opt/lixa/lib/liblixab.so.0 (0x00007fe901e6d000)
	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe901c2f000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe901a16000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fe9017f3000)
	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fe9015ee000)

Now you are ready to start your first application:

[Shell terminal session]
tiian@ubuntu1404-64:/tmp$ ./EXAMPLE1 
Executing EXAMPLE1
TXOPEN returned value -000000007
Exiting...
	

The TXOPEN routine returned the value -7 (TX-FAIL) because the state server is not running. Start the state server (see the section called “Background (daemon) execution”) and try again:

[Shell terminal session (Ubuntu)]
tiian@ubuntu1404-64:~/tmp$ sudo su - lixa
lixa@ubuntu1404-64:~$ /opt/lixa/sbin/lixad --daemon
lixa@ubuntu1404-64:~$ exit
logout
tiian@ubuntu1404-64:~/tmp$ ps -ef|grep lixad|grep -v grep
lixa     12866     1  0 21:35 ?        00:00:00 /opt/lixa/sbin/lixad --daemon
tiian@ubuntu1404-64:/tmp$ ./EXAMPLE1 
Executing EXAMPLE1
TXOPEN returned value +000000000
TXBEGIN returned value +000000000
TXINFORM returned value +000000000
  XID-REC/FORMAT-ID:     +279875137
  XID-REC/GTRID-LENGTH:  +000000016
  XID-REC/BRANCH-LENGTH: +000000016
  XID-REC/XID (SERIAL.): 1279875137.9ce44ddff2274cd99924ae2721b66789.58f1d23a64e7f668c92c624bc096d075                                                                                                         
  TRANSACTION-MODE :     +000000001
    [TX-IN-TRAN]
  COMMIT-RETURN :        +000000000
    [TX-COMMIT-COMPLETED]
  TRANSACTION-CONTROL :  +000000000
    [TX-UNCHAINED]
  TRANSACTION-TIMEOUT :  +000000000
    [NO-TIMEOUT]
  TRANSACTION-STATE :    +000000000
    [TX-ACTIVE]
TXCOMMIT returned value +000000000
TXINFORM returned value +000000000
  XID-REC/FORMAT-ID:     -000000001
  XID-REC/GTRID-LENGTH:  +000000000
  XID-REC/BRANCH-LENGTH: +000000000
  XID-REC/XID (SERIAL.): -1..                                                                                                         
  TRANSACTION-MODE :     +000000000
    [TX-NOT-IN-TRAN]
  COMMIT-RETURN :        +000000000
    [TX-COMMIT-COMPLETED]
  TRANSACTION-CONTROL :  +000000000
    [TX-UNCHAINED]
  TRANSACTION-TIMEOUT :  +000000000
    [NO-TIMEOUT]
  TRANSACTION-STATE :    +000000000
    [TX-ACTIVE]
TXSETCOMMITRET returned value +000000001
TXSETTIMEOUT returned value +000000000
TXSETTRANCTL returned value +000000000
TXINFORM returned value +000000000
  XID-REC/FORMAT-ID:     -000000001
  XID-REC/GTRID-LENGTH:  +000000000
  XID-REC/BRANCH-LENGTH: +000000000
  XID-REC/XID (SERIAL.): -1..                                                                                                         
  TRANSACTION-MODE :     +000000000
    [TX-NOT-IN-TRAN]
  COMMIT-RETURN :        +000000000
    [TX-COMMIT-COMPLETED]
  TRANSACTION-CONTROL :  +000000001
    [TX-CHAINED]
  TRANSACTION-TIMEOUT :  +000000005
  TRANSACTION-STATE :    +000000000
    [TX-ACTIVE]
TXSETTRANCTL returned value +000000000
TXINFORM returned value +000000000
  XID-REC/FORMAT-ID:     -000000001
  XID-REC/GTRID-LENGTH:  +000000000
  XID-REC/BRANCH-LENGTH: +000000000
  XID-REC/XID (SERIAL.): -1..                                                                                                         
  TRANSACTION-MODE :     +000000000
    [TX-NOT-IN-TRAN]
  COMMIT-RETURN :        +000000000
    [TX-COMMIT-COMPLETED]
  TRANSACTION-CONTROL :  +000000000
    [TX-UNCHAINED]
  TRANSACTION-TIMEOUT :  +000000005
  TRANSACTION-STATE :    +000000000
    [TX-ACTIVE]
TXBEGIN returned value +000000000
TXROLLBACK returned value +000000000
TXCLOSE returned value +000000000
	

Your first COBOL Application Program has connected to the state server and has performed two dummy distributed transactions: commit and rollback.

Refer to the section called “Some details about the example” to get some further insights.