Sunday, December 12, 2010

LoadRunner script for SOAP over JMS to test TIBCO Middleware

Following is a script that I created to test SOAP message over JMS using SOA protocol. I would suggest using JAVA protocol to script SOAP over JMS rather than SOA protocol. It provides greater flexibility than SOA protocol. There is a good blog written by Stuart Moncrieff and I suggest reading it if you are planning on using JAVA protocol to test SOAP message over JMS. I don't want to reinvent the wheel by writing a new code. You will require some modification to the Java script. For example, if you are using username and password, you will need to pass these values into the createConnection function.

It will look like this(It is modification of Stuart's code):
queueConnection = queueConnectionFactory.createConnection(username,password);

Before you starting writing your script using either SOA or Java protocol, you will need few files and information and they are:

1: Tibjms.jar -compulsory
2: Java 1.6 -compulsory (older version may work, but I tested against 1.6)
3: JNDI initial context factory -compulsory
4: JNDI provider URL - compulsory
5: JMS connection factory - compulsory
6: JMS security credentials - compulsory, if implemented
7: JMS security principal - compulsory, if implemented
8: Request queue name - required, if you are sending message to the request queue
9: Receive queue name - required, if you are receiving message from the receive queue

You will need to get information for points 3-9 from your JMS administrator or whoever may have implemented JMS.

SOA Protocol script
The script was meant to test TIBCO with JMS Fire and forget pattern. No response was expected from TIBCO because the test was to find out whether the request queue is able to handle the expected requests per hour. Therefore, I did not require Receive queue name details.

Following details were set in the Run-time setting-> JMS advance option. For points 2-5, I have used dummy names.

1:JNDI initial context factory :com.tibco.tibjms.naming.TibjmsInitalContextFactory //testing TIBCO JMS. This is a dropdown option and might change depending on what you are testing.
2:JNDI provider URL :tibjmsnaming://
3:JMS connection factory :QueueConnectionFactory
4:JMS security credentials :jmsPerTester
5:JMS security principal :jmsPerTester

SOAP request
char *EmployeeDetails=
"110 Latrobe st"

long currentTime=1; 
char *ExpiryTime; 

//get current time in seconds

currentTime = currentTime + 500000; 

ExpiryTime = (char*)malloc(20, sizeof(char)); 

//save current time value into ExpiryTime variable. This is how long the message should be valid for

//Save EmployeeDetails SOAP request into LR parameter

//lr_output_message ("%s",lr_eval_string ("{EmployeeDetailSOAP_param}"));

//setup JMS properties
jms_set_general_property("msgJMSMessageType","JMS_MESSAGE_TYPE","BytesMessage"); //Change 'ByteMessage' to 'TextMessage', if you are sending as a text
jms_set_message_property("msgJMSExpiration","JMSExpiration", ExpiryTime); 
jms_set_message_property("msgJMSMessageID","JMSMessageID", "-JMSMessageID-");
jms_set_message_property("msgJMSPriority","JMSPriority", "4"); 
jms_set_message_property("msgJMSRedelivered","JMSRedelivered", "false");
jms_set_message_property ("msgJMSDeliveryMode","JMSDeliveryMode","2");
jms_set_message_property("msgJMSCorrelationID", "JMSCorrelationID", "VuserID-{VUserID}_{TimeDate}"); //VUserID & TimeDate are loadrunner parameters

//sending message
lr_start_transaction ("SoapRequest"); 
jms_send_message_queue("step 1: Sending SOAP message","{EmployeeDetailSOAP_param}", "");  

//Receive message
/*jms_receive_message_queue("step 2: Received SOAP message", ""); 
lr_message(lr_eval_string("{JMS_message}")); */

lr_end_transaction ("SoapRequest",LR_AUTO);

return  0;

Note:In the above code I am using lr_start_transaction function to capture total number of requests posted to the queue. It does not measure the response time. This is because we are not expecting any response due to Fire and Forget pattern.

You could use file(/char array) for the SOAP request as well as parametrize the SOAP content. I will leave this as an exercise for anyone who wants to try it out.

1 comment:

SAM said...

Hi, Thanks for the code, it helped me a lot for my project task. But now i am stucked with Receiving a message from JMS queue. Can you please help me if you have any set JMS property for Receiving message. Also can you explain a bit abt "jms_set_message_property("msgJMSCorrelationID", "JMSCorrelationID", "VuserID-{VUserID}_{TimeDate}"); //VUserID & TimeDate are loadrunner parameters"