由于TUXEDO作为中间件时,没有自带可以直接启动的应用例子,而在测试时,如果需要应用实例则需要手工编译TUXEDO所带源码。
Server
建立测试应用目录,本例将Server应用存放于/opt/bea/app/simpapp目录中,将TUXEDO安装目录内samples/atmi/simpapp中文件复制到/opt/bea/app/simpapp目录中。
复制TUXEDO安装目录中tux.env 到/opt/bea/app/simpapp目录中,并更改相关内容,本例如下:
-bash-3.00# more tux.env
TUXDIR=/opt/bea/tuxedo10.0; export TUXDIR
JAVA_HOME=$TUXDIR/jre; export JAVA_HOME
JVMLIBS=$JAVA_HOME/jre/lib/sparcv9/server:$JAVA_HOME/jre/bin
PATH=/usr/5bin:/opt/gcc/bin:$TUXDIR/bin:$JAVA_HOME/bin:$PATH; export PATH
COBCPY=:$TUXDIR/cobinclude; export COBCPY
COBOPT="-C ANS85 -C ALIGN=8 -C NOIBMCOMP -C TRUNC=ANSI -C OSEXT=cbl"; export COBOPT
SHLIB_PATH=$TUXDIR/lib:$JVMLIBS:$SHLIB_PATH; export SHLIB_PATH
LIBPATH=$TUXDIR/lib:$JVMLIBS:$LIBPATH; export LIBPATH
LD_LIBRARY_PATH=$TUXDIR/lib:$JVMLIBS:$LD_LIBRARY_PATH:/opt/gcc/lib; export LD_LIBRARY_PATH
WEBJAVADIR=$TUXDIR/udataobj/webgui/java; export WEBJAVADIR
TUXCONFIG=/opt/bea/app/simpapp/tuxconfig; export TUXCONFIG
APPDIR=/opt/bea/app/simpapp; export APPDIR
-bash-3.00# pwd
/opt/bea/app/simpapp
-bash-3.00#
其中TUXDIR即为TUXEDO安装目录。
修改例子中的ubbsimple文件,本例中将其复制为ubb文件,然后对ubb文件进行编辑
-bash-3.00# more ubb
#(c) 2003 BEA Systems, Inc. All Rights Reserved.
#ident"@(#) samples/atmi/simpapp/ubbsimple$Revision: 1.5 $"
#Skeleton UBBCONFIG file for the TUXEDO Simple Application.
#Replace the <bracketed> items with the appropriate values.
*RESOURCES
IPCKEY123456
#Example:
#IPCKEY123456
DOMAINIDsimpapp
MASTERitsm001
MAXACCESSERS10
MAXSERVERS5
MAXSERVICES10
MODELSHM
LDBALN
*MACHINES
DEFAULT:
APPDIR="/opt/bea/app/simpapp"
TUXCONFIG="/opt/bea/app/simpapp/tuxconfig"
TUXDIR="/opt/bea/tuxedo10.0"
MAXWSCLIENTS = 150
MAXACCESSERS = 400
#Example:
#APPDIR="/home/me/simpapp"
#TUXCONFIG="/home/me/simpapp/tuxconfig"
#TUXDIR="/usr/tuxedo"
itsm001LMID=itsm001
#Example:
#beatuxLMID=simple
*GROUPS
GROUP1
LMID=itsm001GRPNO=1 OPENINFO=NONE
*SERVERS
DEFAULT:
CLOPT="-A"
simpservSRVGRP=GROUP1 SRVID=1
WSLSRVGRP=GROUP1 SRVID=20 CLOPT="-A-- -n //192.168.0.8:7200-m 10 -M 20 -x 6"
*SERVICES
TOUPPER
-bash-3.00#
其中主机名为”itsm001”,IP地址为”192.168.0.,8”,WSL侦听端口为7200(该端口即为Sitescope中联接时使用端口)
根据文本ubb文件生成二进制配置文件:TUXCONFIG="/opt/bea/app/simpapp/tuxconfig"
-bash-3.00# tmloadcfubb
Really overwrite TUXCONFIG file: /opt/bea/app/simpapp/tuxconfig [y, q] ? y
-bash-3.00#
按照系统提示输入”Y”确认生成tuxconfig文件。
编译Server 应用,simpserv.c内容如下:
bash-2.05# more simpserv.c
/*(c) 2003 BEA Systems, Inc. All Rights Reserved. */
/*Copyright (c) 1997 BEA Systems, Inc.
All rights reserved
THIS IS UNPUBLISHED PROPRIETARY
SOURCE CODE OF BEA Systems, Inc.
The copyright notice above does not
evidence any actual or intended
publication of such source code.
*/
/* #ident"@(#) samples/atmi/simpapp/simpserv.c$Revision: 1.5 $" */
#include <stdio.h>
#include <ctype.h>
#include <atmi.h>/* TUXEDO Header File */
#include <userlog.h>/* TUXEDO Header File */
/* tpsvrinit is executed when a server is booted, before it begins
processing requests.It is not necessary to have this function.
Also available is tpsvrdone (not used in this example), which is
called at server shutdown time.
*/
#if defined(__STDC__) defined(__cplusplus)
tpsvrinit(int argc, char *argv[])
#else
tpsvrinit(argc, argv)
int argc;
char **argv;
#endif
{
/* Some compilers warn if argc and argv aren't used. */
argc = argc;
argv = argv;
/* userlog writes to the central TUXEDO message log */
userlog("Welcome to the simple server");
return(0);
}
/* This function performs the actual service requested by the client.
Its argument is a structure containing among other things a pointer
to the data buffer, and the length of the data buffer.
*/
#ifdef __cplusplus
extern "C"
#endif
void
#if defined(__STDC__) defined(__cplusplus)
TOUPPER(TPSVCINFO *rqst)
#else
TOUPPER(rqst)
TPSVCINFO *rqst;
#endif
{
int i;
for(i = 0; i < rqst->len-1; i++)
rqst->data[i] = toupper(rqst->data[i]);
/* Return the transformed buffer to the requestor. */
tpreturn(TPSUCCESS, 0, rqst->data, 0L, 0);
}
bash-2.05#
bash-2.05# buildserver-o simpserv -f simpserv -s TOUPPER
如果没有异常则会生成simpserv二进制应用文件
注意:本步要求在应用主机上安装C编辑器,本例编辑环境如下:
bash-2.05$ type cc
cc is /usr/bin/cc
bash-2.05$ ls -l /usr/bin/cc
lrwxrwxrwx1 rootother16 Sep 19 10:17 /usr/bin/cc -> /opt/gcc/bin/gcc
bash-2.05$ cc -v
Using built-in specs.
Target: sparc-sun-solaris2.9
Configured with: /net/sacrum/export/home/bldmstr/nightly/20061019_mars_gcc.s9.opt.tarbuild/src/configure --prefix=/opt/gcc --enable-shared --with-system-zlib --enable-checking=release --disable-libmudflap --enable-languages=c,c++ --enable-version-specific-runtime-libs --with-gxx-include-dir=/opt/gcc/include/c++/4.0.3 --with-cpu=v9
Thread model: posix
gcc version 4.0.3 (gccfss)
bash-2.05$
bash-2.05$uname -a
SunOS itsm009 5.9 Generic_118558-34 sun4u sparc SUNW,Sun-Blade-1000
bash-2.05$
编译完成后,使和tmboot –y 启动应用。
-bash-3.00# tmboot -y
Booting all admin and server processes in /opt/bea/app/simpapp/tuxconfig
INFO: BEA Tuxedo, Version 10.0, 64-bit, Patch Level (none)
INFO: Serial #: 454493271161-2664984303294, Expiration NONE, Maxusers 1000000
INFO: Licensed to: Customer
Booting admin processes ...
exec BBL -A :
process id=2477 ... Started.
Booting server processes ...
exec simpserv -A :
process id=2478 ... Started.
exec WSL -A -- -n //192.168.0.8:7200 -m 10 -M 20 -x 6:
process id=2479 ... Started.
3 processes started.
-bash-3.00#
关闭应用:
-bash-3.00# tmshutdown -y
Shutting down all admin and server processes in /opt/bea/app/simpapp/tuxconfig
Shutting down server processes ...
Server Id = 20 Group Id = GROUP1 Machine = itsm001:shutdown succeeded
Server Id = 1 Group Id = GROUP1 Machine = itsm001:shutdown succeeded
Shutting down admin processes ...
Server Id = 0 Group Id = itsm001 Machine = itsm001:shutdown succeeded
3 processes stopped.
-bash-3.00#
Client
客户端程序代码如下:
bash-2.05# more simpcl.c
/*(c) 2003 BEA Systems, Inc. All Rights Reserved. */
/*Copyright (c) 1997 BEA Systems, Inc.
All rights reserved
THIS IS UNPUBLISHED PROPRIETARY
SOURCE CODE OF BEA Systems, Inc.
The copyright notice above does not
evidence any actual or intended
publication of such source code.
*/
/* #ident"@(#) samples/atmi/simpapp/simpcl.c$Revision: 1.5 $" */
#include <stdio.h>
#include "atmi.h"/* TUXEDOHeader File */
#if defined(__STDC__) defined(__cplusplus)
main(int argc, char *argv[])
#else
main(argc, argv)
int argc;
char *argv[];
#endif
{
char *sendbuf, *rcvbuf;
long sendlen, rcvlen;
int ret;
if(argc != 2) {
(void) fprintf(stderr, "Usage: simpcl string\n");
exit(1);
}
/* Attach to System/T as a Client Process */
if (tpinit((TPINIT *) NULL) == -1) {
(void) fprintf(stderr, "Tpinit failed\n");
exit(1);
}
sendlen = strlen(argv[1]);
/* Allocate STRING buffers for the request and the reply */
if((sendbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating send buffer\n");
tpterm();
exit(1);
}
if((rcvbuf = (char *) tpalloc("STRING", NULL, sendlen+1)) == NULL) {
(void) fprintf(stderr,"Error allocating receive buffer\n");
tpfree(sendbuf);
tpterm();
exit(1);
}
(void) strcpy(sendbuf, argv[1]);
/* Request the service TOUPPER, waiting for a reply */
ret = tpcall("TOUPPER", (char *)sendbuf, 0, (char **)&rcvbuf, &rcvlen, (long)0);
if(ret == -1) {
(void) fprintf(stderr, "Can't send request to service TOUPPER\n");
(void) fprintf(stderr, "Tperrno = %d\n", tperrno);
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
exit(1);
}
(void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);
/* Free Buffers & Detach from System/T */
tpfree(sendbuf);
tpfree(rcvbuf);
tpterm();
return(0);
}
bash-2.05#
编辑客户端程序(其中-w参数使客户端以WSL联接,本地客户端则不需要使用):
bash-2.05# buildclient-o client-f simpcl.c-w
simpcl.c: In function 'main':
simpcl.c:34: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:40: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:43: warning: incompatible implicit declaration of built-in function 'strlen'
simpcl.c:50: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:57: warning: incompatible implicit declaration of built-in function 'exit'
simpcl.c:60: warning: incompatible implicit declaration of built-in function 'strcpy'
simpcl.c:71: warning: incompatible implicit declaration of built-in function 'exit'
bash-2.05#
测试应用,如果应用成功则返回大写字符串。
-bash-3.00# ./simpcl adfdf
Returned string is: ADFDF
-bash-3.00#
将client 放到远程主机。
由于本例中两台主机均为solaris 系统,所以在远程客户机上安装完TUXEDO客户端软件后,没有对simpcl.c重新编辑,而是直接将在Server端译后将生成的二进制文件复制到远程客户端使用。
远程客户端环境变量如下:
bash-2.05# env grep TUX
TUXDIR=/export/home/tuxedo/tuxedo9.1
bash-2.05# env grep AD
WSNADDR=//192.168.0.8:7200
bash-2.05#
其中TUXDIR为TUXEDO客户端安装目录。
测方式方法与本地客户端相同。
bash-2.05# ./client adf
Returned string is: ADF
bash-2.05#
。
--转自