This topic provides a reference for configuring SOAtest and Virtualize for popular JMS providers.Sections include:
Adding Required jar Files
To add the required jar files (listed in the tables below) to the SOAtest and Virtualize classpath, complete the following:
- Go to Parasoft > Preferences.
- Open the Parasoft > System Properties page.
- Click Add JARS and choose and select the necessary JAR files to be added.
JNDI Authentication
Any time that a username and password are required to connect to a JMS system that is configured to require authentication for JNDI access, the following JNDI properties must be configured:
java.naming.security.principal=<USERNAME>
java.naming.security.credentials=<PASSWORD>
Amazon Simple Queue Service (SQS)
For | Amazon Simple Queue Service (SQS) and other JMS providers where building JMS ConnectionFactory through JNDI lookup is difficult. |
---|---|
Minimum required JARs | Amazon SQS java client JARs (download from Maven Central here):
WSO2 carbon-jndi JAR (download from the WSO2 Maven repository here): org.wso2.carbon.jndi-<VERSION>.jar |
Factory class |
|
Connecting to AWS | Use I AM user roles for connecting to AWS. Refer to the following Amazon documentation for details: |
Learn more | https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/getting-started.html |
Creating the JMS ConnectionFactory Object
The following Groovy script is provided to help you create a JMS ConnectionFactory object and bind it to an in-memory InitialContext (bindConnectionFactory
method). Run the script once per SOAtest or Virtualize startup. You can run the script using an Extension tool (for example, setup test in a SOAtest .tst or a Virtualize .pvn) for each .tst that requires the object or implement a more sophisticated process that automates script execution in a manner suitable to your environment.
The script supports two methods of authenticating with AWS. If your SOAtest/Virtualize server is deployed within an AWS environment, AWS recommends using the instance provider flow for authentication. Alternatively, you can authenticate with AWS using the static mode, which requires the region
, accessKey
, and secretKey
. See Script Variables for information about the authentication variables defined in the script.
import java.util.* import javax.jms.* import javax.naming.* import com.amazon.sqs.javamessaging.* import com.amazonaws.auth.* import com.amazonaws.regions.* import com.amazonaws.services.securitytoken.* import com.amazonaws.services.securitytoken.model.* import com.amazonaws.services.sqs.* // Specify how you want to connect to AWS ("instance" or "static") provider = "instance" // Access keys for CLI, SDK, & API access // see https://console.aws.amazon.com/iam/home#/security_credentials accessKey = "" secretKey = "" region = Regions.US_WEST_1 // Multi-factor authentication // set serialNumber to null if MFA not enabled serialNumber = null tokenCode = "" // code from Google Authenticator (for example) durationSeconds = 3600 void bindConnectionFactory() { Properties env = new Properties() env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wso2.carbon.jndi.internal.InMemoryInitialContextFactory") Context ctx = new InitialContext(env) SQSConnectionFactory sqsConnectionFactory = createSQSConnectionFactory() ctx.rebind("SQSConnectionFactory", sqsConnectionFactory) } SQSConnectionFactory createSQSConnectionFactory() { AWSCredentialsProvider credentialsProvider = null if (provider.equals("instance")) { credentialsProvider = new InstanceProfileCredentialsProvider(false) } else { credentialsProvider = new AWSStaticCredentialsProvider( new BasicAWSCredentials(accessKey, secretKey)) if (serialNumber != null) { credentialsProvider = getTemporaryCredentials(credentialsProvider) } } return new SQSConnectionFactory( new ProviderConfiguration(), AmazonSQSClientBuilder.standard() .withRegion(region) .withCredentials(credentialsProvider).build()) } AWSStaticCredentialsProvider getTemporaryCredentials(AWSCredentialsProvider credentialsProvider) { AWSSecurityTokenService sts_client = null try { sts_client = AWSSecurityTokenServiceClientBuilder.standard() .withRegion(region) .withCredentials(credentialsProvider).build() Credentials creds = sts_client.getSessionToken(new GetSessionTokenRequest() .withDurationSeconds(durationSeconds) .withSerialNumber(serialNumber) .withTokenCode(tokenCode)).getCredentials() return new AWSStaticCredentialsProvider( new BasicSessionCredentials( creds.getAccessKeyId(), creds.getSecretAccessKey(), creds.getSessionToken())) } finally { if (sts_client != null) { sts_client.shutdown() } } }
A SQSConnectionFactory will be created and bound to the name SQSConnectionFactory
. Set the initial context to org.wso2.carbon.jndi.internal.InMemoryInitialContextFactory
and connection factory to SQSConnectionFactory
in any JNDI properties for looking up JMS ConnectionFactory.
Provider URL is unused because the JMS ConnectionFactory is created programmatically and not dynamically based on URL. For some SOAtest and Virtualize interfaces, such as the Virtualize Message Proxy, the provider URL field is required. In these cases, enter any non-empty string for the dialog to accept your configuration settings.
You can create a Messaging Client and send/receive messages for one of the queues that were already defined. You will be able to also see all the expected JMS header properties, including message IDs.
Script Variables
The following table describes the variables used in the script:
| Access key credentials for CLI, SDK, and API access. |
---|---|
serialNumber | Number that uniquely identifies the device if multi-factor authentication (MFA) is enabled. For virtual MFA devices, the serial number is the Amazon resource name (ARN) of the device as shown on the AWS security credentials page. |
tokenCode | The value returned by your MFA device, such as Google Authenticator. |
durationSeconds | The value specifying how long the temporary MFA credentials will be valid. |
Changing the Consumer Polling Interval
The message consumer for the SQS JMS client uses a default long polling interval of 20 seconds. This means that it can take up to 20 seconds to receive a message from a queue, even if the message shows up before then. The polling interval can be changed with a script. Example (Groovy):
import com.amazon.sqs.javamessaging.SQSMessageConsumerPrefetch void setMessageConsumerWaitTime() { SQSMessageConsumerPrefetch.WAIT_TIME_SECONDS = 1 }
Apache ActiveMQ
For | Apache Active MQ |
---|---|
Minimum required jars | activemq-all-<VERSION>.jar (download from Maven Central here) |
Typical provider URL pattern | tcp://hostname:61616 |
Factory class | JNDI Initial Context factory class Default connection factory JNDI name |
Learn more | http://activemq.apache.org/jndi-support.html |
Apache ActiveMQ Artemis
For | Apache ActiveMQ Artemis |
---|---|
Minimum required jars | artemis-jms-client-all-<VERSION>.jar (download from Maven Central here) |
Typical provider URL pattern | tcp://hostname:61616
|
Factory class | JNDI Initial Context factory class Default connection factory JNDI name |
Learn more | https://activemq.apache.org/components/artemis/documentation/latest/using-jms.html |
Apache Qpid
For | Apache Qpid |
---|---|
Minimum required JARs | JMS 2.0 compatible jars from Qpid 1.11.0 (download from Apache here)
|
Typical provider URL pattern | The path to a JNDI properties file. The file can be empty. If you specify a non-empty file then those properties will be merged with any other JNDI properties defined on the Properties tab. Alternatively, you can use Examples:
|
Connection URL JNDI property | Register a ConnectionFactory in JNDI using the form Example:
Detail: https://qpid.apache.org/releases/qpid-jms-1.11.0/docs/index.html#connection-uri |
Factory class | JNDI Initial Context factory class |
Connection Factory | Use the JNDI name specified earlier in the Example:
|
Learn more |
Azure Service Bus Standard Tier
For | Azure Service Bus Standard Tier |
---|---|
Minimum required JARs | JMS 2.0 compatible jars from Qpid 1.11.0 (download from Apache here)
|
Typical provider URL pattern | The path to a JNDI properties file. The file can be empty. If you specify a non-empty file then those properties will be merged with any other JNDI properties defined on the Properties tab. Alternatively, you can use Examples:
|
Connection URL JNDI property | Register a ConnectionFactory in JNDI using the form Example:
|
Factory class |
|
Connection Factory | Use the JNDI name specified earlier in the Example:
|
Licensing Restrictions | Only queues are accessible using the Detail: |
Learn more | https://learn.microsoft.com/azure/service-bus-messaging/service-bus-java-how-to-use-jms-api-amqp |
Azure Service Bus Premium Tier
For | Azure Service Bus Premium Tier |
---|---|
Minimum required JARs | azure-servicebus-jms-<VERSION>.jar (download from Maven Central here) JMS 2.0 compatible jars from Qpid 1.11.0 (download from Apache here)
org.wso2.carbon.jndi-<VERSION>.jar (download from the WSO2 Maven repository here) |
Factory class |
|
Connection Factory |
|
Licensing Restrictions | The |
Learn more | https://github.com/Azure/azure-servicebus-jms |
Creating the JMS ConnectionFactory Object
You first need the "connection string" for your Azure Service Bus namespace:Endpoint=sb://<NAMESPACE>.servicebus.windows.net/;SharedAccessKeyName=<SAS_POLICY_NAME>;SharedAccessKey=<SAS_POLICY_KEY>
The following Groovy script is provided to help you create a JMS ConnectionFactory
object and bind it to an in-memory InitialContext
(bindConnectionFactory
method). Run the script once per SOAtest or Virtualize startup. You can run the script using an Extension tool (for example, setup test in a SOAtest .tst or a Virtualize .pvn) for each .tst that requires the object or implement a more sophisticated process that automates script execution in a manner suitable to your environment.
import com.microsoft.azure.servicebus.jms.ConnectionStringBuilder import com.microsoft.azure.servicebus.jms.ServiceBusJmsConnectionFactory import com.microsoft.azure.servicebus.jms.ServiceBusJmsConnectionFactorySettings; import java.util.Properties import javax.naming.Context import javax.naming.InitialContext void bindConnectionFactory() { Properties env = new Properties() env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wso2.carbon.jndi.internal.InMemoryInitialContextFactory") Context ctx = new InitialContext(env) ConnectionStringBuilder connectionStringBuilder = new ConnectionStringBuilder("Endpoint=sb://<NAMESPACE>.servicebus.windows.net/;SharedAccessKeyName=<SAS_POLICY_NAME>;SharedAccessKey=<SAS_POLICY_KEY>") ServiceBusJmsConnectionFactorySettings connectionFactorySettings = new ServiceBusJmsConnectionFactorySettings(); connectionFactorySettings.setShouldReconnect(false); ServiceBusJmsConnectionFactory sbConnectionFactory = new ServiceBusJmsConnectionFactory(connectionStringBuilder, connectionFactorySettings) ctx.rebind("ServiceBusJmsConnectionFactory", sbConnectionFactory) }
GlassFish MQ
For | GlassFish |
---|---|
Minimum required JARs | GlassFish 3 - Found under - gf-client.jar Note that the gf-client.jar references a few dozen other jars from the GlassFish 3 installation. You must reference gf-client.jar from the GlassFish installation directory so that the referenced jars can be found and loaded. GlassFish can be downloaded from http://glassfish.java.net/. GlassFish 2 - Found under - appserv-admin.jar |
Typical provider URL pattern | iiop://hostname:3700 |
Factory class | JNDI Initial Context factory class Note that GlassFish has another JNDI Initial Context factory class called "com.sun.appserv.naming.S1ASCtxFactory". This class has poor performance and should not be used. Use the mentioned SerialInitContextFactory class instead which is available in both GlassFish 2 and GlassFish 3. |
Notes | The GlassFish client and GlassFish server perform a reverse DNS lookup on each other. If the server does not recognize the client's host name, then you can add the client's host name and IP address to the hosts file on the server. If the client does not recognize the server's host name, then you can add the server's host name and IP address to the hosts file on the client. The hosts file is typically /etc/hosts on Unix or %SystemRoot%\system32\drivers\etc\hosts on Windows. |
Learn more | http://glassfish.java.net/ |
IBM WebSphere Application Server (WAS)
For | WAS Default JMS provider. Parasoft recommends the use of IBM's JMS thin client that is provided by WAS 7.0 or later, and which can interoperate with WAS 6.0.2 and later. |
---|---|
Minimum required JARs | Found under |
Typical provider URL pattern | iiop://hostname:2809/ |
Factory class | JNDI Initial Context factory class |
Learn more | WebSphere Application Server Network Deployment, Version 7.0 documentation |
What if you don’t have WAS 7.0 or later?
If you aren’t using (or don’t have access to) a WAS 7 installation, download and install the IBM Client for JMS, which also works with WAS 6.0.2 and later:
- Download the JMS Client installer jar from http://www-01.ibm.com/support/docview.wss?uid=swg24012804.
- Follow the instructions on the download page to install both the JMS and JNDI jars for the Sun JRE. The command to install the client jars is similar to:
"java -jar sibc_oeminst-o0902.06.jar jms_jndi_sun C:\ibmjms"
The client jars will be installed under thelib
folder. - Add the JNDI property
com.ibm.CORBA.ORBInit=com.ibm.ws.sib.client.ORB
- For simplicity, this jndi property can be set globally in a jndi.properties file in the JRE's lib folder.
- For the standalone build of this product, the JRE lib folder is under
<INSTALL_DIR>/plugins/com.parasoft.ptest.jdk.eclipse.core.web.<OS>.<ARCH>_<VERSION>/jdk/jre/lib
. - This JNDI property is not needed when using the jars from the WAS 7 runtimes folder.
IBM MQ
For | IBM MQ JMS provider |
---|---|
Minimum required JARs |
|
Typical provider URL pattern | The directory path containing the .bindings file. Example:
|
Factory class | IBM MQ JNDI Initial Context factory class
|
Connection Factory | ConnectionFactory name as defined in the .bindings file. |
JMS messaging without JNDI | Under the properties tab, define the following properties: import com.ibm.mq.jms.*; ... MQConnectionFactory cf = new MQConnectionFactory(); cf.setHostName(hostname); cf.setPort(port); cf.setQueueManager(queuemanager); cf.setChannel(channel); cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP); cf.setFailIfQuiesce(JMSC.MQJMS_FIQ_YES); cf.setUseConnectionPooling(true); |
Additional information | IBM's JNDI provider authenticates itself with the IBM MQ server by sending the user's login name. This is typically the username that was provided when logging into the workstation before starting SOAtest/Virtualize. If the MQ server does not recognize the username, then your tool will fail with the error "javax.jms.JMSSecurityException: MQJMS2013: invalid security authentication supplied for MQQueueManager". This error can be resolved by adding a Windows user account on the IBM MQ server machine. This account should 1) have the same username as the account on the local machine where SOAtest and Virtualize is running and 2) be a member of the "mqm" IBM MQ Administration Group.Alternatively, use a different username by changing the value of the user.name Java System property. This system property can be configured by starting SOAtest and Virtualize using It is also possible to modify Java system properties during test suite execution by using an Extension Tool to call the java.lang.System.setProperty() method from Sun's Java API. |
Learn more |
JBoss JMS
For | JBoss JMS; the following jar list is based on JBoss 5.0 |
---|---|
Minimum required JARs | Found under |
Typical provider URL pattern | hostname |
Factory class | JNDI Initial Context factory class |
Open Message Queue (OpenMQ)
Note that OpenMQ can run by itself or as part of Glassfish App Server, where it is called "Glassfish MQ". If you are using OpenMQ from Glassfish, see the GlassFish section.
For | OpenMQ Server |
---|---|
Minimum required JARs | Found under |
Typical provider URL pattern | hostname |
Factory class | JNDI Initial Context factory class |
Learn more | http://mq.java.net |
Oracle Advanced Queuing (AQ)
For | Oracle Advanced Queuing (AQ) |
---|---|
Minimum required JARs | From Oracle Database installation: or From Oracle Weblogic Server installation: |
Provider URL | Leave this field empty. |
JNDI initial context factory class | oracle.jms.AQjmsInitialContextFactory |
Connection factory JNDI name | One of the following: |
Required JNDI properties |
|
Queue/topic names | Prefix a queue name with |
Additional information | The aqapi.jar from older version of Oracle Database, such as 10g, may be missing the Initial Context factory class. Use the jars from Oracle Database 11g or later. The latest Oracle Database Express Edition (XE) can be downloaded from oracle.com: Oracle Database Express Edition 11g Release 2 |
Learn more | Interoperating with Oracle AQ JMS |
Oracle BEA WebLogic
For | Oracle BEA WebLogic |
---|---|
Minimum required JARs (thin client) * | Found under Note that additional jars may be needed. We recommend using a full client; this relieves you from having to find and add many jars. |
Minimum required JARs (full client) * | Build the single wlfullclient5.jar as described in the instructions for "Creating a wlfullclient5.jar for JDK 1.5 client applications." |
Typical provider URL pattern | Thin Client: Full Client: |
Factory class | JNDI Initial Context factory class: |
Learn more | http://docs.oracle.com/cd/E12840_01/wls/docs103/client/jarbuilder.html |
Progress Sonic MQ/ESB
For | Progress Sonic MQ/ESB |
---|---|
Minimum required JARs | Found under Note that SonicMQ's broker.jar and TIBCO’s tibcojms.jar cannot be used together. |
Typical provider URL Ppttern | tcp://hostname:2506 |
Factory class | JNDI Initial Context factory class |
Learn more | Refer to SonicMQ Application Programming Guide, Appendix A (Using the Sonic JNDI SPI) and which also refers to other relevant sections. |
RabbitMQ
For | RabbitMQ |
---|---|
Minimum required JARs | Download client library from Maven's Central Repository. rabbitmq-jms-<VERSION>.jar |
.bindings file example | #This file is used by the JNDI FSContext. #Wed Jan 31 15:36:15 PST 2018 ConnectionFactory/FactoryName=com.rabbitmq.jms.admin.RMQObjectFactory ConnectionFactory/ClassName=javax.jms.ConnectionFactory ConnectionFactory/RefAddr/0/Type=name ConnectionFactory/RefAddr/0/Encoding=String ConnectionFactory/RefAddr/0/Content=jms/ConnectionFactory ConnectionFactory/RefAddr/1/Type=type ConnectionFactory/RefAddr/1/Encoding=String ConnectionFactory/RefAddr/1/Content=javax.jms.ConnectionFactory ConnectionFactory/RefAddr/2/Type=factory ConnectionFactory/RefAddr/2/Encoding=String ConnectionFactory/RefAddr/2/Content=com.rabbitmq.jms.admin.RMQObjectFactory ConnectionFactory/RefAddr/3/Type=host ConnectionFactory/RefAddr/3/Encoding=String ConnectionFactory/RefAddr/3/Content=host.company.com ConnectionFactory/RefAddr/4/Type=port ConnectionFactory/RefAddr/4/Encoding=String ConnectionFactory/RefAddr/4/Content=5672 |
Typical provider URL pattern | The directory path containing the .bindings file
|
Initial context | com.sun.jndi.fscontext.RefFSContextFactory |
Connection factory | JNDI Initial Context factory class |
Solace JMS
For | Solace JMS |
---|---|
Minimum required JARs | commons-lang-<VERSION>.jar sol-common-<VERSION>.jar sol-jcsmp-<VERSION>.jar sol-jms-<VERSION>.jar |
Typical provider URL pattern | smf://<HOST>:<PORT> |
Factory class | JNDI Initial Context factory class The additional JNDI property |
Sun Java System Message Queue (Sun MQ)
For | Sun MQ Server |
---|---|
Minimum required JARs | Found under |
Typical provider URL pattern | hostname |
Factory class | JNDI Initial Context factory class |
Learn more | See the Sun Java System Message Queue Administration 3.x/4.x Guide, Section Quick-Start Tutorial. This document can be downloaded from http://docs.sun.com/app/docs/prod/message?l=en#hic. In the document, navigate to Software > Application & Integration Services > Message Queue. |
TIBCO EMS
For | TIBCO EMS |
---|---|
Minimum required JARs | Found under Note that SonicMQ's broker.jar and TIBCO’s tibcojms.jar cannot be used together. |
Typical provider URL pattern | tcp://hostname:7222 hostname (if using default port numbers) |
Factory class | JNDI Initial Context factory class |
SSL configuration | The following JNDI properties must be configured: For two-way SSL, the following additional properties must also be configured: |
Additional information | Any time that a username and password is needed to connect to Tibco EMS the following JNDI properties must be configured: |
Learn more | Refer to the TIBCO Enterprise Message Service User's Guide, section 9: Developing an EMS Client Application > Programmer Checklist |
Sun JMS
SOAtest and Virtualize bundle a Sun JNDI implementation that stores JNDI bindings in directories and files on the local hard drive using com.sun.jndi.fscontext.RefFSContextFactory
as the Initial Context and a user defined Provider URL (directory) of C:\JNDIRoot
or something similar.
When using the Sun implementation, you must populate the C:\JNDIRoot
directory with a .binding file so that fscontext
can successfully look up the ConnectionFactory and Queue or Topic objects. Parasoft has put together an example that can be found in the SOAtest/Virtualize installation directory (/examples/jms/JndiFileProviderTest.java), which creates a .binding file.
Other JMS Providers
For other JMS providers, please refer to your vendor guides on how to configure a JMS client to communicate with your system.