# Dynamic Transformation and Routing Sample Readme

Introduction
Intended Audience
Installing the Sample

Set the Prerequisite Environment
Set the Domain Properties
Create the Domain
Tune the Performance Parameters (Optional)
Build the Applications
Create the Database Tables
Start the Server
Deploy the Application

Test the Installation
To Use the IDE
To Modify the Sample Defaults

Sample Installation Sequence (Windows)

Sample Directory Structure
Sample Contents

## Introduction

This readme describes the steps to build, deploy, and run the Dynamic Transformation and Routing sample. For more information on this sample, see the Dynamic Transformation and Routing Sample Description.

For an example of the installation process, see Sample Installation Sequence.

Note: This sample is provided on dev2dev for your convenience and is not supported by BEA.

## Intended Audience

This sample is intended for programmers and advanced users familiar with BEA products, DOS Command Prompt or Unix shell environment, and Ant.

## Installing the Sample

The following sections provide step-by-step instructions for installing the sample.

Note: Unzip the sample files into any directory that does not contain spaces in the directory path. For example, you can unzip the files into a directory named c:\sample_files, but not to a directory named c:\sample files. WebLogic Integration and the WLI Common Utilities must also be installed to directories that do not contain spaces.

### Set the Prerequisite Environment

Before you begin the installation, open a Command Prompt and follow the steps below to set the environment variables and bootstrap the sample environment. The DynamicTransformationAndRouting/scripts/ directory contains bootstrap, ant build files, and the domain properties file. Execute the bootstrap and ant tasks from this directory.

Note: ANT_HOME should be unset. ANT_HOME is not required to run the sample and may produce undesired behavior. The sample automatically uses ant contained in the WebLogic Server installation.

Note: WLST Offline and WLST Online are available for download and evaluation from BEA’s dev2dev site, but have not been formally included in the WebLogic Platform 8.1 product. WLST is supported through BEA newsgroups only, and the utility and APIs are subject to change. BEA intends to formally support this capability in a future release of WebLogic Platform.

1. Set the environment variables as follows:

· For Windows installations, enter the following:
`set BEA_HOME=[bea_home]`
`set JYTHON_HOME=[jython_home] (`Default: %BEA_HOME%\weblogic81\common\lib`)`
`set WLST_JAR=[wlst_jar]` (Default: %WLI_UTIL_HOME%\lib\wlst.jar`)`
`set WLI_UTIL_HOME=[wli_util_home]` (The location of WLI Common Utilities, e.g., C:\wli_util)
`set DOMAIN_HOME=[domain_home]`
`set JAVA_HOME=[java_home]`

· For Unix installations—bash shell, enter the following:
`export BEA_HOME=[bea_home]`
`export JYTHON_HOME=[jython_home] (`Default: $BEA_HOME/weblogic81/common/lib`)`
`export WLST_JAR=[wlst_jar] (`Default: $WLI_UTIL_HOME/lib/wlst.jar`)`
`export WLI_UTIL_HOME=[wli_util_home]` (The location of WLI Common Utilities, e.g., C:\wli_util)
`export DOMAIN_HOME=[domain_home]`
`export JAVA_HOME=[java_home]`

2. Run the bootstrap as follows:

· For Windows installations, enter the following:
`bootstrap`
This creates the `DynamicTransformationAndRouting\scripts\env.properties` file and sets environment variables`.`

· For Unix`installations:`
`. ./bootstrap.sh`
This creates the `DynamicTransformationAndRouting/scripts/env.properties` and sets environment variables`.`

### Set the Domain Properties

By default, the domain user name and password are “weblogic” and “weblogic”.

Note: Use double backslashes (\\) when defining path names in the properties file.

To set the domain properties for a single node domain

Copy the samples domain property file as follows and then modify to suit your needs:

· For Windows installations, enter the following:

`copy` `domain.DynamicTransformationAndRouting.properties domain.properties`

`·` For Unix`installations, enter the following:`

## `cp` `domain.DynamicTransformationAndRouting.properties domain.properties`

Note: You can configure the domain names (e.g., DOMAIN_HOME/domains/DynamicTransformation) by editing the domain.name property in the scripts/domain.properties file.``

To set the domain properties for a clustered domain

Note: To use this sample in a cluster, the domain must be configured with an Oracle database.

Edit the domain.properties file as follows:

1. Comment out domain.cluster=single.

2. Uncomment #domain.cluster=<clustername>.

3. Replace <clustername> with a valid cluster name without brackets.

4. Replace the following with valid values for your environment:

`domain.cluster.multicast.address``=237.0.2.1`
`domain.cluster.multicast.port``=7345`
`domain.cluster.servers``=2```

`domain.cluster.server1=server1`
`domain.cluster.server1.address=localhost`
`domain.cluster.server1.port=8001`

`domain.cluster.server2=server2`
`domain.cluster.server2.address=localhost`
`domain.cluster.server2.port=9001`

5. Based on domain.cluster.servers=<n>, create as many entries of domain.cluster.server<i>, domain.cluster.server<i>.address, and domain.cluster.server<i>.port.

6. Save the domain.properties file.

### Create the Domain

Create the domain by entering the following:

`ant` `create_domain`

### Tune the Performance Parameters (Optional)

To tune the performance parameters:

1. Edit [domain_home]/domains/DynamicTransformation/setDomainEnv.{sh,cmd} and set the following:
`set JAVA_VENDOR=BEA`
`set PRODUCTION_MODE="true"`
`if "%JAVA_VENDOR%"=="BEA" ( set MEM_ARGS to "-Xms512m -Xmx512m" )`

2. Edit <BEA_HOME>/weblogic81/common/lib/workshopLogCfg.xml and change all occurrences of "info" to "warn".

### Build the Applications

Building the applications builds ear files for all workshop applications under the `apps` directory. Build the applications as follows:

`ant` `build`

### Create the Database Tables

`Note:``If you are using Oracle, make sure the Oracle server is up and running.`

`To create the database tables:`

`1.` `Enter:`

`ant` `create_app_db_scripts`

2. If you are using PointBase:

· For Windows, enter:

`%BEA_HOME%\weblogic81\common\bin\startPointBase.cmd -port=9093 -debug=0 -win=true -home=%DOMAIN_HOME%\domains\`DynamicTransformation

· For Unix, enter:

`$BEA_HOME/weblogic81/common/bin/startPointBase.sh -port=9093 -debug=0 -win=true -home=$DOMAIN_HOME/domains/`DynamicTransformation

This opens a console window.

3. Create the database tables by entering:

`ant` `db_init`

4. If you are using PointBase:

· For Windows, enter:

`%BEA_HOME%\weblogic81\common\bin\stopPointBase.cmd –name=workshop`

`·` `For Unix, enter:`

`$BEA_HOME/weblogic81/common/bin/stopPointBase.sh –name=workshop`

### Start the Server

· For Windows installations:

`pushd %DOMAIN_HOME%\domains\` `DynamicTransformation```
`start cmd /c startWeblogic production noiterativedev notestconsole nodebug`
`popd`

· For Unix installations:

`pushd $DOMAIN_HOME/domains/` `DynamicTransformation``; nohup startWeblogic production noiterativedev notestconsole nodebug &; popd`

### Deploy the Application

Note: For a clustered domain, make sure that no other managed servers are running except the admin server.

For Windows installations, do the following:

`1.` `Enter:`

`ant` `deploy```

`Target` `deploy` `in turn calls targets` `create_app_queues``,` `deploy_egs``,` and`` `deploy_apps``.`

Note: At the end of the deployment, a message indicates that the deployment is deferred because no managed server is running. This is normal. Once you stop the admin server and restart with all other managed servers, the resources and the applications will appear.``

`2.` `Initialize xml metadata cache:```

`ant` `setup`

3. Restart the domain as follows:

`start``%DOMAIN_HOME%\domains\`DynamicTransformation`\stopWebLogic.cmd weblogic weblogic`

4. Start the server again.

For Unix installations, do the following:

`1.` `Enter:`

`ant` `deploy`

`Target` `deploy` `in turn calls targets` `create_app_queues, deploy_egs,` and `deploy_apps.`

Note: At the end of the deployment, a message indicates that the deployment is deferred because no managed server is running. This is normal. Once you stop the admin server and restart with all other managed servers, the resources and the applications will appear.``

`2.` `Initialize xml metadata cache:```

`ant` `setup```

3. Restart the domain as follows:

`$DOMAIN_HOME/domains/` DynamicTransformation`/stopWebLogic.sh weblogic weblogic`

4. Start the server again.

### Test the Installation

To test the installation, enter the following:
`ant test –DFROM=408 –DTO=408 (Default of TXN=1)```

`or```

`ant` `test –DFROM=408 –DTO=408 –DTXN=#n` `(Replace` `#n` `with the number of transactions to be sent to the server.)```

`or```

`ant` `test –DURL=t3://<address:port> -DFROM=408 –DTO=408 –DTXN=#n` `(Pass URL as an argument, if the server is not running on` `localhost``.)```

`Here` `from` `and` `to` `are the routing variables which determine the transformation to be applied and the JMS destination to route the message. The sample is configured for two values {408,210} for the routing variables.`

If the test is successful, the following appears on the command line, where XXX indicates the transactions per second:

`Transactions per second (TPS) is: XXX`

To run the application later:

1. Open a Command Prompt to the sample’s scripts directory.

2. Set the environment variables.

3. Run the bootstrap command.

4. Start the server(s).

`5.` Run the application.``

### To Use the IDE

The first time you run this on a machine, open the .work file. If you deployed the ear files and open the IDE while the server is running, it will prompt you to redeploy the application. If you do, it redeploys the application as an exploded ear.

### To Modify the Sample Defaults

You can modify the sample defaults for the from and to values. For example, to add a new transformation for the from field value = “100, do the following:

1. Add a new transformation map (.xq file) in the XQRepository application.

2. Update the XMLCache containing the mapping between the from field and the transformation to be applied to add this entry. This is done by updating the XML document and updating the cache. To do this, modify the xqMap.xml under the client folder.

3. Add a new entry for the to field, if necessary, to the XML cache if a new physical JMS destination is required.

· Create a new xml document containing the new JMS destination on the lines of jmsprops408.xml.

· Update the domain.properties to add a property to point to the new document.

· Update the createJMSEG.py to create the new queue.

· Update the dataloader.py to load the new jmsprops document.

· Modify the client program to listen to the newly defined queue.

## Sample Installation Sequence (Windows)

To build the applications, create the domain, deploy, and configure:

- `set BEA_HOME=[bea_home]`
  `set JYTHON_HOME=[jython_home]`
  `set WLST_JAR=[wlst_jar]`
  `set WLI_UTIL_HOME=[wli_util_home]` `(location of WLI Common Utilities)`
  `set DOMAIN_HOME=[domain_home]`
  `set JAVA_HOME=[java_home]`
- `cd DynamicTransformationAndRouting\scripts\```
- `bootstrap`
- copy domain.DynamicTransformationAndRouting.properties to domain.properties
- ant create_domain
- ant build
- ant create_app_db_scripts
- If using PointBase:
  `%BEA_HOME%\weblogic81\common\bin\startPointBase.cmd -port=9093 -debug=0 -win=true -home=%DOMAIN_HOME%\domains\DynamicTransformation`
- ant db_init
- If using PointBase:
  `%BEA_HOME%\weblogic81\common\bin\stopPointBase.cmd –name=workshop`
- pushd %DOMAIN_HOME%\domains\`DynamicTransformation`
  start cmd /c startWeblogic production noiterativedev notestconsole nodebug
  popd
- Wait for the server to come up.
- ant deploy
- ant setup
- start %DOMAIN_HOME%\domains\`DynamicTransformation`\stopWebLogic.cmd weblogic weblogic
- pushd %DOMAIN_HOME%\domains\ `DynamicTransformation`
  start cmd /c startWeblogic production noiterativedev notestconsole nodebug
  popd
- Wait for the server to come up.
- use on of the followings to test the server:
- ant test –DFROM=408 –DTO=408

To start the server every time after that, enter:

pushd %DOMAIN_HOME%\domains\`DynamicTransformation`
`start cmd /c startWeblogic production noiterativedev notestconsole nodebug`
popd

## Sample Directory Structure

DynamicTransformationAndRouting

├───apps

│ ├─── RoutingProcessor

│ │ ├───APP-INF

│ │ ├── routerschemas

│ │ └─── MessageBroker

│ │ ├───processes

│ │ └───WEB-INF

│ └─── XQRepository

│ ├───APP-INF

│ ├───schemas

│ └─── XQRepository

│ ├───processes

│ └───WEB-INF

│

├───client

└───scripts

## Sample Contents

The sample consists of the following files:

Application – RoutingProcessor, XQRepository

Process Project - MessageBroker

`Processes/``poRouter.jpd`

- Receives the JMS message
- Extracts the JMS properties containing the routing variables
- Extracts the document from the metadata cache containing the map of routing variables and the transformation to be applied
- Extracts the URI of the XQuery to be applied to the incoming document
- Invokes the Dynamic Transformation control
- Extracts the JMS dynamic property document based on the “to” routing variable
- Sets the dynamic properties of the JMS with the extracted document
- Sends the JMS message to the destination

`Processes/` `ddtfControl.jcx` | - Applies the transformation based on the routing variable
`Process/jmsControl.jcx` | - The MS control used to send the JMS messages

Process Project - XQRepository

`Processes/test.dtf` | - The Transformation control used for define XQuery methods
`Processes/``transformPO408.xq` | - The XQuery used for routing variable 408
`Processes/``transformPO210.xq` | - The XQuery used for routing variable 210
`Processes/getXQURI.xq` | - The XQuery used for extracting the XQuery URI for a given routing value

Schemas Project

Avitekpo.xsd | - Schema of the incoming message
Avitek408.xsd | - Schema of the transformed message for routing value 408
Avitek210.xsd | - Schema of the transformed message for routing value 210
xqmap.xsd | - Schema of the XQ map stored in the XML metadata cache containing the map between the routing variable and the XQ URI to be applied