WebT HMS
This chapter describes how to use the WebT message service by accessing the Hybrid Messaging System (HMS) provided by Tmax.
Overview
A Messaging System is a communication medium that enables loose coupling between a sender and a receiver. Each part only uses the information about a channel through which messages are exchanged, so a loose coupling is possible and the sender and the receiver can communicate using only the virtual channel information. Tmax provides HMS and can start a message system access a channel through a configuration.
Accessing HMS and all operations for message sending and receiving are performed by the interfaces defined by the Java Message Service (hereafter JMS), which is the Java based message system standard developed by Sun Microsystems. WebT provides classes that use JMS interfaces so users can use classes to implement message sending and receiving with a Tmax server using HMS.
For more information about the HMS structure in Tmax, refer to "Tmax HMS User Guide". |
JMS API
Classes defined in a JMS provide the following functionalities:
-
ConnectionFactory
-
A root class that users access to use a JMS. Creates connections to a message system.
-
In WebT, the WebtConnectionGroup class acts as a ConnectionFactory class. By casting a WebtConnectionGroup retrieved from an existing environment to a ConnectionFactory, WebT can use the ConnectionFactory.
-
Sub Classes: QueueConnectionFactory, TopicConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory
-
-
Connection
-
A connection to the message system.
-
Creates sessions that can manage transactions for message sending and receiving.
-
Sub classes: QueueConnection, TopicConnection, XAQueueConnection, XATopicConnection
-
-
Session
-
Context to access the message system that can handle transaction units.
-
Creates major classes required for message sending and receiving, such as clients, messages, and destinations.
-
Sub classes: QueueSession, TopicSession, XAQueueSession, XATopicSession
-
-
MessageProducer
-
A client that creates and sends messages.
-
Sub classes: QueueSender, TopicPublisher
-
-
MessageConsumer
-
A client that receives messages.
-
Sub classes: QueueReceiver, TopicSubscriber
-
-
QueueBrowser
-
A client that allows viewing messages in a queue without consuming them. The reception is limited to queue-type destinations.
-
-
Destination
-
A system channel where messages stay. There are two types: Queue and Topic.
-
Sub classes: Queue, Topic
-
-
Message
-
Messages that are sent and received in various types.
-
Sub classes: BytesMessage, MapMessage, ObjectMessage, StreamMessage, TextMessage
-
WebT JMS Support
WebT currently supports the following classes.
-
Connection
-
Sub classes: QueueConnection, TopicConnection, XAConnection, XAQueueConnection, XATopicConnection
-
Supports all methods except the following:
ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
-
-
ConnectionFactory
-
Sub classes : QueueConnectionFactory, TopicConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory
-
Supports all methods.
-
-
Session, QueueSession, TopicSession, XASession, XAQueueSessin, XATopicSession
-
Supports all methods.
-
-
MessageProducer, QueueSender, TopicPublisher
-
Supports all methods.
-
-
MessageConsumer, QueueReceiver, TopicSubscriber
-
Supports all methods.
-
-
QueueBrowser
-
Supports all methods.
-
-
Message, BytesMessage, TextMessage, MapMessage, StreamMessage, ObjectMessage
-
Supports all methods.
-
-
MessageListener
-
Supports a user implementation interface.
-
-
ExceptionListener
-
Supports a user implementation interface.
-
For more information about each class and method, refer to http://java.sun.com/j2ee/1.4/docs/api/javax/jms/package-tree.html. |
Environment Configuration
To access HMS in Tmax, it must be started by setting the Tmax environment configuration. The HMS settings must be configured in the webt.properties file or the JeusMain.xml file for the Connection Group created by WebT to access the HMS.
Configuring Tmax
To use HMS, the DOMAIN, NODE, SVRGROUP, and HMS sections must be set in the Tmax configuration file.
The following is a configuration file example for HMS:
*DOMAIN Domain1 SHMKEY=0x11936, TMMLOGLVL = "DEBUG1", CLHLOGLVL = "DEBUG1", MINCLH = 1, MAXCLH = 1, TPORTNO = 7783, MAXSESSION = 1024 *NODE Node1 TMAXDIR = "/data/tmax", APPDIR = "/data/tmax/appbin/", MAXSESSION = 1024 *SVRGROUP svghms NODENAME = "node1", CPC=1, SVGTYPE="HMS", RESTART=N, OPENINFO = "ORACLE_XA+Acc=P/scott/tiger+SesTm=60+Threads=true", HMSSUBSCFG = "/data/tmax/config/hmssubsconfig", HMSNAME = "hms_ora", HMSSINDEX = 1, HMSMSGLIVE = 1, HMSMAXTHR = 4, HMSMAXDBTHR = 10 *SERVER … *SERVICE … *HMS queue1 SVGNAME = svghms, TYPE = "QUEUE", BOOT = "WARM", GLOBAL = N topic1 SVGNAME = svghms, TYPE = "TOPIC", BOOT = "WARM", GLOBAL = N
-
DOMAIN and NODE sections
The MAXSESSION field can be set.
-
SVRGROUP section
SVRGROUP, NODENAME, SVGTYPE, HMSNAME, OPENINFO, HMSINDEX, HMSMAXTHR, and HMSMAXDBTHR must be set. HMSSUBSCFG, HMSMSGLIVE, HMSPORT, HMSHEARTBEAT, and HMSGQINT can be configured as well.
-
HMS section
SVRNAME and TYPE must be set. BOOT, GLOBAL, GQTHR, GQMAXREQ, and GQFULL can also be configured.
For more information about each configuration, refer to "Chapter 2. Configuring an HMS Environment" in the "Tmax HMS User Guide". |
Configuring JEUSMain.xml
If the HMS configuration is added to the WebtConnectionPool, which is set under the <external-resource> tag in the JEUSMain.xml, HMS can be accessed.
The following example shows how to set the JEUSMain.xml file.
<resource> ... <external-resource> <property-group> <name-prefix>tmax2</name-prefix> <property> <key>type</key> <value>shared</value> </property> <property> <key>host-name</key> <value>192.168.35.218</value> </property> <property> <key>host-port</key> <value>8888</value> </property> <property> <key>min</key> <value>10</value> </property> <property> <key>max</key> <value>20</value> </property> <property> <key>step</key> <value>2</value> </property> <property> <key>check-acquired</key> <value>true</value> </property> <property> <key>support-xa</key> <value>true</value> </property> <property> <key>enable-autoclose</key> <value>true</value> </property> <property> <key>connect-timeout</key> <value>2</value> </property> <propery> <key>jms-name</key> <value>hms01</value> </property> <propery> <key>jms-type</key> <value>queue</value> </property> </property-group> </external-resource> ... </resource>
The following describes HMS configuration items.
Item | Category | Description |
---|---|---|
jms-name |
Setting value |
String |
Default value |
NULL |
|
Description |
The HMS name to enable the HMS services in Tmax. If this value is specified, the HMS in Tmax can be accessed through the connection pool using the Java messaging system interfaces. |
|
jmsType |
Setting value |
queue | topic | xaqueue | xatopic |
Default value |
NULL |
|
Description |
The type of the messaging system to access. Valid only when the jms-name is specified. |
Configuring webt.properties
HMS can be accessed from WebT by configuring the following items in the webt.properties file.
The following is an example of configuring the webt.properties file.
####################################### # logging related parameters. ####################################### # set log level valid values are none, info, debug. default is none. log.level=debug # set directory in which the log file places. if not set, log is # printed to standard out log.dir=D:\\ # set the name of the log file. default is webt.log log.file=webt.log # set log buffering size. default is 0 log.bufsize=1024 # tmax.webt.xid.log=true ####################################### # FDL related parameters ####################################### # set the fdl file. fdl.file=c:\\tmax\\sample\\fdl\\tmax.fdl # set application wide default character set. default is system default defaultCharset=euc-kr # Tmax headerType headerType=extendedV4 ############################## # monioring related parameters ############################## # enable/disable alive check. default is disable(false) monitoring.pool.checkAlive=true # set monitoring interval. default is 60sec monitoring.pool.interval=5 # set monitoring log file valid-days.default is -1 monitoring.log.validDays=1 ############################## # connection pool realted paramters ############################## # enable/disable connection pool. default is disable(false) enableConnectionPool=true # WebtConnectionGroup name list connectionPool.groups=tmax1 # set connection group type valid values are shared, non-shared, # non-shared2. default is shared connectionPool.tmax1.type=shared # set Tmax Server Address. connectionPool.tmax1.hostAddr=192.168.1.123 # set Tmax Server Port. connectionPool.tmax1.hostPort=8888 # set Backup Tmax Server Address. connectionPool.tmax1.hostBackupAddr=61.77.153.1 # set Backup Tmax Server Port. connectionPool.tmax1.hostBackupPort=8889 # set default user name for security. connectionPool.tmax1.userName=tmax # set default user passward for security. connectionPool.tmax1.userPasswd=1234 # set default domain name for security. connectionPool.tmax1.domainName=choco # set default domain passward for security. connectionPool.tmax1.domainPasswd=1234 # set initial pool size. default is 10 connectionPool.tmax1.initCapacity=1 # set max pool size. default is 20 connectionPool.tmax1.maxCapacity=10 # set increment step size. default is 5 connectionPool.tmax1.incrementRate=2 # set connection idle time. default is 60sec connectionPool.tmax1.maxIdleTime=60 # set tptimeout. connectionPool.tmax1.tpTimeout=40 # set txtimeout. connectionPool.tmax1.txTimeout=10 # set connection timeout. connectionPool.tmax1.connectTimeout=10 # enable to event service. #connectionPool.tmax1.enableEvent=true # set event service Type. #connectionPool.tmax1.eventSvcType=all # set event handler object. #connectionPool.tmax1.eventHandler=tcpservet.event.GenericEvent jeus.servlet.webt.autoClose.enable=true connectionPool.tmax1.jmsName = hms01 connectionPool.tmax1.jmsType = queue
The following describes HMS configuration items.
-
connectionPool.<groupName>.jmsName = String
-
Default value : NULL
-
The HMS name to enable the HMS services in Tmax. If this value is specified, the HMS in Tmax can be accessed through the connection pool using the Java messaging system interfaces.
-
-
connectionPool.<groupName>.jmsType = queue | topic | xaqueue | xatopic
-
Default value : NULL
-
The type of the messaging system to access. Valid only when the jms-name is specified.
-
Sample Program
The following is a sample Java program that uses HMS in WebT.
public class JmsTest1 { public static void main(String[] argv) throws Exception{ System.setProperty("webt.properties", "d:\\webt.properties"); new WebtProperties(); QueueConnectionFactory result = (QueueConnectionFactory)WebtConnectionPool.getGroup("tmax1"); QueueSession qc = (QueueSession)(((QueueConnectionFactory)result).createQueueConnection().createQueueSession(false, Session.AUTO_ACKNOWLEDGE)); Queue q = qc.createQueue("queue01"); QueueSender qs = (QueueSender)(qc.createSender(q)); QueueSender qs2 = (QueueSender)(qc.createSender(q)); System.out.println("qs2 id : " + ((WebtQueueSender)qs2).getID()); TextMessage msg = qc.createTextMessage(); msg.setText("qwerty"); msg.setIntProperty("NO", 1); qs.send(msg,DeliveryMode.PERSISTENT,0,0); QueueReceiver qr = (QueueReceiver)(qc.createReceiver(q)); BytesMessage msg2 = (BytesMessage)(qr.receive()); byte[] data = new byte[256]; msg2.readBytes(data); System.out.println("body : " + new String(data)); System.out.println("NO : " + msg2.getIntProperty("NO")); qr.close(); qs.close(); //qs2.close(); qc.close(); }