Modernizing Oracle Tuxedo Applications with Python - Aivars Kalvans - E-Book

Modernizing Oracle Tuxedo Applications with Python E-Book

Aivars Kalvans

0,0
39,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

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.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 204

Veröffentlichungsjahr: 2021

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Modernizing Oracle Tuxedo Applications with Python

A practical guide to using Oracle Tuxedo in the 21st century

Aivars Kalvāns

BIRMINGHAM—MUMBAI

Modernizing Oracle Tuxedo Applications with Python

Copyright © 2021 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Aaron Lazar

Publishing Product Manager: Denim Pinto

Senior Editor: Rohit Singh

Content Development Editor: Tiksha Lad

Technical Editor: Rashmi Subhash Choudhari

Copy Editor: Safis Editing

Project Coordinator: Deeksha Thakkar

Proofreader: Safis Editing

Indexer: Rekha Nair

Production Designer: Prashant Ghare

First published: March 2021

Production reference: 1190321

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-80107-058-4

www.packt.com

Contributors

About the author

Aivars Kalvāns is a developer, software architect, and consultant. He has been using Oracle Tuxedo (formerly BEA Tuxedo) since version 8 in 2003 to develop the Tieto Card Suite payment card system using the C++, Python, and Java programming languages. During his almost 19-year career at Tieto, Aivars has been involved in many projects related to payment card issuing, acquiring, and utility payments through mobile phones, ATMs, and POS terminals.

I want to thank my lovely wife, Anete, and sons, Kārlis, Gustavs, and Leo, for making life much more interesting.

About the reviewer

Klāvs Dišlers is a software developer at Moon Inc. He has over 8 years of experience in maintaining and improving Oracle Tuxedo and Python-based parts of the Tieto Card Suite payment system. During his career, he has mainly focused on developing libraries and automated testing tools to improve the day-to-day tasks of his coworkers and clients.

I would like to thank my wonderful wife, Kristīne; my precious daughter, Marija; and my curious son, Valters, for making my life meaningful.

Table of Contents

Preface

Section 1: The Basics

Chapter 1: Introduction and Installing Tuxedo

Technical requirements

Introducing Tuxedo

A Unix-inspired application server

Understanding Tuxedo through modern lens

Availability

Performance

Services

Polyglot development

Transactions

XATMI

Tuxedo today

Reviewing the need for Python

Installing Tuxedo and Python

Summary

Questions

Further reading

Chapter 2: Building Your First Tuxedo Application

Technical requirements

Creating a server

Creating a client

Creating a configuration file for Tuxedo

RESOURCES section

MACHINES section

GROUPS section

SERVERS section

TUXCONFIG

Starting the application

Administering the application

Stopping the application

Summary

Questions

Further reading

Chapter 3: Tuxedo in Detail

Technical requirements

Learning what BBL is

Understanding queues

Configuring queues

Introducing services and load balancing

Exploring the MSSQ configuration

Exploring the SSSQ configuration

Summary

Questions

Further reading

Chapter 4: Understanding Typed Buffers

Technical requirements

Introducing typed buffers

Using STRING typed buffers

Using CARRAY typed buffers

Using FML32 typed buffers

Using FML32 in Python

Working with field identifiers

Defining fields

Displaying FML32 typed buffers

Writing FML32 expressions

Importing and exporting typed buffers

Summary

Questions

Further reading

Section 2: The Good Bits

Chapter 5: Developing Servers and Clients

Technical requirements

Writing to ULOG

Understanding server lifetime

Understanding the advertising of services

Receiving inputs in a service

Returning outputs from a service

Optimizing tpreturn

Understanding client lifetime

Calling a service

Joining the application

Summary

Questions

Further reading

Chapter 6: Administering the Application Using MIBs

Technical requirements

Introducing MIB

Developing multiple versions of an application

Using tpadmcall to create TUXCONFIG

Upgrading the servers

Reconfiguring the application

Monitoring the application

Monitoring queues

Summary

Questions

Further reading

Chapter 7: Distributed Transactions

Technical requirements

Configuring Tuxedo for transactions

Managing transactions

Understanding timeouts

Blocking timeouts

Summary

Questions

Further reading

Chapter 8: Using Tuxedo Message Queue

Technical requirements

Creating and configuring queues

Using queues

Forwarding messages

Summary

Questions

Further reading

Chapter 9: Working with Oracle Database

Technical requirements

Preparing the database

Using local transactions with Oracle Database

Using global transactions with Oracle Database

Multi-threading and global transactions

Summary

Questions

Further reading

Section 3: Integrations

Chapter 10: Accessing the Tuxedo Application

Technical requirements

Using the Tuxedo Workstation client

Configuring Workstation Listener

Exposing Tuxedo services as web services

Summary

Questions

Further reading

Chapter 11: Consuming External Services in Tuxedo

Technical requirements

Consuming services

Adding fault tolerance for external services

Handling stateful protocols

Summary

Questions

Chapter 12: Modernizing the Tuxedo Applications

Technical requirements

Introducing NATS

Developing a basic NATS application

Developing a bi-directional gateway

Summary

Questions

Further reading

Assessments

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Why subscribe?

Other Books You May Enjoy

Section 1: The Basics

In this section, we will introduce Tuxedo and get a development environment ready for the rest of the book. We will cover the Tuxedo client-server architecture and messages sent between clients and servers in depth from both the Tuxedo and UNIX sides.

This section has the following chapters:

Chapter 1, Introduction and Installing TuxedoChapter 2, Building Our First Tuxedo ApplicationChapter 3, Tuxedo in DetailChapter 4, Understanding Typed Buffers

Chapter 1: Introduction and Installing Tuxedo

In this chapter, we will introduce Tuxedo and learn why it is still relevant and in use even today. I will try to convince you that the Python programming language is a good choice when it comes to writing, extending, and improving Tuxedo applications. And finally, we will create a development environment for learning Tuxedo development using Python.

We will cover the following topics in this chapter:

Introducing TuxedoUnderstanding Tuxedo through modern lensReviewing the need for PythonInstalling Tuxedo and Python

By the end of this chapter, you will have a good understanding of Tuxedo and have your environment set up for building your own applications.

Technical requirements

To follow the instructions in this chapter, you will require the following:

Docker for Linux, or Docker Desktop for Windows 10A 64-bit processorAt least 3 GB of free disk spaceAt least 4 GB of RAM, but 8 GB is strongly recommended

You can find the code files for this chapter on GitHub at https://github.com/PacktPublishing/Modernizing-Oracle-Tuxedo-Applications-with-Python/tree/main/Chapter01. The Code in Action video for the chapter can be found at https://bit.ly/3rWX4Gh.

Introducing Tuxedo

Tuxedo started in the year 1983 at AT&T as a framework for building high-performance, distributed business applications. It has its roots in the DUX (Database for Unix) and TUX (Transactions for Unix) projects, which were combined into a client-server communication framework with support for transactions under the name TUXEDO. Tuxedo stands for Transactions for Unix, Extended for Distributed Operations.

Tuxedo evolved from a client-server framework of release 1.0 to support high availability in release 2.0, and then to distributed and heterogeneous system support in releases 3.0 and 4.0. By release 6.1 and the year 1995, Tuxedo had reached maturity. A book entitled The TUXEDO System was published and it described Tuxedo as we know it today. Tuxedo continued to improve and advance over the later years and gained additional features until the most recent release, 12.2.2, but the core of it is pretty close to what it was in 1995.

Some of the innovations made by the engineers of Tuxedo became standardized; most notably, the XA interface is still implemented by databases and used for distributed transactions even in modern Java applications. Less known is the XATMI standard describing the core Tuxedo API. You may be familiar with the XA and XATMI specifications from X/Open Company, but not many people know that the inspiration came from Tuxedo.

Another fun fact is that Tuxedo enabled Service-Oriented Architecture (SOA) before the term was coined, and it enabled us to write microservices and even transactional microservices before the microservice architectural style became popular. Of course, a framework that is more than three decades old does not fit modern ideas when it comes to application servers, middlewares, microservice frameworks, and so on, but if you take a step back, you will see similarities.

A Unix-inspired application server

Tuxedo is an application server for the C and COBOL programming languages. Application servers, as we know them today for other programming languages, are typically a single process with multiple threads. That leads to isolation problems when multiple applications are running in the same application server. Some languages ignore that, while others try to minimize it by using different class loaders and other techniques. But still, all applications use the same heap memory. A single misbehaving application will affect other applications either by consuming all CPU resources or consuming too much memory.

Tuxedo follows the original Unix philosophy of having many (small) processes that communicate with each other. Such a process is called a server and a Tuxedo application consists of many servers. Another kind of process is a client, which accesses facilities provided by the server but does not provide facilities itself. Unix processes give memory isolation out of the box for Tuxedo applications: memory corruption by one server will not affect others. Processes are also scheduled by the operating system to give each of them a fair share of CPU time. A process can be assigned a priority or be run under different user accounts.

Communication between clients and servers is done using Unix System V ("System Five") inter-process communication (IPC) mechanisms: message queues, shared memory segments, and semaphores. Distributed computing is added transparently on top of that by forwarding messages from queues over the TCP/IP network to a different machine. All Tuxedo applications are distributed applications by design: communication is done by passing messages; a receiver may fail before or after processing the message; the sender may fail before receiving the response. The possibility of failure is exposed in the API.

After getting an idea of what Tuxedo is, let's learn more about it in detail in the next section.

Understanding Tuxedo through modern lens

In this section, we will look at various aspects of Tuxedo through a modern lens. We cannot cover all of them, but I believe each sections covers an aspect that is still relevant today.

Availability

If a Tuxedo server process crashes, it will get restarted. Multiple copies of the same executable may be run at the same time for redundancy. Multiple machines may be used to improve availability when one of them crashes. Tuxedo will load balance requests between the processes and machines that are up and running to minimize response time.

All Tuxedo applications have an administrative process that looks for servers that are stuck or have crashed and restarts them.

It is also possible to reconfigure a Tuxedo application without downtime. Adding more servers, and changing and reconfiguring existing ones – it can all be done while the application is running. Also, new versions of the software can be deployed without interrupting business processes.

Performance

The Tuxedo framework itself is fast and requires few resources. The performance cost on top of your application code will be very low.

This is partially because of the IPC queues used for the communication mechanism. The roundtrip latency, that is, sending a request and receiving a response, is less than 40 microseconds. Yes, that is 0.000040 seconds for a service call between two processes on the same machine.

The other reason for such performance is at-most-once delivery semantics, also known as fire-and-forget. It provides no message delivery guarantees and the sender is responsible for retrying the request and coming up with a way for a receiver to filter duplicate requests. If that sounds scary at first, this approach is similar to the UDP protocol, which offers better performance compared to TCP/IP. The application can be made reliable by using reliable queues or other mechanisms.

Oracle Tuxedo, along with Oracle Database, was used in transaction processing the TPC-C benchmark to achieve more than 500,000 transactions/second (http://www.tpc.org/tpcc/results/tpcc_results5.asp). Hundreds and thousands of business transactions per second are processed by Tuxedo running on smaller servers and laptops. To give you some perspective, Bitcoin is limited to around 7 transactions per second.

Services

Tuxedo is a message-oriented middleware. It works by sending and receiving messages through IPC queues. However, a typical Tuxedo API does not mention IPC queues as other message-oriented middlewares do. Tuxedo has an abstraction on top of the queues called a service. Each Tuxedo server implements one or more services. A service may be backed by a single queue or by multiple queues, or multiple services may share the same queue. All of that is transparent to the application code. A service might even be running on a different machine, but that is a concern for the administrator configuring the application, not the developer.

What about microservices or macroservices? Tuxedo is neutral in this regard: you are free to implement one big monolith service or many smaller ones, each using a different storage functionality and implementation language. It is a design choice, not a technical decision. When you do implement your application as many smaller services, Tuxedo will help you to make them transactional if you want to.

Polyglot development

Tuxedo natively supports the C and COBOL programming languages and Tuxedo's development tools produce output in one of those languages.

Since you can write C-like code in C++, you can use C++ to develop Tuxedo applications as long as you take care of exception propagation and typecasting, and avoid some pitfalls. Tuxedo comes with support for writing Java code; however, your Java code will look more like C code than idiomatic and modern Java. Other languages, such as PHP, Python, and Ruby, are supported through a technology called Service Component Architecture (SCA).

Transactions

Distributed transactions, or XA transactions, have a bad name these days, but I blame this on poor implementation in application servers. In Tuxedo, they work like a charm. You should design your application to avoid the need for distributed transactions, but when you need the consistency and are tempted to implement a solution with compensating transactions, just let Tuxedo do its work.

XATMI

X/Open ATMI (XATMI) stands for the Application to Transaction Monitor Interface and was based on existing Tuxedo API calls. It introduces typed buffers, which are used to exchange messages between parts of the application with the API to allocate, inspect, and release them. It also describes what a service is and how it is implemented. Finally, it specifies APIs for different messaging patterns: synchronous and asynchronous calls and conversational paradigms.

However, this standard captured what Tuxedo was capable of at some point in time. Tuxedo has since gained new APIs and supports typed buffers with more features and is better suited for complex applications. Think of XATMI as the SQL standard for databases: while the API is standardized, there are plenty of behavior differences not covered by the standard, and Tuxedo's XATMI will always be one of a kind.

Tuxedo today

Tuxedo became a product of the Oracle Corporation in 2008 and is now a part of Oracle Fusion Middleware, with the latest stable release being 12.2.2 in 2016. Tuxedo is a commercial, closed source product. With the current trend of relying on open source software, we will not see Tuxedo gaining huge popularity and acceptance. Most likely, it will not be used to develop new applications unless you use it already in your organization.

However, Tuxedo applications run a significant part of critical infrastructure in banking, telecommunications, payments, and many others. Just like COBOL, it is not going to disappear in the next few years; Tuxedo is here to stay for years to come. Those applications have to be maintained and enhanced and learning about Tuxedo might be a future job for you.

With detailed knowledge of Tuxedo, we are now ready to move on to the next section, where we will try to justify the use of the Python programming language.

Reviewing the need for Python

As I am writing this book, Python is the third most popular language according to the TIOBE Programming Community index. Given current trends, it may surpass Java and secure second place by the time this book is published. The only other language more popular than Python and Java is C.