# AsyncBinary 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 AsyncBinary sample. For more information on this sample, see the AsyncBinary Sample Description.

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

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 AsyncBinSample/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 ANT_HOME=`
`set BEA_HOME=[bea_home]` (e.g., C:/bea)
`set JAVA_HOME=[java_home] (`e.g., %BEA_HOME%/jdk150_11)
`set JYTHON_HOME=[jython_home](`Default: %BEA_HOME%/wlserver_10.0/common/lib`)`
`set WLI_UTIL_HOME=[wli_util_home]` (The location of WLI Common Utilities, e.g., C:/wli_util)
`set WL_HOME=[WebLogic_home]` (e.g., %BEA_HOME%/wlserver_10.0)

`set WLI_HOME=[WLI_home]` (e.g., %BEA_HOME%/wli_10.2)
`set DOMAIN_HOME=[domain_home]` (e.g., %BEA_HOME%/user_projeccts)
`set CLIENT_HOME=[client_home]` `(e.g., C:/AsyncBinSample``)`

· For Unix installations—bash shell, enter the following:
`export ANT_HOME=`
`export BEA_HOME=[bea_home]` (e.g., /export/home/my_bea)
`export JAVA_HOME=[java_home]` (e.g., $BEA_HOME/jdk150_11)
`export JYTHON_HOME=[jython_home] (`Default: $BEA_HOME/wlserver_10.0/common/lib`)`
`export WLI_UTIL_HOME=[wli_util_home]` (The location of WLI Common Utilities, e.g., C:/wli_util)
`export WL_HOME=[WebLogic_home]` (e.g., $BEA_HOME /wlserver_10.0)

`export WLI_HOME=[WLI_home]` (e.g., $BEA_HOME/wli_10.2)
`export DOMAIN_HOME=[domain_home] (`e.g., $BEA_HOME/user_projects)
export CLIENT_HOME=[client_home] `(e.g., /export/home/AsyncBinSample``)`

2. Run the bootstrap as follows:

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

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

3. Set the WLS Environment by entering setWLSEnv.cmd ( or setWLSEnv.sh for Unix).

### 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:

`copy domain.asyncbinary.properties domain.properties```

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

## `cp domain.asyncbinary.properties domain.properties```

Note: You can configure the domain names (e.g., DOMAIN_HOME/domains/acmeintg) 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:

`ant create_domain` ``

### Tune the Performance Parameters (Optional)

To tune the performance parameters:

1. Edit <DOMAIN_HOME>/domains/`acmeintg`/setDomainEnv.{sh,cmd} and set the following:
`set JAVA_VENDOR=BEA`
`if "%JAVA_VENDOR%"=="BEA" ( set MEM_ARGS to "-Xms512m -Xmx512m" )`

### Build the Applications

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

`1.` Enter:
`ant build```

### Start the Server

· For Windows installations:

Start a new command window and enter

`%DOMAIN_HOME%\domains\acmeintg\startWeblogic.cmd`

· For Unix installations, enter:

`$DOMAIN_HOME/domains/acmeintg/startWeblogic.sh &`

### 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`

Note: If you are using PointBase, start the Weblogic server before running the following step.

2. If you are using PointBase:

· For Windows, enter:

`%DOMAIN_HOME%\domains\acmeintg\bin\startPointBaseConsole.cmd`

· For Unix, enter:

`$DOMAIN_HOME/domains/acmeintg/bin/startPointBaseConsole.sh`

This opens PointBase console window. Connect to the PointBase server by providing following values. Then you can execute the sql content in the next steps 3 and 4 for PointBase.

`Jdbc url: jdbc:pointbase:server://localhost:9093/weblogic_eval`

`User: weblogic`

`Password: weblogic`

3. Execute the sql script <DOMAIN_HOME>/temp/acmeintg/appdbscripts.sql. If you are using PointBase, you can copy the sql content into the PointBase console and do execute all.

4. If you are using PointBase, execute the sql script <CLIENT_HOME>/scripts/pointbase_dbscripts.sql. If you are using Oracle, execute <CLIENT_HOME>/scripts/oracle_dbscripts.sql

###

### 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.``

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.``

### Test the Installation

To test the installation:

1. Run ant test as follows:

`·` For single node enter:
`ant test -DURL=t3://localhost:7001` `(Default of TXN=1``)`

`or`

`ant test -DURL=t3://localhost:7001 –DTXN=#n`

`·` For a cluster enter:
`ant test -DURL=t3://localhost:8001,localhost:9001,localhost:10001` `(Default of TXN=1``)```

`or```

`ant test -DURL=t3://localhost:8001,localhost:9001,localhost:10001 –DTXN=#n```

Note: `Replace #n` `with the number of transactions to be sent to the server. Each one will create four transactions as there is information for four credit cards in the database.` ``

`2.` `In a separate window, go to` <domain_home>\domains\acmeintg`\cgServer` `and inspect file cgServer.log``. On Unix, you can enter:`
`tail –f cgServer.log`
`In a clustered environment, use the managed server name instead.`
`For each TXN value, there will be 4 messages sent to the server, and the log file should show all 4 transactions with the following mark:`
`<*** Benchmark results: Start = 21:30:03:437 End = 21:30:09:093 Elapsed = 00:05:656 ***>```

`Note:``If the server is not running on localhost:7001 [default], a URL can be passed as an argument in the above command as follows:`

`ant test –DTXN=1 –DURL=t3://<address:port>`

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

Workshop is an Eclipse based IDE. You can start Workshop by executing <BEA_HOME>/workshop_10.2/workshop4WP/workshop4WP.exe. You can use the IDE to deploy the application. If you deployed the ear files using ant and try to deploy using IDE again, the deployment will fail. IDE deploys the application as an exploded ear.

To see the application in IDE:

1. Delete the .metadata and .temp folders from <CLIENT_HOME>/apps.

2. Set wl.home environment variable to point to <`BEA_HOME>/wlserver_10.0`

3. Open Workshop and point to <CLIENT_HOME>/apps as workspace.

4. Define WLI_HOME as a variable in Workshop and point it to <BEA_HOME>/wli_10.2( Window->Preferences->Java-> Build Path->Classpath Variables->New button )

5. Use File->Import->Existing projects into Workspace and point to the <CLIENT_HOME>/apps folder.

## 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 WL_HOME=[weblogic_home]`
  `set WLI_UTIL_HOME=[wli_util_home]` `(location of WLI Common Utilities)`
  `set DOMAIN_HOME=[domain_home]`
  `set JAVA_HOME=[java_home]`
  `set CLIENT_HOME=[client_home]```

`set WLI_HOME=[WLI_home]```

- `cd AsyncBinSample\scripts\```
- `bootstrap`
- `setWLSEnv`
- copy domain.`asyncbinary`.properties to domain.properties
- ant create_domain
- ant build
- In a new command window, %DOMAIN_HOME%\domains\`acmeintg`\startWeblogic.cmd
  Wait for the server to come up.
- ant create_app_db_scripts
- If using PointBase:
  %DOMAIN_HOME%\domains\`acmeintg`\`bin\startPointBaseConsole.cmd`
- Run the sql scripts manually
- ant deploy
- `ant test -DURL=t3://localhost:7001`

To start the server every time after that, open a new command window and enter:

%DOMAIN_HOME%\domains\`acmeintg`\startWeblogic.cmd

## Sample Directory Structure

AsyncBinSample

├───apps

│ ├───acme

│ │ └───APP-INF

│ ├───Common

│ ├───intg_ejb

│ ├───Schemas

│ │ └───system

│ └───acmeweb

│ ├───com/acme/intg

│ │ ├───controls

│ │ ├───processes

│ │ └───transformations

│ └───WEB-INF

│ ├───com/acme/intg

│ └───xquery-functions

├───client

├───lib

└───scripts

## Sample Contents

The sample consists of the following files:

Application – acme

EJB Project – intg_ejb

`InboundMessageHandlerBean.ejb` | - To process the received message in CCInbound JMS Queue; an MDB

Client Proxy

`CreditCardProcessProxy.jar` | - Created from CreditCardProcess.jpd, to be used by InboundMessageHandlerBean.ejb to call CreditCardProcess.jpd

Process Project - acmeWeb

`processes/``CreditCardProcess.java` | - Receives the message in non-XML format - Persists the message in a file - Converts non-XML to XML format for further processing by calling ConvertNonXMLToXML - Validates and authorizes by calling CreditCardValidationProcess.jpd - Converts the reply XML to non-XML by calling OutboundXMLToNonXML.dtf - Persist the outbound non-XML message in a file - Returns the non-XML reply data to the MDB
`processes/ConvertNonXMLToXML.java` | - An interface controller to the NonXMLtoXML.dtf
`processes/CreditCardValidationProcess.java` | - Validates the CreditCard number - Checks the balance - Authorizes the purchase - Updates the database - Create an outbound reply XML - Updates the transaction in the database - Returns the reply XML
`controls/CCTxnDBControl.java` | - All database related interfaces
    controls/ConvertNonXMLToXMLPControl.java
| - Converts non-XML to XML for further processing
    controls/CreditCardValidationProcessPControl.java
| - Interface to the CreditCardValidationProcess.jpd
    transformations/ CreditCardValidationProcessTransformation.java
| - Transformation of XML to database fields
    transformations/ CreditCardValidationProcessccTxnInsertinsertTxn.xq
| - XQuery for the above transformation
    transformations/InboundXMLToOutboundXML.java
| - Transformation of processed InboundXML to OutboundXML
    transformations/convertInXMLToOutXML.xq
| - XQuery for the above transformation
    transformations/NonXMLtoXML.java
| - Transformation of inbound non-XML to inbound XML
    transformations/convertNonXMLtoXML.xq
| - XQuery for the above transformation
    transformations/OutboundXMLToNonXML.java
| - Transformation of processed OutboundXML to outbound non-XML
    transformations/convertXMLtoNonXML.xq
| - XQuery for the above transformation

Schemas Project

CCInboundRawMessage.mfl | - Non-XML representation of the incoming message
AuthorizationMessage.xsd | - XML representation of the incoming message
ValidationMessage.xsd | - XML representation of the outgoing message
CCOutboundRawMessage.mfl | - Non-XML representation of the outgoing message

Database Tables

scripts/ pointbase_dbscripts.sql | - User-defined tables for PointBase
scripts/ oracle_dbscripts.sql | - User-defined tables for Oracle