Book Image

Modernizing Oracle Tuxedo Applications with Python

By : Aivars Kalvans
Book Image

Modernizing Oracle Tuxedo Applications with Python

By: Aivars Kalvans

Overview of this book

Despite being developed in the 1980s, Oracle Tuxedo still runs a significant part of critical infrastructure and is not going away any time soon. Modernizing Oracle Tuxedo Applications with Python will help you get to grips with the most important Tuxedo concepts by writing Python code. The book starts with an introduction to Oracle Tuxedo and guides you in installing its latest version and Python bindings for Tuxedo on Linux. You'll then learn how to build your first server and client, configure Tuxedo, and start running an application. As you advance, you'll understand load balancing and work with the BBL server, which is at the heart of a Tuxedo application. This Tuxedo book will also cover Boolean expressions and different ways to export Tuxedo buffers for storage and transmission, before showing you how to implement servers and clients and use the management information base to change the configuration dynamically. Once you've learned how to configure Tuxedo for transactions and control them in application code, you'll discover how to use the store-and-forward functionality to reach destinations and use an Oracle database from a Tuxedo application. By the end of this Oracle Tuxedo book, you'll be able to perform common Tuxedo programming tasks with Python and integrate Tuxedo applications with other parts of modern infrastructure.
Table of Contents (18 chapters)
1
Section 1: The Basics
6
Section 2: The Good Bits
12
Section 3: Integrations

Installing Tuxedo and Python

Oracle provides Dockerfiles and commands to build Docker images for Oracle products on GitHub (https://github.com/oracle/docker-images). Tuxedo is no exception, although Oracle considers it old content and has moved into an archive location where it is available today. Therefore, we will create more up-to-date Docker images ourselves.

To install Tuxedo, you must first download it from the Oracle website (http://www.oracle.com/technetwork/middleware/tuxedo/downloads/index.html). You will have to create an account if you don't already have one. Tuxedo is available for different operating systems: AIX, Linux, HP-UX, Solaris, and Microsoft Windows. For all examples in this book, we will use the latest release of Oracle Tuxedo 12cR2 (12.2.2) and an installation package that includes all the required add-ons called "Oracle Tuxedo 12cR2 (12.2.2)" (including Tuxedo, SALT, and Jolt) for Linux x86-64 (64-bit). The downloaded file will be named tuxedo122200_64_Linux_01_x86.zip.

Create a new folder and put the downloaded tuxedo122200_64_Linux_01_x86.zip file there. You will need to create tuxedo1222.rsp and Dockerfile files in the same folder as the downloaded file.

We start with tuxedo1222.rsp, which contains answers for Oracle Tuxedo installer so that it can be installed in silent mode:

RESPONSEFILE_VERSION=2.2.1.0.0
FROM_LOCATION="/home/oracle/Disk1/stage/products.xml"
ORACLE_HOME="/home/oracle/tuxhome"
ORACLE_HOME_NAME="tuxhome"
INSTALL_TYPE="Custom Install"
DEPENDENCY_LIST={"tuxedoServer:12.2.2.0.0","atmiClient:12.2.2.0.0"}
TLISTEN_PASSWORD="oracle"

This is a minimized response file that contains only the required responses. Here are the most important things:

  • FROM_LOCATION gives the location of the unpacked ZIP file.
  • ORACLE_HOME and ORACLE_HOME_NAME say that Tuxedo will be installed under /home/oracle/tuxhome.
  • INSTALL_TYPE says we will install only selected components.
  • TOPLEVEL_COMPONENT and DEPENDENCY_LIST say that only the core Tuxedo should be installed.

Then we need a Dockerfile file that contains instructions for building a Docker image:

FROM oraclelinux:8
RUN yum -y install oracle-release-el8 && \
    yum -y install \
           libnsl java-devel gcc-c++ python3-devel \
           unzip file hostname which sudo && \
    rm -rf /var/cache/yum
RUN groupadd oracle && \
        useradd -m -g oracle -s /bin/bash oracle && \
        echo 'oracle ALL=(ALL) NOPASSWD:ALL' \
        >> /etc/sudoers.d/oracle
USER oracle
COPY tuxedo1222.rsp tuxedo122200_64_Linux_01_x86.zip /home/oracle/
ENV ORACLE_HOME=/home/oracle/tuxhome \
    JAVA_HOME=/etc/alternatives/java_sdk
RUN cd ~/ && \
      jar xf tuxedo122200_64_Linux_01_x86.zip && \
      cd ~/Disk1/install && \
      chmod -R +x * && \
      ./runInstaller.sh -responseFile ~/tuxedo1222.rsp \
            -silent -waitforcompletion && \
      rm -rf ~/Disk1 && \
      rm -f ~/tuxedo1222.rsp ~/tuxedo122200_64_Linux_01_x86.zip
ENV TUXDIR=/home/oracle/tuxhome/tuxedo12.2.2.0.0
ENV PATH=$PATH:$TUXDIR/bin
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TUXDIR/lib
USER root
RUN pip3 install tuxedo
USER oracle
WORKDIR /home/oracle

Once you have it, you can run the following command:

docker build -t tuxpy .

This command creates the Docker image. While it runs for several minutes, let's take a look at the most important steps:

  1. The Docker image will be created from Oracle Linux 8. Other Linux distributions may also be used, but the choice of Oracle Linux will come in handy when we start using the Oracle database.
  2. We run the yum package manager to install Python version 3, Java for running the Oracle Tuxedo installer, and the GCC compiler for building a Python module.
  3. We create a regular Linux user named oracle and give permissions to run sudo for installing other software packages.
  4. Once all the files are put into the container, the Tuxedo installation is unpacked.
  5. The Tuxedo installation is run in non-interactive mode with a response file containing all the necessary inputs. Tuxedo can also be installed using a graphical interface or console interface like all other Oracle products, which is handy if you don't use containers.
  6. We export the TUXDIR environment variable that points to the directory where Tuxedo is installed and set up program and library paths to include Tuxedo binaries.
  7. After that is done, the Python tuxedo module is installed using the pip3 tool.

After that, you can start the newly created image by using the following command:

docker run -ti --privileged tuxpy bash

If you are using Docker Desktop on Microsoft Windows, you may need to add winpty in front of the command:

winpty docker run -ti --privileged tuxpy bash

The --privileged parameter gives extended privileges to the container that will be needed in Chapter 3, Tuxedo in Detail to resize message queues.

If you have any preferences for a text editor or other tools, you can install them by using sudo yum install and the package name. As an exercise, take a look at the Python examples that use SCA under $TUXDIR/samples/sca/simp_python. It will make you appreciate the simplicity of your first Tuxedo application in Python, which we will create in the next chapter.