Hi,

Attached is the text documents for codes and log error. I am a beginner in
Jmeter. First time I am doing IBM MQ performance testing. So, I am not able
to understand the error. Please guide me on how to do IBM MQ testing.
As I previously mentioned, I referred below site code to do the testing. I
just changed Configuration parameters for IBM Services.
https://www.blazemeter.com/blog/ibm-mq-testing-with-jmeter-learn-how/


Thanks & Regards,
Smruti Koyande


On Mon, Jan 10, 2022 at 10:48 AM Dmitri T <glin...@live.com> wrote:

> How we are supposed to help without:
>
>    1. Seeing your full code in form of text, not the screenshot
>    2. Seeing jmeter.log file contents (preferably with debug level
>    verbosity
>    <https://www.blazemeter.com/blog/how-to-configure-jmeter-logging>)
>
> The error means that you're trying to call *createProducer()* function of
> the object which doesn't exist which in its turn means that Session
> <https://docs.oracle.com/javaee/7/api/javax/jms/Session.html> interface
> instance is null
> <https://dev.to/dj_devjournal/understanding-null-in-java-4o31> so you
> need to re-visit your code and double check the place where you're creating
> the JMS Session object.
>
>
> On 1/10/2022 4:51 AM, Smruti Koyande wrote:
>
> Hi,
>
> Can anyone help out with the above query.
>
> On Fri, Jan 7, 2022 at 9:18 PM Smruti Koyande <smr...@cateina.com> wrote:
>
>> Hii,
>>
>> Anyone help me to create the test plan in Jmeter for the IBM MQ message
>> test?
>>
>> Below is the scenario for our project :
>> [image: image.png]
>> I referred link :
>> https://www.blazemeter.com/blog/ibm-mq-testing-with-jmeter-learn-how/
>>
>> As per link,
>> Step 1 : Downloaded the jar files and pasted the same in /lib folder and
>> restarted the Jmeter.
>> Step 2 : Created a test plan as suggested in the link but getting below
>> errors . I used our configuration parameters for the IBM MQ service.
>>
>>
>>
>> [image: image.png]
>> [image: image.png]
>> [image: image.png]
>>
>>
>>
>> --
>> Thanks & Regards,
>> Smruti Koyande
>>
>>
>>
>
> --
> Thanks & Regards,
> Smruti Koyande
> Junior Software Tester
>
>

-- 
Thanks & Regards,
Smruti Koyande
Junior Software Tester
2022-01-10 14:23:39,069 ERROR o.a.j.p.j.s.JSR223Sampler: Problem in JSR223 
script JSR223 Sampler, message: javax.script.ScriptException: 
java.lang.NullPointerException: Cannot invoke method createProducer() on null 
object
javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke 
method createProducer() on null object
        at 
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320)
 ~[groovy-jsr223-3.0.7.jar:3.0.7]
        at 
org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:71)
 ~[groovy-jsr223-3.0.7.jar:3.0.7]
        at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_301]
        at 
org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:217)
 ~[ApacheJMeter_core.jar:5.4.2]
        at 
org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:72)
 [ApacheJMeter_java.jar:5.4.2]
        at 
org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638) 
[ApacheJMeter_core.jar:5.4.2]
        at 
org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
 [ApacheJMeter_core.jar:5.4.2]
        at 
org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) 
[ApacheJMeter_core.jar:5.4.2]
        at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) 
[ApacheJMeter_core.jar:5.4.2]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]
Caused by: java.lang.NullPointerException: Cannot invoke method 
createProducer() on null object
        at 
org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91) 
~[groovy-3.0.7.jar:3.0.7]
        at 
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:44)
 ~[groovy-3.0.7.jar:3.0.7]
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
 ~[groovy-3.0.7.jar:3.0.7]
        at 
org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:34) 
~[groovy-3.0.7.jar:3.0.7]
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
 ~[groovy-3.0.7.jar:3.0.7]
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
 ~[groovy-3.0.7.jar:3.0.7]
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
 ~[groovy-3.0.7.jar:3.0.7]
        at Script1.run(Script1.groovy:8) ~[?:?]
        at 
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317)
 ~[groovy-jsr223-3.0.7.jar:3.0.7]
import com.ibm.msg.client.jms.JmsConnectionFactory
import com.ibm.msg.client.jms.JmsFactoryFactory
import com.ibm.msg.client.wmq.WMQConstants

import javax.jms.Session

// 1 : The configuration parameters for the IBM MQ service are centralized here.
def hostName = "quickstart-cp4i-test-ibm-mq.cp4i-portall.svc"
def hostPort = 1414
def channelName = "SB.SVRCONN"
def queueManagerName = "QUICKSTART"
def queueName = "Testing.IN"

// 2 : Creates a factory object connection


def ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER)
def cf = ff.createConnectionFactory()

// 3 : Sets the properties of the factory object connection
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, hostName)
cf.setIntProperty(WMQConstants.WMQ_PORT, hostPort)
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, channelName)
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT)
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, queueManagerName)

// 4 : Creates a connection with the connection credentials and sets up the 
Session object
def conn = cf.createConnection("app", "test")
def sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE)

// 5 : Creates a Destination object
def destination = sess.createQueue(queueName)

conn.start()

log.info("#### Start completed!")

// 6 : Saves the object that will be shared among thread groups
System.getProperties().put("Session", sess)
System.getProperties().put("Connection", conn)
System.getProperties().put("Destination", destination)

// 7 : Set the “setupDone” to “true” so the “If Controller” cannot be executed 
two times in this run.
vars.put("setupDone", "true")
import javax.jms.TextMessage
import javax.jms.BytesMessage

import java.time.LocalDate
import java.time.LocalTime
import java.time.Instant
import java.time.format.DateTimeFormatter

// 1 : Take reference of the shared objects: Session and MQ Destination
def sess = System.getProperties().get("Session")
def destination = System.getProperties().get("Destination")

// 2 : Create a new consumer
def consumer = sess.createConsumer(destination)

def start = Instant.now()

// 3 : Look for an incoming message from the consumer using a 1 second timeout
def msg = consumer.receive(1000)

def stop = Instant.now()

// 4 : Receive API with timeout can return “null” when no message is available
if (msg != null) {
            // 5 : Take the data from the incoming message, format a String 
with the data and place into a SampleResult so it can be seen in a JMeter 
listener (this is a sample piece of code).
        if (msg instanceof BytesMessage) {
                def tmp = msg.asType(BytesMessage)
                log.debug("#### Incoming BytesMessage contains " + 
tmp.getBodyLength() + " bytes")
        } else if (msg instanceof TextMessage) {
                def tmp = msg.asType(TextMessage)
                log.debug("#### Incoming TextMessage contains -> " + 
tmp.getText())
        } else
                log.debug("#### Incoming message has unexpected format!")

            // 6 : Parse IBM MQ properties related to the timestamp of the “put 
message” (this is a sample piece of code).
        LocalDate date = 
LocalDate.parse(msg.getStringProperty("JMS_IBM_PutDate"),
                                        DateTimeFormatter.ofPattern("uuuuMMdd"))
        LocalTime time = 
LocalTime.parse(msg.getStringProperty("JMS_IBM_PutTime"),
                                        DateTimeFormatter.ofPattern("HHmmssSS"))

        // 7 : Display the message put time in IBM MQ and in UTC (Universal 
Time Coordinated).
            def timestampDetail = String.format("#### Incoming message was 
placed in queue @ %s - %s", date, time)
        log.info(timestampDetail)

        // 8 : Add information to the SampleResult object that can be seen in 
the Listeners
            SampleResult.setResponseData(msg.toString() + "\n\n" + 
timestampDetail)
        SampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT )
        SampleResult.setLatency( stop.toEpochMilli() - start.toEpochMilli() )

} else {
        log.info("#### Nothing to fetch!")
}

// 9 : Close the consumer
consumer.close()
// 1 :Invoke the close Session and Connection objects (for saving machine 
resources)
System.getProperties().get("Session").close()
System.getProperties().get("Connection").close()

log.info("#### Stop completed!")

// 2 : Set the “stopDone” to “true” in manner that “If Controller” cannot be 
executed two times into this run
vars.put("stopDone", "true")
import java.time.Instant

// 1 : Take reference of the shared objects: Session and MQ Destination. These 
objects are used to establish a connection to the IBM MQ service.
def sess = System.getProperties().get("Session")
def destination = System.getProperties().get("Destination")

// 2 : Create a new producer
def producer = sess.createProducer(destination)

// 3 : Used just to add a random time value (for differentiating the messages 
in the results)
def rnd = new Random(System.currentTimeMillis())

// 4 : Create a TextMessage and assign it a payload
def payload = String.format("{
                "Name":"ABCD"
                "ID":"12345"
                }", rndnextInt(Integer.MAX_VALUE))
def msg = sess.createTextMessage(payload)

def start = Instant.now()

 // 5 : Send message to IBM MQ
producer.send(msg)

def stop = Instant.now()

// 6 : Close the producer
producer.close()

// 7 : Add information to the SampleResult object that can be seen in Listeners
SampleResult.setResponseData(msg.toString())
SampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT )
SampleResult.setLatency( stop.toEpochMilli() - start.toEpochMilli() )
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@jmeter.apache.org
For additional commands, e-mail: user-h...@jmeter.apache.org

Reply via email to