You are on page 1of 50

MantaRay

Deployment and
Integration Guide
Next Generation Distributed Messaging
Version 2.0 (DOC 2.0.0.)

Coridan Inc.
Copyright Notice 11 May 2006

Copyright Notice
Copyright © 2006 Coridan Inc.
All rights reserved.

This document contains proprietary information of Coridan Inc., and is provided under a
license agreement containing restrictions on use and disclosure and is also protected by
copyright law.
Due to continued product development this information may change without notice. The
information and intellectual property contained herein is confidential between Coridan
Inc. and the client and remains the exclusive property of Coridan Inc. If you find any
problems in the documentation, please report them to us in writing. Coridan does not
warrant that this document is error-free.
No part of this publication may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, electronic, mechanical, photocopying,
recording or otherwise without the prior written permission of Coridan.
Microsoft Word, Microsoft Office, Windows® and Windows XP® are trademarks of the
Microsoft Corporation. Java® is a trademark of the Sun Corporation. MantaRay® is a
registered trademark of Coridan Inc.

Coridan Inc.
Boston, MA, USA
+(866) 808-0322
Support E-Mail: (mailto:support@coridan.com)
Website: (http://www.coridan.com)

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) iii
11 May 2006

Table of Contents
Copyright Notice iii

Table of Contents iv

Preface v
About this Manual ........................................................................................................................................v
Audience............................................................................................................................................v
MantaRay Documentation.................................................................................................................v
Document Conventions ....................................................................................................................vi
About Coridan ........................................................................................................................................... vii
Worldwide Technical Support ................................................................................................................... vii
Feature Requests............................................................................................................................ viii
Bug Reports................................................................................................................................... viii
JBoss Versions 3.x and 4.x 1
JBoss Configuration Process ........................................................................................................................1
Specifying the Location of MantaRay Files ......................................................................................2
Registering MantaRay JMS objects in the JNDI Tree.......................................................................3
Configuring MantaRay as a Foreign JMS Provider...........................................................................4
Code Samples ...............................................................................................................................................6
Servlet Context Listener Class Sample Code ....................................................................................6
Web.xml Sample File ........................................................................................................................7
JBoss Startup Destination MBean Interface ......................................................................................7
JBoss Startup Destination MBean Implementation ...........................................................................8
WebLogic 8.1 11
WebLogic 8.1 Configuration Process .........................................................................................................11
Specifying the Location of MantaRay Files ....................................................................................11
Registering MantaRay JMS objects in the JNDI Tree.....................................................................13
Running the WebLogic Server ........................................................................................................14
Verifying the JNDI Tree..................................................................................................................14
Configuring MantaRay as a Foreign JMS Provider.........................................................................15
Code Samples .............................................................................................................................................19
Servlet Context Listener Class Sample Code ..................................................................................19
Web.xml Sample File ......................................................................................................................19
Config.xml Sample File...................................................................................................................20
Startup Class Sample Code..............................................................................................................21
WebLogic 9.x 23
WebLogic 9.x Configuration Process .........................................................................................................24
Specifying the Location of MantaRay Files ....................................................................................24
Running the WebLogic Server ........................................................................................................25
Registering MantaRay JMS objects in the JNDI Tree.....................................................................25
Configuring MantaRay as a Foreign JMS Provider.........................................................................30
Code Samples .............................................................................................................................................40
Servlet Context Listener Class Sample Code ..................................................................................40
Web.xml Sample File ......................................................................................................................41
Startup Class Sample Code..............................................................................................................42

iv Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


Preface 11 May 2006

Preface
In This Chapter
About this Manual .......................................................v
About Coridan .............................................................vii
Worldwide Technical Support .....................................vii

About this Manual


This guide presents techniques and procedures for deploying MantaRay messaging
solutions in enterprise environments. Incorporation into a variety of commercial business
integration and enterprise backbone solutions is the principal focus of this document.
These solutions include SOA and ESB based products.
Each chapter covers a specific product or product line. The material includes explanatory
text, step-by-step procedure and code samples for your use.

Audience
The Deployment and Integration guide is intended for use by developers, system
architects and integrators involved in the process of deploying enterprise infrastructure
solutions. The reader is expected to be familiar with Java programming, JMS and the
concepts of distributed enterprise environments.

MantaRay Documentation
Documentation for the MantaRay solutions consists of several user guides available in
PDF format. The Coridan web site (http://www.coridan.com) contains application
samples and a variety of other useful information.

Getting Started Guide


The Getting Started Guide provides a brief overview of the MantaRay peer-to-peer
messaging solution, along with step-by-step instructions for installation and basic
configuration. This volume also includes instructions for verifying and testing the
installation through the use of simple application samples.

Reference Guide
The Reference Guide contains a technical overview together with detailed
instructions and explanations regarding configuration parameters, options, advanced
features, and API documentation. This information is presented in a handy tabular
format designed for easy reference without the necessity of paging through a lengthy
book.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) v


11 May 2006 About this Manual

Document Conventions
The following table shows the typographic conventions used for this book.

Typeface Description
Terms Emphasizes specific terms and concepts, generally
when first introduced
Code Sample Code samples and configuration file text

Note Notes, tips, cautions and warnings

C ommand Commands or text to be entered


Parameter Parameter name
OPTION Menu or dialog option
The following table shows the icons that are used to draw attention to specific topics in
this book.

Icon Description
Tips - Tips, tricks, work-arounds and other good ideas to
help you work more efficiently

Caution - Pay careful attention to the instructions in order to


avoid errors or unexpected results

Warning - Failure to follow the instructions will result in an


error or system instability

Notes - Informative information

Java code sample

XML code segment or file

vi Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


Preface 11 May 2006

About Coridan
Coridan is a leading provider of peer-to-peer messaging middleware products that
provide cutting-edge alternatives to traditional messaging solutions. Located in Boston,
Massachusetts, USA and Herzliya, Israel, Coridan was founded in 2003.
The Coridan team includes high tech veterans with many years of experience in
developing world-class software products. Coridan is backed by leading institutional
venture capital firms that take a hands-on approach in nurturing promising high-tech
companies.

Worldwide Technical Support


At Coridan, we provide first class support for all of our products and technologies via
our web site (http://www.coridan.com). As an open source project, MantaRay benefits
from the support of thousands of developers worldwide who provide constant feedback,
inquiries, bug reports, fixes, work-arounds and feature requests. This information and
more is available at the MantaRay Project website
(http://sourceforge.net/projects/mantaray/).
You are invited to take advantage of our technical support facilities as described below:
ƒ E-mail support is available on a 24/7 basis
ƒ Demos (http://www.coridan.com) are available for download from our web site
ƒ A help forum (http://sourceforge.net/forum/?group_id=112623) is available at the
MantaRay Project site at SourceForge
ƒ MantaRay developer blogs are available on our web site
ƒ Sign up for our e-mail list to receive up-to-date information regarding new releases,
bug fixes, upcoming events, seminars, webinars, etc.
When contacting technical support, please supply the following information, when
possible:
ƒ Your name and contact information
ƒ Your company or organization
ƒ Product version number and build
ƒ Platform and operating system information:
- Hardware description
- Operating system and version
- Available memory
- Description of messaging scenario and requirements
- Firewalls and other network security software
ƒ Problem description and any documentation that may help in resolving the problem,
such as log files and descriptions of the testing scenario

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) vii
11 May 2006 Worldwide Technical Support

Feature Requests
If you have a feature request, please submit it at
MantaRay: Feature Requests: Submit Tracker Item
(https://sourceforge.net/tracker/?func=add&group_id=112623&atid=663826).

Bug Reports
Submit a bug report on the
MantaRay: Bugs: Submit Tracker Item
(http://sourceforge.net/tracker/?func=add&group_id=112623&atid=663823)
page at SourceForge.net.
When submitting a bug report, please supply the information requested above for
technical support.

viii Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide
JBoss Versions 3.x and 4.x 11 May 2006

1
JBoss Versions 3.x and 4.x
In This Chapter
JBoss Configuration Process .......................................1
Code Samples ..............................................................6
This chapter presents the procedures for configuring JBoss Application Server versions
3.x and 4.x.so that MantaRay functions as a foreign JMS provider in this environment.
The explanations and procedures contained in this chapter assume that you have
successfully installed, configured and integrated JBoss Application Server into your IT
environment and that you are familiar with its operational concepts and procedures. For
further information, please refer to the JBoss documentation.
This chapter further assumes that you have successfully installed and configured
MantaRay on the Application Server peer(s) and any client peers requiring MantaRay
messaging capability. For details and instructions regarding installing and configuring
MantaRay, please refer to the MantaRay Getting Started and Reference Guides.
Notes: The following text expressions, appearing in this chapter, refer to specific file
locations in instructions and code samples as specified below. When following the
instructions or writing code, you should substitute the actual locations for these
expressions.
JBOSS_HOME refers to the fully qualified path to the folder in which the JBoss Server
files are located.
MANTA_HOME refers to the fully qualified path to the MantaRay installation folder.

JBoss Configuration Process


The JBoss configuration process consists of three sequential procedures:
1 Specifying the location of MantaRay files
2 Registering MantaRay JMS objects in the JNDI tree
3 Configuring MantaRay as a Foreign JMS Provider
Each of these steps is described in detail in the following sections.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 1


11 May 2006 JBoss Configuration Process

Specifying the Location of MantaRay Files


In order for JBoss to work with MantaRay, you need to specify the location of the
MantaRay JAR files and the MantaRay configuration file.

MantaRay JAR Files


To specify the location of the MantaRay JAR files, perform either of the following
steps:
ƒ Copy the Manta.jar and all jar files from the Manta/ext folder into the
JBOSS_HOME\server\default\lib folder.
ƒ Manually add the MantaRay class path to the JBoss startup script (run.bat for
Windows or run.sh for Unix/Linux), located under the JBOSS_HOME\bin
folder.
JAR files (add other relevant JAR files as required)
set MANTA_PATH="%MANTA_HOME%\\antlr.jar;
%MANTA_HOME%\manta.jar;
%MANTA_HOME%\ext\clink-1.5.0.jar;
%MANTA_HOME%\ext\commons-logging.jar;
%MANTA_HOME%\ext\jms.jar;
%MANTA_HOME%\ext\log4j-1.2.8.jar;
%MANTA_HOME%\ext\jmxri.jar;
%MANTA_HOME%\ext\jmxremote.jar;
%MANTA_HOME%\ext\jmxtools.jar;"

MANTA_PATH
set JBOSS_CLASSPATH = %JBOSS_CLASSPATH%;%MANTA_PATH%

The mantaConfig JVM property


The mantaConfig property is a required JVM parameter that specifies the location of the
MantaRay configuration file. To set the mantaConfig property, perform any one of the
following steps:
ƒ Specify the path to the MantaRay configuration files in the Servlet context listener
code.
ƒ Specify the path to the MantaRay configuration files in the JBoss specific startup
class code.
ƒ Specify the path to the MantaRay configuration files in the JBoss startup script
(run. bat for Windows or run .sh for Unix/Linux), located under the
JBOSS_HOME\bin folder. Add the following line:
Set JAVA_OPTS=%JAVA_OPTS% -
DmantaConfig=%MANTA_CONFIG\config\default_config.xml

2 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


JBoss Versions 3.x and 4.x 11 May 2006

Registering MantaRay JMS objects in the JNDI Tree


You must register the MantaRay JMS objects (ConnectionFactories, Queues, and
Topics) in the server JNDI tree.
There are two methods for registering the MantaRay JMS objects into the JNDI tree:
ƒ Register objects at startup by using a Servlet context listener. This is the standard
(and preferred) method, which works well with any J2EE compliant server without
the need for any server-specific API.
ƒ Register objects using a JBoss startup class.
The following procedures describe both methods.

To Deploy a Startup Class Using a Servlet Context Listener


1 Create a Servlet context listener class (See "Servlet Context Listener Class Sample
Code" page 6).
2 Create a web.xml (See "Web.xml Sample File" page 7) file that refers to the listener
class.
3 Pack the class and the web.xml file into a WAR file with the following basic
structure:
WEB-INF/ - folder for application support
lib/ - folder for supporting jar files
classes/ - folder for compiled java files
web.xml - configuration file for the application

4 Move the WAR file to the JBOSS_HOME\server\default\deploy folder.


To Register MantaRay Objects Using a JBoss Startup Class
1 Create a startup MBean that holds the MantaRay destinations and binds them into
the JNDI tree. The MBean is comprised of two files, the MBean interface (See
"JBoss Startup Destination MBean Interface" page 7) and the MBean
implementation (See "JBoss Startup Destination MBean Implementation" page 8).
2 Generate a JBoss SAR file:
a Compile the MantaRay startup class and interface.
b Create a jboss-service.xml file in the META-INF folder, containing the
following lines:
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="MantaStartup"
name="JBoss.manta:service=MantaStartup"/>
</server>

c Pack the compiled class and interface with the jboss-service.xml file into
a JAR file (for example, manta-startup.jar) with the following basic
structure:
META-INF
jboss-service.xml
MantaStartupMBean.class
MantaStartup.class
d Change the file extension from .jar to.sar (for example, manta-
startup.sar).
3 Move the SAR file to the JBOSS_HOME\server\default\deploy folder.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 3


11 May 2006 JBoss Configuration Process

Configuring MantaRay as a Foreign JMS Provider


Once you have completed registering the MantaRay JMS objects in the JNDI tree, you
can use MantaRay as a JMS server using a regular JMS client in either environment.
However, in order to consume JMS messages more efficiently, you should also register
MantaRay as a foreign JMS provider in JBoss.
To register the MantaRay JMS server as a Foreign JMS provider:
1 Set the RecursiveSearch attribute to 'T r u e ' in the, located in the
JBOSS_HOME\server\default\conf folder.
<attribute name="RecursiveSearch">True</attribute>

2 Insert the following code into the < invoker-proxy-bindings> tag in the
jboss-service.xml file:
<invoker-proxy-binding>
<name>Manta-message-driven-bean</name>
<invoker-mbean>
JBoss.mq:service=JMSProviderLoader,name=MantaJMSProvider
</invoker-mbean>
<proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker
</proxy-factory>
<proxy-factory-config>
<JMSProviderAdapterJNDI>MantaMQ</JMSProviderAdapterJNDI>
<ServerSessionPoolFactoryJNDI>StdJMSPool
</ServerSessionPoolFactoryJNDI>
<MinimumSize>1</MinimumSize>
<KeepAliveMillis>30000</KeepAliveMillis>
<MaximumSize>15</MaximumSize>
<MaxMessages>1</MaxMessages>
<MDBConfig>
<ReconnectIntervalSec>10</ReconnectIntervalSec>
<DLQConfig>
<DestinationQueue>queue/DLQ</DestinationQueue>
<MaxTimesRedelivered>10</MaxTimesRedelivered>
<TimeToLive>0</TimeToLive>
</DLQConfig>
</MDBConfig>
</proxy-factory-config>
</invoker-proxy-binding>

3 Insert the following code into the < container-configurations> tag:

4 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


JBoss Versions 3.x and 4.x 11 May 2006

<container-configuration>
<container-name>Manta MDB support</container-name>
<call-logging>true</call-logging>
<invoker-proxy-binding-name>Manta-message-driven-bean
</invoker-proxy-binding-name>
<container-interceptors>

<interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor
</interceptor>

<interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.RunAsSecurityInterceptor
</interceptor>
<!-- CMT -->
<interceptor transaction="Container">
org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
<interceptor transaction="Container" metricsEnabled="true">
org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
<interceptor transaction="Container">
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor
</interceptor>
<!-- BMT -->
<interceptor transaction="Bean">
org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor
</interceptor>
<interceptor transaction="Bean">
org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT
</interceptor>
<interceptor transaction="Bean" metricsEnabled="true">
org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
<interceptor>

org.jboss.resource.connectionmanager.CachedConnectionInterceptor
</interceptor>
</container-interceptors>
<instance-pool>
org.jboss.ejb.plugins.MessageDrivenInstancePool
</instance-pool>
<instance-cache></instance-cache>
<persistence-manager></persistence-manager>
<container-pool-conf>
<MaximumSize>100</MaximumSize>
</container-pool-conf>
</container-configuration>

4 Add the following MBean descriptor to the jms-ds.xml file, located in the
JBOSS_HOME\server\default\deploy\jms folder. This code should be
nested in the <connection-factories> tag.
<!-- The JMS provider loader -->
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="JBoss.mq:service=JMSProviderLoader,name=MantaJMSProvider">
<attribute name="ProviderName">MantaMQ</attribute>
<attribute name="ProviderAdapterClass">
org.jboss.jms.jndi.JNDIProviderAdapter
</attribute>
<attribute name="QueueFactoryRef">mantaQCF</attribute>
<attribute name="TopicFactoryRef">mantaTCF</attribute>
</mbean>

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 5


11 May 2006 Code Samples

Code Samples
This section presents several examples of code that illustrate the concepts and
configuration procedures. Explanatory notes are appended to some of the samples.

Servlet Context Listener Class Sample Code


package com.manta.sample.startup

import org.mr.api.jms.*;
import javax.jms.*;
import javax.naming.InitialContext;
import javax.naming.InitialContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class MantaStartup implements ServletContextListener {


public MantaStartup() {super();}
public void contextInitialized(ServletContextEvent sce) {
try {
//create connection factory objects
QueueConnectionFactory qFactory =
new MantaQueueConnectionFactory();
TopicConnectionFactory tFactory =
new MantaTopicConnectionFactory();
//initiate JNDI context
//bind the connection factorie objects to the
//JNDI tree
context.bind("mantaQCF", qFactory);
System.out.println("bind mantaQCF");
context.bind("mantaTCF", tFactory);
System.out.println("bind mantaTCF");
TopicConnection tcon =
tFactory.createTopicConnection();
QueueConnection qcon =
qFactory.createQueueConnection();
QueueSession qsess = qcon.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSession tsess = tcon.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
//bind topic to the JNDI tree
String tName = new String("SampleTopic1");
Topic tryT = tsess.createTopic(tName);
context.bind(tName, tryT);
//bind topic to the JNDI tree
String qName = new String("SampleQueue1");
Queue tryQ = qsess.createQueue(qName);
context.bind(qName, tryQ);
System.out.println("finished binding");
context.close();
tcon.close();
qcon.close();
}catch (Exception e) { e.printStackTrace();}
}
public void contextDestroyed(ServletContextEvent sce) {}

Code Sample Notes


ƒ Modify JMS destinations as required by your applications.
ƒ The MantaRayQueueConnectionFactory and
MantaRayTopicConnectionFactory bindings are mandatory.
ƒ We recommend that you use a configuration file to load destinations and connection
factories in your code. This example uses hard-coded values for demonstration
purposes only

6 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


JBoss Versions 3.x and 4.x 11 May 2006

Web.xml Sample File


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>
com.manta.sample.startup.MantaStartup
</listener-class>
</listener>
</web-app>

JBoss Startup Destination MBean Interface


public interface MantaStartupMBean {
public abstract void init() throws Exception;
public abstract void start() throws Exception;
public abstract void stop() throws Exception;
public abstract void destroy() throws Exception;
}

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 7


11 May 2006 Code Samples

JBoss Startup Destination MBean Implementation


import org.jboss.util.*;
import javax.management.*;
import org.mr.api.jms.*;
import javax.naming.*;
import javax.jms.*;
public class MantaStartup implements MBeanRegistration,
MantaStartupMBean {
public MantaStartup() {}
public ObjectName preRegister(MBeanServer server, ObjectName
name)
throws java.lang.Exception {
return new ObjectName(":service=MantaStartup");
}
public void postRegister(java.lang.Boolean registrationDone){
}
public void preDeregister() throws java.lang.Exception {}
public void postDeregister() {}
public void init() throws Exception {}
public void start() throws Exception {
try {
//create connection factory objects
QueueConnectionFactory qfactory =
new MantaQueueConnectionFactory();
TopicConnectionFactory tFactory =
new MantaTopicConnectionFactory();
ConnectionFactory mfactory =
new MantaConnectionFactory();
//initiate JNDI context
InitialContext context = new InitialContext();
//bind the connection factorie objects to the
//JNDI tree
context.bind("mantaCF", mfactory);
System.out.println("bind mantaCF");
context.bind("mantaQCF", qfactory);
System.out.println("bind mantaQCF");
context.bind("mantaTCF", tFactory);
System.out.println("bind mantaTCF");
TopicConnection tcon =
tFactory.createTopicConnection();
QueueConnection qcon =
qfactory.createQueueConnection();
QueueSession qsess = qcon.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSession tsess = tcon.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
//bind topic to the JNDI tree
String tName = new String("SampleTopic1");
Topic tryT = tsess.createTopic(tName);
context.bind(tName, tryT);
//bind topic to the JNDI tree
String qName = new String("SampleQueue1");
Queue tryQ = qsess.createQueue(qName);
context.bind(qName, tryQ);
System.out.println("finished binding");
context.close();
tcon.close();
qcon.close();
} catch (Exception e) { e.printStackTrace();}
}
public void stop() throws Exception {
//write custom code here to do implement any cleanup functionality
}
public void destroy() throws Exception {}
}

8 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


JBoss Versions 3.x and 4.x 11 May 2006

Code Sample Notes


ƒ Modify destinations as required by your applications.
ƒ The MantaRayQueueConnectionFactory and
MantaRayTopicConnectionFactory bindings are mandatory.
ƒ We recommend that you use a configuration file to load destinations and connection
factories. This example uses hard-coded values for demonstration purposes only.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 9


WebLogic 8.1 11 May 2006

2
WebLogic 8.1
In This Chapter
WebLogic 8.1 Configuration Process..........................11
Code Samples ..............................................................19
This chapter presents the procedures for configuring WebLogic version 8.1 so that
MantaRay functions as a foreign JMS provider in this environment. The explanations
and procedures contained in this chapter assume that you have successfully installed,
configured and integrated WebLogic into your IT environment and that you are familiar
with its operational concepts and procedures. For further information, please refer to the
WebLogic documentation.
The data displayed in the screen captures is for example purposes only. You should
define object names and attributes for your environment according to your specific
requirements.
This chapter further assumes that you have successfully installed and configured
MantaRay on the server peer(s) and any client peers requiring MantaRay messaging
capability. For details and instructions regarding installing and configuring MantaRay,
please refer to the MantaRay Getting Started and Reference Guides.
Notes: The following text expression, appearing in this chapter, refers to a specific file
location in instructions and code samples as specified below. When following the
instructions or writing code, you should substitute the actual location for this expression.
MANTA_HOME refers to the fully qualified path to the MantaRay installation folder.

WebLogic 8.1 Configuration Process


The WebLogic configuration process consists of three sequential procedures:
1 Specifying the location of MantaRay files
2 Registering MantaRay JMS objects in the JNDI tree
3 Configuring MantaRay as a Foreign JMS Provider
Each of these steps is described in detail in the following sections.

Specifying the Location of MantaRay Files


In order for WebLogic to work properly with MantaRay, you need to specify the location
of the MantaRay JAR files and the MantaRay configuration file.
To configure WebLogic to locate the MantaRay JAR files:
1 Manually add the MantaRay class path to the startWebLogic.cmd (Windows)
or startWebLogic.sh (Unix/Linux) file. Add any additional lines that may be
required in your environment.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 11


11 May 2006 WebLogic 8.1 Configuration Process

set MANTA_PATH="%MANTA_HOME%\ext\antlr.jar;
%MANTA_HOME%\manta.jar;
%MANTA_HOME%\ext\clink-1.5.0.jar;
%MANTA_HOME%\ext\commons-logging.jar;
%MANTA_HOME%\ext\jms.jar;
%MANTA_HOME%\ext\log4j-1.2.8.jar;
%MANTA_HOME%\ext\jmxri.jar;
%MANTA_HOME%\ext\jmxremote-jmx.jar;
%MANTA_HOME%\ext\jmxtools.jar;"

2 Add the MANTA_PATH to the class path.


set CLASSPATH= %CLASSPATH%; %MANTA_PATH%

Warning: Make certain that the %CLASSPATH% parameter precedes the


%MANTA_PATH% parameter exactly as shown above. The order of these two
parameters is critical.

The mantaConfig JVM Property


The mantaConfig property is a required JVM parameter that specifies the location of the
MantaRay configuration file. To set the mantaConfig property, perform any one of the
following steps:
ƒ Specify the path to the MantaRay configuration files in the Servlet context listener
code.
ƒ Specify the path to the MantaRay configuration files in the WebLogic specific
startup class code.
ƒ Specify the path to the MantaRay configuration files in the WebLogic startup script
file (startWebLogic.cmd for Windows or startWebLogic.sh for
Unix/Linux).
%JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS%
-DmantaConfig=”MANTA_HOME/config/default_confgi.xml”
-Dweblogic.Name=%SERVER_NAME%
-Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE%
-Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy"
weblogic.Server

12 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 8.1 11 May 2006

Registering MantaRay JMS objects in the JNDI Tree


You must register the MantaRay JMS objects (ConnectionFactories, Queues, and
Topics) in the server JNDI tree.
There are two methods for registering the MantaRay JMS objects into the JNDI:
ƒ Register objects at startup by using a Servlet context listener. This is the standard
(and preferred) method, which works well with any J2EE compliant server without
the need for any server-specific API.
ƒ Register objects using a WebLogic startup class. The details of how to do this is
beyond the scope of this document, however a sample WebLogic startup class (page
21) is provided for your convenience.
Using a Servlet Context Listener
1 Create a Servlet context listener class (See "Servlet Context Listener Class Sample
Code" page 6).
2 Create a web.xml (See "Web.xml Sample File" page 7) file that refers to the listener
class.
3 Pack the class and the web.xml file into a WAR file with the following basic
structure:
WEB-INF/ - folder for application support
classes/ - folder for compiled java files
web.xml - configuration file for the application

4 Move the WAR file to the %WL_HOME%%WL_DOMAIN%\applications folder.


Notes:
WL_HOME refers to the fully qualified path to the folder in which the WebLogic server
files are installed.
WL_DOMAIN refers to the relative path (from WL_HOME) to the folder in which the
WebLogic domain is located.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 13


11 May 2006 WebLogic 8.1 Configuration Process

Running the WebLogic Server


1 Navigate to the WebLogic console using a URL in the form: http://<ip
address or hostname>:<port>/console.
For example, http://localhost:7001/console.
2 Log in to the console. The WebLogic Console window appears in your browser.

Verifying the JNDI Tree


After you finish registering MantaRay JMS objects in the server JNDI tree, we
recommend that you perform the following procedure to verify that they have been
correctly registered. This process involves viewing the JNDI tree in the WebLogic
console.
1 Open and login to WebLogic Server Console using your web browser.
2 From the WebLogic console window, right-click on the desired server, which is
located under the Servers branch of the desired domain (m yD omain in the below
example) in the JNDI Tree (left-hand) pane. Myserver is the WebLogic default
server name, as shown in the example below. You will likely have defined your own
server names for your network.

3 From the shortcut menu, select View JNDI tree. The JNDI Tree window
appears in a separate window.

4 Browse the tree to verify the presence of the appropriate MantaRay


connectionFactories and destinations. To view details of an object on the tree, click
on the desired object. The object details appear in the right-hand pane, as shown in
the above example.

14 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 8.1 11 May 2006

Configuring MantaRay as a Foreign JMS Provider


Once you have completed registering the MantaRay JMS objects in the JNDI tree, you
can use MantaRay as a JMS server using a regular JMS client in either environment.
However, in order to consume JMS messages more efficiently, you should also register
MantaRay as a foreign JMS provider in WebLogic.
Registering MantaRay as a foreign JMS provider is a three stage process. You perform
the configuration tasks in the JMS branch in WebLogic Navigation Tree, located in the
left-hand pane of the browser window.
1. Create a Foreign JMS Server.
The Foreign JMS Server branch contains information about the local and/or
remote JNDI provider, including its initial context factory, URL, and
additional parameters. It is the parent of the Foreign JMS ConnectionFactory
and Foreign JMS Destination nodes.
2. Create Foreign JMS ConnectionFactories.
Each node represents one foreign ConnectionFactory. The node contains the
name of the ConnectionFactory in the remote JNDI provider, the name to
map it to in the server’s JNDI tree, and, optionally, a user name and
password.
3. Create Foreign JMS Destinations.
Each node represents a foreign JMS Destination. It contains the name to
look up on the foreign JNDI provider (MantaRay JMS destinations), and the
name to map it to on the local server.
Note: You can also define a foreign JMS provider by editing the config.xml (page 20)
file located in the %WL_HOME%%WL_DOMAIN% folder as an alternative to using the
WebLogic Console.

Creating the Foreign JMS Server


To create a Foreign JMS Server, perform the following steps:
1 Open and login to WebLogic Server Console using your web browser.
2 In the Navigation Tree, click to select the <DomainName> | Services |
JMS | Foreign JMS Servers node. The Foreign JMS Servers console
page appears in the right-hand pane.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 15


11 May 2006 WebLogic 8.1 Configuration Process

3 Click the Configure a new Foreign JMS Server link. The definition
console page appears in the right-hand pane.

4 Enter a name for the foreign JMS server in the Name field (for example,
'm a nt aF o rei gn ').
5 Enter the class that must be instantiated to access the JNDI provider in the JNDI
Initial Context Factory field. The default value
'w ebl ogi c.jn di. WL In it ialC ont ext F act ory ' appears automatically.
6 Enter a URL in the JNDI Connection URL field (for example,
t 3: //l ocalh ost: 7001 ).
7 Click the Create button to finish. The newly created foreign JMS server appears as
a node in the Navigation Tree.

16 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 8.1 11 May 2006

Creating Foreign Connection Factories


To create new foreign JMS ConnectionFactories, perform the following steps:
1 Click the Configure Foreign JMS Connection Factories link in the
Foreign JMS Connection console page. The Create a new Foreign
JMS ConnectionFactory console page appears in the right-hand pane.

2 Enter the name that the remote object is bound to in the local server JNDI directory
in the Local JNDI Name field.
3 Enter the name of the remote object that will be looked up in the remote JNDI
directory in the Remote JNDI Name field.
4 Enter a user name and password in the appropriate fields as required.
5 Click Create to complete the definition. The new ConnectionFactory appears as a
node under the Foreign JMS ConnectionFactories node in the
Navigation Tree.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 17


11 May 2006 WebLogic 8.1 Configuration Process

Creating Foreign JMS Destinations


To create new foreign JMS destinations, perform the following steps:
1 Click the Configure Foreign JMS Destinations link in the Foreign
JMS Connection console page. The Create a new Foreign JMS
Destination console page appears.

2 Enter the name that the remote object is bound to in the local server JNDI directory
in the Local JNDI Name field.
3 Enter the name of the remote object that will be looked up in the remote JNDI
directory in the Remote JNDI Name field.
4 Click Create to complete the definition. The new destination appears as a node
under the Foreign JMS Destination node in the Navigation Tree.
Once deployed, foreign JMS MBeans create objects in the local server JNDI tree, which
then performs a lookup of the referenced JMS objects whenever the foreign MBeans are
looked up. This means that the local server and the remote JNDI folder are always
synchronized.

18 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 8.1 11 May 2006

Code Samples
This section presents several examples of code that illustrate the concepts and
configuration procedures. Explanatory notes are appended to some of the samples.

Servlet Context Listener Class Sample Code


package com.manta.sample.startup

import org.mr.api.jms.*;
import javax.jms.*;
import javax.naming.InitialContext;
import javax.naming.InitialContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class MantaStartup implements ServletContextListener {


public MantaStartup() {super();}
public void contextInitialized(ServletContextEvent sce) {
try {
//create connection factory objects
QueueConnectionFactory qFactory =
new MantaQueueConnectionFactory();
TopicConnectionFactory tFactory =
new MantaTopicConnectionFactory();
//initiate JNDI context
//bind the connection factorie objects to the
//JNDI tree
context.bind("mantaQCF", qFactory);
System.out.println("bind mantaQCF");
context.bind("mantaTCF", tFactory);
System.out.println("bind mantaTCF");
TopicConnection tcon =
tFactory.createTopicConnection();
QueueConnection qcon =
qFactory.createQueueConnection();
QueueSession qsess = qcon.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSession tsess = tcon.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
//bind topic to the JNDI tree
String tName = new String("SampleTopic1");
Topic tryT = tsess.createTopic(tName);
context.bind(tName, tryT);
//bind topic to the JNDI tree
String qName = new String("SampleQueue1");
Queue tryQ = qsess.createQueue(qName);
context.bind(qName, tryQ);
System.out.println("finished binding");
context.close();
tcon.close();
qcon.close();
}catch (Exception e) { e.printStackTrace();}
}
public void contextDestroyed(ServletContextEvent sce) {}

Web.xml Sample File


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>
com.manta.sample.startup.MantaStartup
</listener-class>
</listener>
</web-app>

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 19


11 May 2006 Code Samples

Config.xml Sample File


<ForeignJMSServer ConnectionURL="t3://localhost:7001"
JNDIProperties="" Name="mantaForeign"
Targets="myserver">
<ForeignJMSConnectionFactory
LocalJNDIName="local/mantaQCF"
Name="qConFactory" RemoteJNDIName="mantaQCF"/>
<ForeignJMSConnectionFactory
LocalJNDIName="local/mantaTCF"
Name="tConFactory" RemoteJNDIName="mantaTCF"/>
<ForeignJMSDestination
LocalJNDIName="local/SampleTopic1"
Name="mantaTopic1"
RemoteJNDIName="SampleTopic1"/>
<ForeignJMSDestination
LocalJNDIName="local/SampleQueue1"
Name="mantaQueue1"
RemoteJNDIName="SampleQueue1"/>
</ForeignJMSServer>

Note: We recommend that you do not change the above config.xml file unless you know
what you are doing.

20 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 8.1 11 May 2006

Startup Class Sample Code


package com.manta.sample.startup;
import org.mr.api.jms.*;
import javax.jms.*;
import javax.naming.InitialContext;
public class MantaBinder {
public static void main(String[] args){
try {
//the follwing line is needed if the system property
//is not set in the setDomainEnv files
//System.setProperty("mantaConfig",
// "C:/MantaHome/config/default_config.xml");
//create connection factory objects
QueueConnectionFactory qFactory =
new MantaQueueConnectionFactory();
TopicConnectionFactory tFactory =
new MantaTopicConnectionFactory();
//initiate JNDI context
InitialContext context = new InitialContext();
//bind the connection factorie objects to the
//JNDI tree
context.bind("mantaQCF", qFactory);
System.out.println("bind mantaQCF");
context.bind("mantaTCF", tFactory);
System.out.println("bind mantaTCF");
TopicConnection tcon =
tFactory.createTopicConnection();
QueueConnection qcon =
qFactory.createQueueConnection();
QueueSession qsess = qcon.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSession tsess = tcon.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
//bind topic to the JNDI tree
String tName = new String("SampleTopic1");
Topic tryT = tsess.createTopic(tName);
context.bind(tName, tryT);
//bind topic to the JNDI tree
String qName = new String("SampleQueue1");
Queue tryQ = qsess.createQueue(qName);
context.bind(qName, tryQ);
System.out.println("finished binding");
context.close();
tcon.close();
qcon.close();
} catch (Exception e) { e.printStackTrace();}
}
}

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 21


WebLogic 9.x 11 May 2006

3
WebLogic 9.x
In This Chapter
WebLogic 9.x Configuration Process..........................24
Code Samples ..............................................................40
This chapter presents the procedures for configuring WebLogic version 9.x so that
MantaRay functions as a foreign JMS provider in this environment. The explanations
and procedures contained in this chapter assume that you have successfully installed,
configured and integrated WebLogic into your IT environment and that you are familiar
with its operational concepts and procedures. For further information, please refer to the
WebLogic documentation.
The data displayed in the screen captures is for example purposes only. You should
define object names and attributes for your environment according to your specific
requirements.
This chapter further assumes that you have successfully installed and configured
MantaRay on the server peer(s) and any client peers requiring MantaRay messaging
capability. For details and instructions regarding installing and configuring MantaRay,
please refer to the MantaRay Getting Started and Reference Guides.
Note: Whenever you make changes to the WebLogic configuration using the WebLogic
console, you must click Lock & Edit before you begin, and Activate Changes after all
changes have been made.

Notes: The following text expressions, appearing in this chapter, refer to specific file
locations in instructions and code samples as specified below. When following the
instructions or writing code, you should substitute the actual locations for these
expressions.
MANTA_HOME refers to the fully qualified path to the MantaRay installation folder.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 23


11 May 2006 WebLogic 9.x Configuration Process

WebLogic 9.x Configuration Process


The WebLogic configuration process consists of three sequential procedures:
1 Specifying the location of the MantaRay JAR files and the MantaRay configuration
file.
2 Registering MantaRay JMS objects in the JNDI tree.
3 Registering MantaRay as a WebLogic foreign JMS provider.
Each of these steps is described in detail in the following sections.

Specifying the Location of MantaRay Files


In order for WebLogic to work with MantaRay, you need to specify the location of the
MantaRay JAR files and the MantaRay configuration file.
1 Add the following line to the setDomainEnv.cmd (Windows) or the
setDomainEnv.sh (Unix/Linux) file, located in the
usersProjects/domain name/bin directory. Add any additional lines that
may be required in your environment.
set MANTA_PATH="%MANTA_HOME%\ext\antlr.jar;
%MANTA_HOME%\manta.jar;
%MANTA_HOME%\ext\clink-1.5.0.jar;
%MANTA_HOME%\ext\commons-logging.jar;
%MANTA_HOME%\ext\jms.jar;
%MANTA_HOME%\ext\log4j-1.2.8.jar;
%MANTA_HOME%\ext\jmxri.jar;
%MANTA_HOME%\ext\jmxremote-jmx.jar;
%MANTA_HOME%\ext\jmxtools.jar;"

2 Add the MANTA_PATH to the class path.


set PRE_CLASSPATH= %MANTA_PATH%

The mantaConfig JVM Property


The mantaConfig property is a required JVM parameter that specifies the location of the
MantaRay configuration file. To set the mantaConfig property, perform any one of the
following steps:
ƒ Specify the path to the MantaRay configuration files in the Servlet context listener
code.
ƒ Specify the path to the MantaRay configuration files in the WebLogic specific
startup class code.
ƒ Specify the path to the MantaRay configuration files in the WebLogic script file
(setDomainEnv.cmd for Windows or setDomainEnv.sh for Unix/Linux).
An example might read as follows:
'JAVA_PROPERTIES=-DmantaConfig=
C:\MantaRay_1.9_bin\config\default_config.xml'.

24 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

Running the WebLogic Server


1 Navigate to the WebLogic console using a URL in the form: http://<ip
address or hostname>:<port>/console.
For example, http://localhost:7001/console.
2 Log in to the console. The WebLogic Console window appears in your browser.

Registering MantaRay JMS objects in the JNDI Tree


You must register the MantaRay JMS objects (ConnectionFactories, Queues, and
Topics) in the server JNDI tree.
There are two methods for registering the MantaRay JMS objects into the JNDI:
ƒ Register objects at startup by using a Servlet context listener. This is the standard
(and preferred) method, which works well with any J2EE compliant server without
the need for any server-specific API.
ƒ Register objects using a WebLogic startup class.
Using a Servlet Context Listener
1 Create a Servlet context listener class (page 6).
2 Create a web.xml file that refers to the listener class.
3 Pack the class and the web.xml (page 7) file into a WAR file with the following
basic structure:
WEB-INF/ - folder for application support
classes/ - folder for compiled java files
web.xml - configuration file for the application

4 Move the WAR file to the %WL_HOME%%WL_DOMAIN%\autodeploy folder.


Notes:
WL_HOME refers to the fully qualified path to the folder in which the WebLogic server
files are installed.
WL_DOMAIN refers to the relative path (from WL_HOME) to the folder in which the
WebLogic domain is located.

Using a WebLogic Startup Class


The procedure for using a WebLogic startup class to register MantaRay JMS in the JNDI
is comprised of several processes that are presented in the following sections.
Creating the Startup Class
The first step is to create and compile the WebLogic startup class. A sample startup class
(page 21) is provided for your convenience.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 25


11 May 2006 WebLogic 9.x Configuration Process

Registering the Startup Class


1 Open and login to WebLogic Server Console using your web browser.

2 Click Lock & Edit in the Change Center section, located in the upper left-
hand side of the window.
3 In the Domain Structure tree (located in the center left-hand pane in the above
screen capture), open the Environment node and then click on the Startup &
Shutdown Classes node. The Summary of Startup and Shutdown
Classes console page appears in the right-hand pane.

4 Click the New button in the lower left-hand corner of the page.

26 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

5 Select the Startup Class option button in the console page that appears, and
then click Next to continue.

6 The Configure a New Startup or Shutdown Class console page


appears. Enter a name for the startup class in the Name field.
7 Enter the fully qualified class name in the Class Name field. This must agree with
path in your startup class code (For example, c om .m ant a. samp l e.s t artu p as
in the sample startup class). Click Next to continue.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 27


11 May 2006 WebLogic 9.x Configuration Process

Note: Make certain that the startup class is added to the WebLogic class The Configure
a New Startup or Shutdown Class console page appears. Select Startup
Class and then click Next.

8 Click the Activate Changes button in the upper-left hand corner of the browser
window.
9 Restart WebLogic Server.

28 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

Verifying JNDI Entries


1 Open and login to WebLogic Administrative Console using your web browser.
2 Select Environment | Servers from the Domain Structure tree. The
Summary of Servers console page appears.

3 Click to the name of the desired server. Do not select the check box. The
Settings for AdminServer console page appears.
4 Click the View JNDI Tree link, located in the upper left-hand corner of this
page. A new browser window opens, showing the domain structure.

5 Navigate the Domain Structure tree to display details of the JNDI structure, as
shown in the following sample screen capture. Verify that the JNDI information is
correct.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 29


11 May 2006 WebLogic 9.x Configuration Process

Configuring MantaRay as a Foreign JMS Provider


Once you have completed registering the MantaRay JMS objects in the JNDI tree, you
can use MantaRay as a JMS server using a regular JMS client in either environment.
However, in order to consume JMS messages more efficiently, you should also register
MantaRay as a foreign JMS provider in WebLogic.

Creating a JMS Module


1 Open and login to WebLogic Administrative Console using your web browser.
2 Click Lock & Edit in the Change Center section, located in the upper left-
hand side of the window.
3 Select Services | Messaging | JMS Modules from the Domain
Structure tree. The JMS Modules console page appears in the right-hand
pane. Click New to continue.

30 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

4 Enter a name for the JMS provider in the Name field (for example: 'm an t a ra y ').
The remaining two fields are optional. Click Next to continue.

5 Select the check box for the desired target server in the Targets section. Click
Next to continue.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 31


11 May 2006 WebLogic 9.x Configuration Process

6 Select the Would you like to add resources? check box and then click
Finish.

7 The “The JMS module was created successfully.” message appears.

32 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

Adding Resources to the JMS Module


This procedure assumes that you are continuing immediately after completing the
Creating a JMS Module steps described in the previous section.
1 Click on the New button in the Summary of Resources section at the bottom
of the Settings For.. console page. You do not need to select the check box.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 33


11 May 2006 WebLogic 9.x Configuration Process

2 Select Foreign Server from the option button group (WebLogic 9.1 as shown
below) or from the Type drop-down list (WebLogic 9.0 - not shown). Click Next
to continue.

3 Enter a name for the foreign server (e.g., mantaray) in the Name field, and then click
Finish.

4 The Create a Mew JMS System Resource Module console page appears.
Click Finish to continue.

34 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

Configuring ConnectionFactories
This procedure assumes that you are continuing immediately following completion of
the Adding Resources to the JMS Module steps as described in the previous
section.
1 Click on the name of the new resource (the foreign server that you have just created)
that appears in the Summary of Resources table at the bottom of the
Settings For... console page. You do not need to select the check box.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 35


11 May 2006 WebLogic 9.x Configuration Process

2 Enter the name of the class that must be instantiated to access the JNDI provider in
the JNDI Initial Context Factory field. The default value,
'w ebl ogi c.jn di. WL In it ialC ont ext F act ory ', appears automatically.
3 Enter a value for the JNDI Connection URL field, enter the URL of the JNDI
(e.g. t 3:/ /local host :7001 ). The JNDI Properties field is optional.

36 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

4 Click the Connection Factories link. The Connection Factories


console page appears. Create a new connection factory entry for each
connectionFactory that is bound to the JNDI as follows:
a Click the New button in the Foreign Connection Factories table.
b Enter a name for the connectionFactory in the Name field.
c Enter the name of the connectionFactory that is bound to the startup class in the
Local JNDI Name and Remote JNDI Name fields.
d Click OK to continue. The Connection Factories console page appears.
e Repeat these steps for each connectionFactory. Please note that the sample data
appearing in the screen capture is for demonstration purposes only.

5 The newly created connectionFactory entries appear in the Foreign


Connection Factories table as shown below.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 37


11 May 2006 WebLogic 9.x Configuration Process

Creating Foreign Destinations


1 When you finish creating connectionFactories, click the Destinations link to
add those destinations that you bound to the startup class.
2 Create a new destination entry for each destination that is bound to the JNDI as
follows:
a Click the New button in the Foreign Destinations table.
b Enter the JMS destination name in the Name field.
c Enter the name of the JMS destination that is bound to the startup class in the
Local JNDI Name and Remote JNDI Name fields.
d Click OK to continue. The sample data appearing in the screen capture is for
demonstration purposes only.

38 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

3 The newly created destination entries appear in the Foreign Destinations


table as shown below.

Activating the Definitions


The final step in the definition process is to activate the definitions that you completed.
To do so, click the Activate Changes button, located in the Change Center
section above the Domain Structure tree. This completes the definition process.

Once deployed, foreign JMS MBeans create objects in the local server JNDI tree, which
then performs a lookup of the referenced JMS objects whenever the foreign MBeans are
looked up. This means that the local server and the remote JNDI folder are always
synchronized.

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 39


11 May 2006 Code Samples

Code Samples
This section presents several examples of code that illustrate the concepts and
configuration procedures. Explanatory notes are appended to some of the samples.

Servlet Context Listener Class Sample Code


package com.manta.sample.startup

import org.mr.api.jms.*;
import javax.jms.*;
import javax.naming.InitialContext;
import javax.naming.InitialContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class MantaStartup implements ServletContextListener {


public MantaStartup() {super();}
public void contextInitialized(ServletContextEvent sce) {
try {
//create connection factory objects
QueueConnectionFactory qFactory =
new MantaQueueConnectionFactory();
TopicConnectionFactory tFactory =
new MantaTopicConnectionFactory();
//initiate JNDI context
//bind the connection factorie objects to the
//JNDI tree
context.bind("mantaQCF", qFactory);
System.out.println("bind mantaQCF");
context.bind("mantaTCF", tFactory);
System.out.println("bind mantaTCF");
TopicConnection tcon =
tFactory.createTopicConnection();
QueueConnection qcon =
qFactory.createQueueConnection();
QueueSession qsess = qcon.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSession tsess = tcon.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
//bind topic to the JNDI tree
String tName = new String("SampleTopic1");
Topic tryT = tsess.createTopic(tName);
context.bind(tName, tryT);
//bind topic to the JNDI tree
String qName = new String("SampleQueue1");
Queue tryQ = qsess.createQueue(qName);
context.bind(qName, tryQ);
System.out.println("finished binding");
context.close();
tcon.close();
qcon.close();
}catch (Exception e) { e.printStackTrace();}
}
public void contextDestroyed(ServletContextEvent sce) {}

Code Sample Notes


ƒ Modify JMS destinations as required by your applications.
ƒ The MantaRayQueueConnectionFactory and
MantaRayTopicConnectionFactory bindings are mandatory.
ƒ We recommend that you use a configuration file to load destinations and connection
factories in your code. This example uses hard-coded values for demonstration
purposes only

40 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide


WebLogic 9.x 11 May 2006

Web.xml Sample File


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>
com.manta.sample.startup.MantaStartup
</listener-class>
</listener>
</web-app>

MantaRay Deployment and Integration Guide Version 2.0 (DOC 2.0.0) 41


11 May 2006 Code Samples

Startup Class Sample Code


package com.manta.sample.startup;
import org.mr.api.jms.*;
import javax.jms.*;
import javax.naming.InitialContext;
public class MantaBinder {
public static void main(String[] args){
try {
//the follwing line is needed if the system property
//is not set in the setDomainEnv files
//System.setProperty("mantaConfig",
// "C:/MantaHome/config/default_config.xml");
//create connection factory objects
QueueConnectionFactory qFactory =
new MantaQueueConnectionFactory();
TopicConnectionFactory tFactory =
new MantaTopicConnectionFactory();
//initiate JNDI context
InitialContext context = new InitialContext();
//bind the connection factorie objects to the
//JNDI tree
context.bind("mantaQCF", qFactory);
System.out.println("bind mantaQCF");
context.bind("mantaTCF", tFactory);
System.out.println("bind mantaTCF");
TopicConnection tcon =
tFactory.createTopicConnection();
QueueConnection qcon =
qFactory.createQueueConnection();
QueueSession qsess = qcon.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicSession tsess = tcon.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
//bind topic to the JNDI tree
String tName = new String("SampleTopic1");
Topic tryT = tsess.createTopic(tName);
context.bind(tName, tryT);
//bind topic to the JNDI tree
String qName = new String("SampleQueue1");
Queue tryQ = qsess.createQueue(qName);
context.bind(qName, tryQ);
System.out.println("finished binding");
context.close();
tcon.close();
qcon.close();
} catch (Exception e) { e.printStackTrace();}
}
}

Code Sample Notes


ƒ Modify JMS destinations as required by your applications.
ƒ The MantaRayQueueConnectionFactory and
MantaRayTopicConnectionFactory bindings are mandatory.
ƒ We recommend that you use a configuration file to load destinations and connection
factories in your code. This example uses hard-coded values for demonstration
purposes only

42 Version 2.0 (DOC 2.0.0) MantaRay Deployment and Integration Guide

You might also like