<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Altentee &#187; Performance &#38; Test Automation Experts &#187; JMS</title>
	<atom:link href="http://altentee.com/tag/jms/feed/" rel="self" type="application/rss+xml" />
	<link>http://altentee.com</link>
	<description>Performance and Test Automation Experts</description>
	<lastBuildDate>Sat, 12 Jun 2010 00:35:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using LoadRunner Java Vusers with WebLogic JMS Queues/Topics</title>
		<link>http://altentee.com/2008/using-loadrunner-java-vusers-to-generate-load-on-weblogic-jms-queuestopics/</link>
		<comments>http://altentee.com/2008/using-loadrunner-java-vusers-to-generate-load-on-weblogic-jms-queuestopics/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 23:07:43 +0000</pubDate>
		<dc:creator>Tim Koopmans</dc:creator>
				<category><![CDATA[90kts]]></category>
		<category><![CDATA[Altentee]]></category>
		<category><![CDATA[JMS]]></category>
		<category><![CDATA[loadrunner]]></category>

		<guid isPermaLink="false">http://90kts.com/blog/2008/using-loadrunner-java-vusers-to-generate-load-on-weblogic-jms-queuestopics/</guid>
		<description><![CDATA[<p>The following scripts are examples on how to generate load for the BEA WebLogic implementation of JMS. Specifically I demonstrate how to place messages on a queue and how to publish messages to a topic using a Java Vuser within LoadRunner.
</p>
<p>There are a few pre-requisites to get this all working.</p>
<p>BEA WebLogic JMS supports the Sun [...]]]></description>
			<content:encoded><![CDATA[<p>The following scripts are examples on how to generate load for the BEA WebLogic implementation of JMS. Specifically I demonstrate how to place messages on a queue and how to publish messages to a topic using a Java Vuser within LoadRunner.<br />
<span id="more-122"></span></p>
<p>There are a few pre-requisites to get this all working.</p>
<p>BEA WebLogic JMS supports the <a href="http://java.sun.com/products/jms/docs.html">Sun JMS Specification</a> which implements the standard JMS APIs. So in order for your code to work, you must have the latest JMS package (jms.jar) which I sourced from the Sun SDK for enterprise messaging. Because I had so much difficulty getting my hands on this, I&#8217;ll <a href='http://90kts.com/blog/wp-content/uploads/2008/03/jmsjar.zip' title='jms.jar'>host it here</a> for the time being if you&#8217;re interested in running your own demo.</p>
<p>You will also need a copy of the WebLogic package (weblogic.jar) which is typically found in the lib directory of your WebLogic server. The code demonstrated in this blog uses WebLogic 9.2.x</p>
<p>You will need to tell your Java Vuser where to get these libraries, which is done by modifying the run-time settings (F4) in VuGen.<br />
<a href='http://90kts.com/blog/wp-content/uploads/2008/03/javavuserclasspath.png' title='Java Vuser Classpath Settings'><img src='http://90kts.com/blog/wp-content/uploads/2008/03/javavuserclasspath.png' alt='Java Vuser Classpath Settings' /></a></p>
<p>Also, if you&#8217;ve never created a Java Vuser before, then make sure your load generators have a copy of the Sun JDK; I used 1.5.0_14 &#8230;</p>
<p>The following code examples have been written for a Point-To-Point (writing messages to a queue) and Pub/Sub (publishing messages to a topic) scenario. You can use either depending on your requirements.</p>
<p>I have also parametized some values, with original values commented so you can see what they look like. I&#8217;ve also thrown in a couple of other LoadRunner API specific calls, to demonstrate some handy methods for logging and transactions.</p>
<p>For now, I only need to load specific queues or topics, with no requirement to simulate a subscriber/consumer for these modules, although if you needed to, the following code should give you enough of a head start coupled with examples provided by BEA. <a href="http://www.myloadtest.com/soap-over-jms-with-loadrunner/">This article</a> is also a great example of achieving a similar purpose for a TIBCO implementation using SOAP over JMS. Nice one Stuart<br />
 <img src='http://altentee.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>JMSLoadQueuePTP &#8211; </strong> <a href='http://90kts.com/blog/wp-content/uploads/2008/03/jmsloadqueueptp.zip' title='JMSLoadQueuePTP Vuser'>Download Script</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * LoadRunner Java script. (Build: 873)
 *
 * Script Description: This examples shows how to establish a connection and
 * send messages to a JMS queue. It requires the jms.jar and weblogic.jar
 * packages to be available in your run-time settings classpath.
 *
 * Author: tim.koopmans@90kts.com
 *
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">lrapi.lr</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Hashtable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jms.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.naming.Context</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.naming.InitialContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.naming.NamingException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Actions
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Define public paramse</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> JNDI_FACTORY <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;weblogic.jndi.WLInitialContextFactory&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> JMS_FACTORY<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> QUEUE<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> <span style="color: #003399;">URL</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Define private params</span>
    <span style="color: #000000; font-weight: bold;">private</span> QueueConnectionFactory qconFactory<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> QueueConnection qcon<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> QueueSession qsession<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> QueueSender qsender<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> Queue queue<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> TextMessage msg<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">NamingException</span>, JMSException <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Parameters</span>
	JMS_FACTORY	<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;jms_FACTORY&gt;&quot;</span><span style="color: #339933;">;</span> 	<span style="color: #666666; font-style: italic;">// e.g. weblogic.sandbox.connectionFactory</span>
	QUEUE 		    <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;queue&gt;&quot;</span><span style="color: #339933;">;</span> 	     <span style="color: #666666; font-style: italic;">// e.g. weblogic.sandbox.queue</span>
	<span style="color: #003399;">URL</span> 		      <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;url&gt;&quot;</span><span style="color: #339933;">;</span> 		     <span style="color: #666666; font-style: italic;">// e.g. t3://192.168.249.128:7001</span>
	<span style="color: #666666; font-style: italic;">//lr.message( &quot;DEBUG: URL &quot; + URL );</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Setup initial context and JNDI factory</span>
	Hashtable<span style="color: #339933;">&lt;</span>string,String<span style="color: #339933;">&gt;</span> env <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hashtable<span style="color: #339933;">&lt;</span>string,String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        env.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span>.<span style="color: #006633;">INITIAL_CONTEXT_FACTORY</span>, JNDI_FACTORY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        env.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span>.<span style="color: #006633;">PROVIDER_URL</span>, <span style="color: #003399;">URL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">InitialContext</span> ctx  <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InitialContext</span><span style="color: #009900;">&#40;</span>env<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Establish connection to JMS queue</span>
	lr.<span style="color: #006633;">start_transaction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;connect_to_server&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	qconFactory <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>QueueConnectionFactory<span style="color: #009900;">&#41;</span> ctx.<span style="color: #006633;">lookup</span><span style="color: #009900;">&#40;</span>JMS_FACTORY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	qcon <span style="color: #339933;">=</span> qconFactory.<span style="color: #006633;">createQueueConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	qsession <span style="color: #339933;">=</span> qcon.<span style="color: #006633;">createQueueSession</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span>, Session.<span style="color: #006633;">AUTO_ACKNOWLEDGE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	queue <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Queue<span style="color: #009900;">&#41;</span> ctx.<span style="color: #006633;">lookup</span><span style="color: #009900;">&#40;</span>QUEUE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	qsender <span style="color: #339933;">=</span> qsession.<span style="color: #006633;">createSender</span><span style="color: #009900;">&#40;</span>queue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	qcon.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	lr.<span style="color: #006633;">end_transaction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;connect_to_server&quot;</span>, lr.<span style="color: #006633;">AUTO</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end of init</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> action<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JMSException <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Typically you would parametize the following string</span>
	<span style="color: #003399;">String</span> FORMATTED_MESSAGE <span style="color: #339933;">=</span>
	    <span style="color: #0000ff;">&quot;&lt;?xml version=<span style="color: #000099; font-weight: bold;">\&quot;</span>1.0<span style="color: #000099; font-weight: bold;">\&quot;</span>?&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;&lt;parts&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;   &lt;title&gt;Computer Parts&lt;/title&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;   &lt;part&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;      &lt;item&gt;Motherboard&lt;/item&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;      &lt;manufacturer&gt;ASUS&lt;/manufacturer&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;      &lt;model&gt;P3B-F&lt;/model&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;      &lt;cost&gt; 123.00&lt;/cost&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;   &lt;/part&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;   &lt;part&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
	    <span style="color: #0000ff;">&quot;&lt;/parts&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Create a message object</span>
	 msg <span style="color: #339933;">=</span> qsession.<span style="color: #006633;">createTextMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 msg.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>FORMATTED_MESSAGE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #666666; font-style: italic;">// Send the message object</span>
	 lr.<span style="color: #006633;">start_transaction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;send_message&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 qsender.<span style="color: #006633;">send</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 lr.<span style="color: #006633;">end_transaction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;send_message&quot;</span>, lr.<span style="color: #006633;">AUTO</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	 <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end of action</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> end<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JMSException <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Close all JMS objects</span>
	qsender.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	qsession.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	qcon.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end of end</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>JMSLoadTopicPUB &#8211; </strong><a href='http://90kts.com/blog/wp-content/uploads/2008/03/jmsloadtopicpub.zip' title='JMSLoadTopicPUB Vuser'>Download Script</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * LoadRunner Java script. (Build: 873)
 *
 * Script Description: This examples shows how to establish a connection and
 * send messages to a JMS topic. It requires the jms.jar and weblogic.jar
 * packages to be available in your run-time settings classpath.
 *
 * Author: tim.koopmans@90kts.com
 *
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">lrapi.lr</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Hashtable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jms.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.naming.Context</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.naming.InitialContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.naming.NamingException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.rmi.PortableRemoteObject</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Actions
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Define public params, typically you would parametize these</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> JNDI_FACTORY <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;weblogic.jndi.WLInitialContextFactory&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> JMS_FACTORY<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> TOPIC<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> <span style="color: #003399;">URL</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Define private params</span>
    <span style="color: #000000; font-weight: bold;">private</span> TopicConnectionFactory tconFactory<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> TopicConnection tcon<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> TopicSession tsession<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> TopicPublisher tpublisher<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> Topic topic<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> TextMessage msg<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">NamingException</span>, JMSException <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Parameters</span>
        JMS_FACTORY	<span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;jms_FACTORY&gt;&quot;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// e.g. weblogic.sandbox.connectionFactory</span>
        TOPIC 	    <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;topic&gt;&quot;</span><span style="color: #339933;">;</span> 	   <span style="color: #666666; font-style: italic;">// e.g. weblogic.sandbox.topic</span>
        <span style="color: #003399;">URL</span>         <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;url&gt;&quot;</span><span style="color: #339933;">;</span> 		   <span style="color: #666666; font-style: italic;">// e.g. t3://192.168.249.128:7001</span>
        <span style="color: #666666; font-style: italic;">//lr.message( &quot;DEBUG: URL &quot; + URL );</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Setup initial context and JNDI factory</span>
        Hashtable<span style="color: #339933;">&lt;</span>string,String<span style="color: #339933;">&gt;</span> env <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Hashtable<span style="color: #339933;">&lt;</span>string,String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        env.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span>.<span style="color: #006633;">INITIAL_CONTEXT_FACTORY</span>, JNDI_FACTORY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        env.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span>.<span style="color: #006633;">PROVIDER_URL</span>, <span style="color: #003399;">URL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        env.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;weblogic.jndi.createIntermediateContexts&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">InitialContext</span> ctx  <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InitialContext</span><span style="color: #009900;">&#40;</span>env<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Establish connection to JMS topic as PUB</span>
        lr.<span style="color: #006633;">start_transaction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;connect_to_server&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tconFactory <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TopicConnectionFactory<span style="color: #009900;">&#41;</span>
        <span style="color: #003399;">PortableRemoteObject</span>.<span style="color: #006633;">narrow</span><span style="color: #009900;">&#40;</span>ctx.<span style="color: #006633;">lookup</span><span style="color: #009900;">&#40;</span>JMS_FACTORY<span style="color: #009900;">&#41;</span>,
        TopicConnectionFactory.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tcon <span style="color: #339933;">=</span> tconFactory.<span style="color: #006633;">createTopicConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tsession <span style="color: #339933;">=</span> tcon.<span style="color: #006633;">createTopicSession</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span>, Session.<span style="color: #006633;">AUTO_ACKNOWLEDGE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        topic <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Topic<span style="color: #009900;">&#41;</span> <span style="color: #003399;">PortableRemoteObject</span>.<span style="color: #006633;">narrow</span><span style="color: #009900;">&#40;</span>ctx.<span style="color: #006633;">lookup</span><span style="color: #009900;">&#40;</span>TOPIC<span style="color: #009900;">&#41;</span>, Topic.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tpublisher <span style="color: #339933;">=</span> tsession.<span style="color: #006633;">createPublisher</span><span style="color: #009900;">&#40;</span>topic<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tcon.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        lr.<span style="color: #006633;">end_transaction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;connect_to_server&quot;</span>, lr.<span style="color: #006633;">AUTO</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end of init</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> action<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JMSException <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Typically you would parametize the following string</span>
        <span style="color: #003399;">String</span> FORMATTED_MESSAGE <span style="color: #339933;">=</span>
        <span style="color: #0000ff;">&quot;&lt;?xml version=<span style="color: #000099; font-weight: bold;">\&quot;</span>1.0<span style="color: #000099; font-weight: bold;">\&quot;</span>?&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;&lt;parts&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;   &lt;title&gt;Computer Parts&lt;/title&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;   &lt;part&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;      &lt;item&gt;Motherboard&lt;/item&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;      &lt;manufacturer&gt;ASUS&lt;/manufacturer&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;      &lt;model&gt;P3B-F&lt;/model&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;      &lt;cost&gt; 123.00&lt;/cost&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;   &lt;/part&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;   &lt;part&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">+</span>
        <span style="color: #0000ff;">&quot;&lt;/parts&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Create a message object</span>
        msg <span style="color: #339933;">=</span> tsession.<span style="color: #006633;">createTextMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        msg.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>FORMATTED_MESSAGE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Send the message object</span>
        lr.<span style="color: #006633;">start_transaction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;send_message&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tpublisher.<span style="color: #006633;">publish</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        lr.<span style="color: #006633;">end_transaction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;send_message&quot;</span>, lr.<span style="color: #006633;">AUTO</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end of action</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> end<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JMSException <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Close all JMS objects</span>
        tpublisher.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tsession.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tcon.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end of end</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://altentee.com/2008/using-loadrunner-java-vusers-to-generate-load-on-weblogic-jms-queuestopics/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
