WebLogic Server 6.1 Code Examples, BEA Systems, Inc.

Package examples.wtc.tBridge

The tBridge is an administratively configured process that provides a communication bridge between JMS and Tuxedo.

There are three types of communication pathways that can be configured with the tBridge:

Note: This example uses the same configuration WebLogic Server and Tuxedo configurations that are required for the simpapp example.
  • If you have completed the simpapp example, you are ready run the tBridge example.
  • Otherwise, complete the simpapp example.

    Configuration

    This section provides information on the steps required to configure the tBridge to communicate with JMS and Tuxedo.
    1. Add the tBridge configuration to WTC_CONFIG.XML
    2. Add the JMS queues to WebLogic Server
    3. Startup WebLogic Server
    4. Verify the Tuxedo configuration
    5. Execute the example JMS routines

    1. Add the tBridge configuration to WTC_CONFIG.XML
    2. The tBridge configuration is described in a separate, primary leaf section of the WTC_CONFIG.XML. Edit the WTC_CONFIG.XML and add the <tBridge></tBridge> section after the </BDMCONFIG>. For this example, we reference the Tuxedo service TOUPPER used in simpapp example. An example tBridge WTC_CONFIG.XML file is located in the tBridge example directory.
      
      <?xml version="1.0"?>
      
      <!DOCTYPE WTC_CONFIG SYSTEM 
      "http://www.bea.com/servers/wls610/dtd/wtc_config_1_0.dtd">
      <WTC_CONFIG>
      <BDMCONFIGA>
               <T_DM_LOCAL_TDOMAIN AccessPoint="TDOM2">
                       <WlsClusterName>MyCluster</WlsClusterName>
                       <AccessPointId>TDOM2</AccessPointId>
                       <Type>TDOMAIN</Type>
                       <Security>NONE</Security>
                       <ConnectionPolicy>ON_DEMAND</ConnectionPolicy>
                       <BlockTime>30</BlockTime>
                       <NWAddr>[Network address of WTC domain]</NWAddr>
                       <!-- Example address: //mydomain.acme.com:20304 -->
               </T_DM_LOCAL_TDOMAIN>
               <T_DM_REMOTE_TDOMAIN AccessPoint="TDOM1">
                       <LocalAccessPoint;TDOM2</LocalAccessPoint>
                       <AccessPointId>MYDOMAIN</AccessPointId>
                       <Type>TDOMAIN</Type>
                       <NWAddr>[Network address of Tuxedo domain]</NWAddr>
                       <!-- Example address: //mydomain.acme.com:20305 -->
               </T_DM_REMOTE_TDOMAIN>
               <T_DM_IMPORT
                       ResourceName="TOUPPER"
                       LocalAccessPoint="TDOM2"
                       RemoteAccessPointList="TDOM1">
                       <TranTime>600</TranTime>
               </T_DM_IMPORT>
      </BDMCONFIG>
      <tBridge>
             <redirect>
                <fromto>
                   <direction>JmsQ2TuxS</direction>
                   <source>
                      <Name>weblogic.jms.Jms2TuxQueue</Name>
                   </source>
                   <target>
                      <AccessPoint>TDOM2</AccessPoint>
                      <Name>TOUPPER</Name>
                   </target>
                   <replyQ>weblogic.jms.Tux2JmsQueue</replyQ>
                   <translateFML>No</translateFML>
                </fromto>
             </redirect>
             <timeout>60</timeout>
             <wlsErrorDestination>weblogic.jms.tBerrorQueue</wlsErrorDestination>
             <jndiFactory>weblogic.jndi.WLInitialContextFactory</jndiFactory>
             <jmsFactory>weblogic.jms.ConnectionFactory</jmsFactory>
             <tuxFactory>tuxedo.services.TuxedoConnection</tuxFactory>
      </tBridge>
      </WTC_CONFIG>
      
      This configuration specifies that the tBridge reads a message from a JMS queue, transfers it to a Tuxedo service and returns the reply to a JMS queue.
      • The <direction> keyword is JmsQ2TuxS.
      • The <source> <Name> keyword specifies the name of the JMS queue to read is weblogic.jms.Jms2TuxQueue.
      • The <target> specifies the elements necessary to explicitly reference the destination.
      • The <AccessPoint> keyword specifies the name of the access point is TDOM2.
      • The <Name> keyword specifies the Tuxedo service name to be called: TPUPPER.
      • The <replyQ> keyword specifies the name of a JMS reply queue is weblogic.jms.Tux2JmsQueue.

    3. Add the JMS queues to WebLogic Server
    4. This example uses two JMS queues that must be configured in WebLogic Server:
      • weblogic.jms.Jms2TuxQueue - the tBridge is a message consumer associated with this queue. When a message is written to this queue, as described in the configuration, tBridge will read the message and call the desired Tuxedo service.
      • weblogic.jms.Tux2JmsQueue - the tBridge will return the Tuxedo service response to this JMS queue.
      The queues can be configured using the WebLogic Server console or the WebLogic Server CONFIG.XML file must be edited to add the following statements:
      
       <JMSQueue JNDIName="weblogic.jms.Jms2TuxQueue" Name="Jms2TuxQueue" StoreEnabled="default"/>
       <JMSQueue JNDIName="weblogic.jms.Tux2JmsQueue" Name="Tux2JmsQueue" StoreEnabled="default"/>
      

    5. Add the JMS Server
    6. Update your config.xml file to add a JMS server.
      
            <JMSServer 
                     Name="TestJMSServer" 
                       Targets="myserver">
              <JMSQueue 
                   JNDIName="weblogic.jms.Jms2TuxQueue" 
                    Name="Jms2TuxQueue"/>
              <JMSQueue 
                   JNDIName="weblogic.jms.Tux2JmsQueue" 
                   Name="Tux2JmsQueue"/>
           </JMSServer>
      

    7. Startup WebLogic Server
    8. Start WebLogic Server and monitor the log file for any errors.

    9. Verify the Tuxedo configuration
    10. This example uses the same configuration WebLogic Server and Tuxedo configurations that are required for the simpapp example.
      • If you have completed the simpapp example, you are ready run the tBridge example.
      • Otherwise, complete the simpapp example.

      Execute the client code using the run command to demonstrate that the TOUPPER EJB is functional.

    11. Execute the example JMS routines
    There are two simple test routines provided with WebLogic Tuxedo Connector:
    • tBsend2jms - reads from the terminal and send a JMS message to the designated queue.
    • tBfrom2jms - reads from a JMS queue and sends to the terminal.
    These utility routines have two argument:
    • [target queue] is optional and defaults to "weblogic.jms.Jms2TuxQueue" for tBsend2jms and "weblogic.jms.Tux2JmsQueue" for tBfrom2jms.
    • WeblogicURL is required

    Run the example

    1. In a DOS window, if you haven't already done so, set the WebLogic Server environment by using the setEnv.cmd.
      • Execute tBfrom2jms by using the following command:
         java weblogic.wtc.tbridge.tBfrom2jms t3://localhost:7001
        The routine should respond indicating that it is waiting for a JMS message.
    2. In another DOS window, setup the WebLogic Server environment and execute the tBsend2jms routine using the following command:
       java weblogic.wtc.tbridge.tBsend2jms t3://localhost:7001
    3. The tBsend2jms routine indicates that it is waiting for terminal input.
    4. In the tBsend2jms window, type in a text string such as "Hello"
    5. The tBfrom2jms window responds with "HELLO"

    Using tBridge with Tuxedo /Q

    The tBridge can also interface with Tuxedo /Q. The configuration described above can be easily altered to send a JMS message to Tuxedo /Q and also to read a message from Tuxedo /Q and sent it to JMS. In the tBridge example show below there are two directional <:fromto> pipes configured:
    1. One pipe reads from a JMS queue weblogic.jms.Jms2TuxQueue and send the message to the Tuxedo /Q QSPACE named STRING with the reply queue set to RPLYQ.
    2. A second pipe that performs the opposite function, reading from the Tuxedo /Q QSPACE named STRING and sending the message to the JMS queue weblogic.jms.Tux2JmsQueue.
    
             <fromto>
                 <direction>JmsQ2TuxQ</direction>
                 <source>
                    <Name>weblogic.jms.Jms2TuxQueue</Name>
                 </source>
                 <target>
                    <AccessPoint>TDOM2</AccessPoint>
                    <Qspace>QSPACE</Qspace>
                    <Name>STRING</Name>
                 </target>
                 <replyQ>RPLYQ</replyQ>
                 <translateFML>NO</translateFML>
              </fromto>
              <fromto>
                 <direction>TuxQ2JmsQ</direction>
                 <source>
                    <AccessPoint>TDOM2</AccessPoint>
                    <Qspace>QSPACE</Qspace>
                    <Name>STRING</Name>
                 </source>
                 <target>
                    <Name>weblogic.jms.Tux2JmsQueue</Name>
                 </target>
                 <translateFML>NO</translateFML>
              </fromto>
    

    FML to XML Conversion

    The tBridge can do simple or "FLAT" FML32 to XML conversion. The following tBridge configuration can be used to send a XML message to the Tuxedo REVERSE_STRING FML32 based service and receive a XML reply.

    This example uses the same configuration WebLogic Server and Tuxedo configurations that are required for the simpFML32 example.

  • If you have completed the simpFML32 example, you are ready run the tBridge example.
  • Otherwise, complete the simpFML32 example.
    
              <fromto>
                 <direction>JmsQ2TuxS</direction>
                 <source>
                    <Name>weblogic.jms.Jms2TuxQueue</Name>
                 </source>
                 <target>
                    <AccessPoint>TDOM2</AccessPoint>
                    <Name>REVERSE_STRING</Name>
                 </target>
                 <replyQ>weblogic.jms.Tux2JmsQueue</replyQ>
                 <translateFML>FLAT</translateFML>
              </fromto>
    

    Run the example

    1. Execute the simpFML32 example.
    2. Add the tBridge configuration into the WTC_CONFIG.XML as show above. Add the resource entry into the BDMCONFIG section of the WTC_CONFIG.XML as shown below. This loads the class containing the FML32 field buffer names.
      
               <T_DM_RESOURCES>
                       <FieldTables>
                       <FldTblClass 
      Type="fml32">weblogic.wtc.tbridge.tBtest2flds32</FldTblClass>
                       </FieldTables>
               </T_DM_RESOURCES>
      
    3. Restart WebLogic Server.
    4. Start the two JMS utility routines: tBsend2jms and tBfrom2jms.
    5. In the DOS window running tBsend2jms, type the following simple XML message: <XML><STRING>Hello</STRING></XML>
    6. The corresponding DOS window running tBfrom2jms should display the returned XML message: <FML32><STRING>olleH</STRING></FML32>

    There's more...

    For more information on the tBridge error message handling, message priority and correlation ID mapping, see the WebLogic Tuxedo Connector Administration Guide.

    For more information about WebLogic Server WebLogic Tuxedo Connector, see:


    Documentation is available at
    http://e-docs.bea.com/wls/docs61/

    Copyright © 2000-2001 BEA Systems, Inc. All rights reserved.