Java CAPS Sample Documentation


<font color="red">Working with the Oracle Java CAPS Samples for Oracle Advanced Queueing</font>

Working with the Oracle Java CAPS Samples for Oracle Advanced Queueing


The following procedures provide general instructions for working with the Advanced Queueing sample projects and modifying the Advanced Queueing database. For more detailed information and instructions on using Advanced Queueing, see the Oracle Database documentation.

Overview

The purpose of the sample projects provided for Oracle Advanced Queueing and Java CAPS (Repository) is to illustrate how to access Advanced Queues from Java Collaboration Definition (JCD) projects and then monitor and manage those queues through Java CAPS Enterprise Manager.

When you extract the ZIP file containing the samples, the Java CAPS project is located in jcapsem\projEMTest.zip. Sample input and output files and SQL scripts are also included in the jcapsem directory. The sample also includes a Java CAPS Environment to go along with the sample project.

This tutorial takes you through the steps of configuring the projects and Environment, configuring the Advanced Queues, deploying the projects, and running sample data. It covers the following procedures:


Prerequisites

Before beginning any of the following procedures, you must have Java CAPS and an Oracle database installed.

Installing the Java CAPS Sample Project

This procedure requires that the Java CAPS Repository be running.

  1. Download jcapsem.zip.

    This file is also available from the Java CAPS sample code site under the Oracle JMS tab.

  2. Extract the downloaded file into a temporary directory.

  3. Launch NetBeans, and verify that you are connected to the Repository.

  4. From the NetBeans toolbar, select Tools, point to CAPS Repository, and then select Import Project.

  5. On the Import Project dialog box, click Yes to proceed, or click No to save any changes to the Repository and repeat the previous step.

  6. On the Import Manager, click Browse and navigate to the temporary directory where you extracted jcapsem.zip, and then to \jcapsem.

  7. Select projEMTest.zip and click Open.

    One project, projEMTest appears in the selected projects list. An Environment, EMEnvironment, appears in the list of environments to import.

  8. Make sure Destination Project is set to As Top-Level.

  9. Click Import.

  10. On the confirmation dialog box that appears, click OK.

    The Repository is refreshed, the project appears in the Projects window, and the Environment appears in the Services window.


Configuring the Advanced Queues

In order to configure Advanced Queueing, you must have an Oracle database installed and running. This procedure takes you through the steps of configuring the database, running a required script against the database to give Enterprise Manager delete capabilities on the queues, and creating the Advanced Queue life-cycle module in Java CAPS.

The sample projects include a sample script, setup_jcapsem.sql that performs most of the database setup work for you. It creates a Java CAPS user (jcapsem), grants all the necessary privileges to the user, creates the tables and queues, starts the queues, and enables both enqueue and dequeue.

  1. From a command prompt, navigate to the location where you extracted the sample project files above, and then navigate to the jcapsem directory.

  2. Run the following command from the prompt:

    sqlplus /NOLOG @setup_jcapsem.sql

  3. When prompted enter the Oracle password for the system user.

    The script runs, and status messages for the process appear your command line screen.

  4. When the process completes, navigate to JavaCAPS_Home\appserver\addons\caps\oracleaq, and run the following command:

    sqlplus system@service_name jdbcwrappers.sp

    where service_name is the Oracle SID name of the database.

  5. When prompted enter the Oracle password for the system user.

    The script runs, and status messages for the process appear your command line screen.

  6. You can check the tables that were created by logging into your database with the Java CAPS user:

    sqlplus jcapsem/jcapsem@service_name

    Run the following command to see the tables that were created:

    select table_name from user_tables;

  7. Start the Java CAPS GlassFish server.

  8. From a command prompt, navigate to JavaCAPS_Home\appserver\bin.

  9. At the command prompt enter asadmin.

  10. At the asadmin prompt, enter the following command:

    create-oracleaq --oracleaqhost database_hostname --oracleaqsid database_servicename --oracleaqusername jcapsem --oracleaqpassword jcapsem CAPS_AQ

    where database_hostname is the name of the server on which the Oracle database is installed and database_servicename is the Oracle service name for the database instance.

  11. Enter the GlassFish server username and password when prompted.

  12. Exit asadmin, and restart the GlassFish server for the changes to take effect.


Adding the Server to Enterprise Manager

This procedure adds the GlassFish server to Enterprise Manager so you can view the topics and queues. Make sure the GlassFish server is running before performing this procedure.

  1. Navigate to the Java CAPS home directory, and double click start_emanager.

  2. Once the startup process is complete, launch Enterprise Manager in a web browser. The URL is http://hostname:port.

    The default port is 15000.

  3. Enter the login information.

    The default user name and password are admin and adminadmin.

  4. If the Glassfish server is not already added to Enterprise Manager, do the following to add it:

    1. In the left navigation panel, click JavaEE.

      The Add Application Server page appears.

    2. Enter the host name, port number, user name, and password for the GlassFish server.

      The default port number is 4848, and the user name and password are those you specified during Java CAPS installation.

    3. Click Connect to Server.

      The domain appears in the Current Application Server List.

  5. In the left navigation panel, expand Servers and expand hostname:port.

  6. Verify that the Advanced Queue you added appears in the list under the server. It will appear as OracleAQ_CAPS_AQ.

  7. Click OracleAQ_CAPS_AQ and verify that its status is Up.

  8. You can click on the Topics and Queues tabs to view the topics and queues that were created earlier.


Configuring the Java CAPS Environment

This procedure configures the Java CAPS Environment so it is pointing to the correct servers, databases, and file locations.

  1. In the NetBeans Services window, expand CAPS Environments.

  2. Right-click EMEnvironment, point to Version Control, and then select Checkout. On the Version Control - Check Out window, click Check Out.

  3. Do the following to configure the Unified JMS Resource Adapter:

    1. Under EMEnvironment, expand LogicalHost1 and right-click Unified JMS Resource Adapter1.

    2. Point to Version Control, and then select Checkout. On the Version Control - Check Out window, click Check Out.

    3. Right-click Unified JMS Resource Adapter1, and select Properties.

      The Properties window appears.

    4. Click the ellipsis next to Connection URL and verify the host name, port number, and Oracle AQ database SID name are all correct.

      The Username and Password fields are populated with the values from the setup_jcapsem.sql script. Only modify these fields if you changed the user name and password in the script.

    5. Click OK.

  4. Do the following to configure the application server:

    1. Under EMEnvironment, expand LogicalHost1.

    2. Right-click SunJavaSystemApplicationServer1, point to Version Control, and then select Check Out. Click Check Out on the window that appears.

    3. Right-click SunJavaSystemApplicationServer1, and select Properties.

      The Properties window appears.

    4. In the navigation tree on the left, select Sun Java System Application Server Configuration.

    5. Verify the GlassFish application server URL and user name, and update if needed.

    6. Update the password with the one you entered when you installed Java CAPS. Click OK.

  5. Do the following to configure the File External System (optional):

    1. Under EMEnvironment, right-click esFile, and select Properties.

      The Properties window appears.

    2. In the navigation tree on the left, expand Inbound File eWay and select Parameter settings.

    3. Modify the location for the input file.

    4. Repeat the above steps for Outbound File eWay.


Deploying and Testing the Java CAPS Project

This procedure includes deploying the Java CAPS project to the GlassFish server. Before you begin, make sure the GlassFish server is running. You can start the server by right-clicking GlassFish v2.x under the Servers node in the NetBeans Services window.

Sample input files are provided so you can test and verify that the project is interacting with the database correctly and producing the correct output.

Deploying the prjEMTest Project

  1. On the NetBeans Projects window, right-click prjEMTest, point to New, and then select Deployment Profile.

  2. Enter a name for the profile, and for the Environment select EMEnvironment.

  3. Click OK.

  4. On the Deployment Profile Editor, click Automap.

    The connectivity components are automatically moved into the Environment containers.

  5. In the Deployment Profile Editor toolbar, click Build.

  6. After the build is complete, click Deploy.


Testing the prjEMTest Project

Before You Begin

Make sure your Enterprise Manager is running, and that it is connected to the application server as described in Adding the Server to Enterprise Manager.

  1. Do the following to test the queues:

    1. Navigate to the location where you extracted the sample ZIP file when you installed the sample projects, and then navigate to \jcapsem.

    2. Copy inputEMQ.txt to the C:\temp directory.

      Note: If you changed the directories for the File External System while configuring the Java CAPS Environment, move this file to the directory you entered instead.

    3. The file should be picked up and the messages processed through the queues you configured.

    4. In Enterprise Manager, expand JavaEE > Servers > hostname:port.

    5. Click OracleAQ_CAPS_AQ, and then click the Queues tab.

    6. Select JCAPSEM.QUEUE2 and verify that five messages appear in the Messages list.

    7. Select one of the messages and click the View/Edit icon to view information about the payload.

    8. Select one of the messages and click the Properties icon to view information about the message properties.

    9. Click the Select All icon and then click the Delete icon to delete all five messages.

  2. Do the following to test the topics:

    1. In Enterprise Manager, expand JavaEE > Servers > hostname:port.

    2. Click OracleAQ_CAPS_AQ, and then click the Topics tab.

    3. Do the following to verify and create the durable subscribers:

      1. Select JCAPSEM.TOPIC2.

      2. Click the Subscribers tab and then click Create a New Durable Subscriber.

      3. Enter a name for the subscriber and click OK.

    4. Navigate to the location where you extracted the sample ZIP file when you installed the sample projects, and then navigate to \jcapsem.

    5. Copy inputEMT.txt to the C:\temp directory.

      Note: If you changed the directories for the File External System while configuring the Java CAPS Environment, move this file to the directory you entered instead.

    6. The file should be picked up and the messages processed through the topics you configured.

    7. In Enterprise Manager, expand JavaEE > Servers > hostname:port.

    8. Click OracleAQ_CAPS_AQ, and then click the Topics tab.

    9. Select JCAPSEM.TOPIC2 and verify that five messages appear in the Messages list.

    10. Select one of the messages and click the View/Edit icon to view information about the payload.

    11. Select one of the messages and click the Properties icon to view information about the message properties.

    12. Click the Select All icon and then click the Delete icon to delete all five messages.


Working With Advanced Queueing in Enterprise Manager

From Enterprise Manager, you can view, edit, submit, and delete JMS messages in the Advanced Queueing topics and queues. You can also create durable subscribers for the topics you created, and create new topics and queues.

Before You Begin

Make sure your Enterprise Manager is running, and that it is connected to the application server as described in Adding the Server to Enterprise Manager.

  1. On Enterprise Manager, expand JavaEE > Servers > hostname:port.

  2. Click OracleAQ_CAPS_AQ, and then click the Topics tab.

  3. Select JCAPSEM.TOPIC1.

  4. To create a durable subscriber, click the Subscribers tab and then click Create a New Durable Subscriber. Enter a name for the subscriber and click OK.

  5. To delete the subscriber, select it in the list and click Delete.

  6. To submit a message to the topic make sure it has a durable subscriber, click the Messages tab, and then click the Send/Publish icon. Enter some text in the dialog that appears, and click Submit.

    The message appears in the message list under the topics.

  7. To create a new topic, click the Create a New Topic icon, enter a name for the topic in the dialog box that appears, and click OK.

    The new topic appears in the topic list.

  8. Click the Queues tab and then select JCAPSEM.QUEUE2.

  9. In the Messages area, click the Send/Publish icon, enter some text, and then click Submit.

    The message appears in the message list under the queues.

  10. To create a new queue, click the Create a New Queue icon, enter a name for the queue in the dialog box that appears, and click OK.

    The new queue appears in the queue list.