txnd - Transaction server Manual
txnd -- txnd is a distributed* "Transaction Server" helps in invoking any of the business objects, irrespective of their location. Business objects can be any method in a 'C' program or it can be a method of a C++ object. Business objects are registered into the transaction server (txnd) through a configuration file*. The client codes the business object, converts it as a shared object and registers it in the configuration file used by the transaction server (txnd).
The clients that wishes to use this service requests the server for the invocation of the business object.The server using a configuration file, locates the existence of the business object and invokes the requested method in the business object.
txnd ( the transaction server) is written in C++. This can run on any platform (thought currently it runs only in Linux). 'txnd' is a simple, yet powerful transaction server that aids in the transaction processing.
Please send in your valuable comments and suggestions to
sguruprasanna@yahoo.com / sabari@nucleussoftware.com For any clarifications, or to know more about this project, please feel free to mail us to the above mentioned email ids. Please bear with us for the features mentioned under development.
- Starting txnd
- Extract the file txnd-0.1.tar.gz.
- Run the script starttxnd. This will start txnd in background. 'txnd' server writes log messages in the file txnd.log available in the txnd-0.1 directory.
- Coding the Business object
The business object could be a 'C' program or a C++ class. In case if it is a 'C' program, it has to be converted into a .so file.
In case of a business object being a 'C++' class, the source file containg the class should contain appropriate methods declared with external linkage (i.e using extern 'C'), which in turn will call the member functions of the bsuiness object class. For example, let us say, the business object class is CBusinessObject as shown below:
class CBusinessObject
{
- private
private members;
- public
void method1(){} void method2(){} ... ... ... };
extern 'C'
{
void methodToCallMethod1() // this calls the method1 of BusinessObject class
//internally
{
CBusinessObject businessObject;
...
...
...
businessObject.method1();
...
...
...
}
void methodToCallMethod2AndMethod3() // this calls the method1 and method2 of
//BusinessObject class internally
{
CBusinessObject businessObject;
...
...
...
businessObject.method1();
...
...
...
businessObject.method2();
}
}
The above class has to be converted into a shared object.
3. Calling a business object method
This requires a client program to connect to the server(txnd) and send a message requesting the invocation of the business object. The message to be sent should be of the form
ApplicationName= <name of the .so file without extension> ~MethodName= <name of the method to be called> ~
Eg. ApplicationName=businessobject~MethodName=method1~
In order to do this, the client program can use the TCPClient class supplied along with the txnd source. All the client program needs to do is,
- include the file tcpclient.h
- link the client program against "libtcpclient.so" file (using -l and -L option of 'ld'), which comes along with txnd
The TCPClient class contains the following methods
- TCPClient(const char *IPADDRESS, int PORT) where IPADDRESS is the ipaddress where txnd is running and PORT is where txnd is listening to.
- int readString(char *stringRead, int numberOfCharactersToBeRead);
reads specified number of characters into 'stringRead'
- int writeString(char *stringToWrite, int numberOfCharactersToWrite);
writes the specified number of characters from 'stringToWrite'
- int closeClientSocket();
Closes the opened client socket
NOTE: These API's throw exception of type "const char *" in case of errors.
* feature yet to be implemented.
