In this tutorial we're going to walk through creating an RPC listener job for the iSeries, and a sample job to access the listener job from any PC.

Why Create an RPC Listener?

For years I was dissatisfied with the performance of ODBC queries to the AS/400 (sorry, "iSeries"!).
The problem with ODBC was that it wasn't loaded into the iSeries' memory until a request was made, so critical time was lost on virtually every query while the listener started up and allocated memory. As you're probably aware, the iSeries strength was not in providing "real-time" performance for what it treated as batch programs. It always reserved that little egg of performance kick to interactive applications.

I could have probably written this in Java, but frankly it's not my favourite language, and believe it or not Java has it's own performance issues on the iSeries, even with it being integrated into the Websphere licensed program.

When all was said and done, the Python listener you see here provided magnitudes faster queries for the iSeries than ODBC.
Okay, I don't have any hard data to back this up, and ODBC does improve once it's loaded into memory after the first query, but it still never beats this listener program. My guestimate is that the improvement is a minimum of 5 times faster, but I've clocked it faster than that.

(In fact it's significantly faster than some other commercial listener applications I've seen!)

What's Required?

Just Python running on the iSeries, and you can use any language for the remote client, but in this case I'm using Python running on Windows.

Getting Started

Create a new Python module on the iSeries' IFS (or on Windows, and just FTP it over later) and call it "RPCserverASCII.py". Why the "ASCII"? Because this module will be specifically designed to listen for requests from non-EBCDIC machines. You may have guessed that there's also an RPCserverEBCDIC.py module that does the same thing...

With the module opened, your first few lines are going to be the various import statements:

(Loading script via AJAX...)

Most of these are fairly obvious. You may have guessed we're actually using the "chat" module built into Python for this app. Why? It's easy, it's fast, it's low-level enough for high performance and high level enough that we're not bit-twiddling and writing exotic end-of-stream checking routines.

The "traceback" module is our insurance plan...when something goes wrong, we're going to make a detailed record. Always handy, especially when you get to the point (like I have) where this app becomes heavily used, and more and more critical, in the enterprise.

Next let's assign some global variables:

(Loading script via AJAX...)

Next page we'll look at the RPC class module itself that does all the heavy lifting...on to page 2....