Closed timonych closed 5 years ago
Yes, it is possible to use a JSR223 Sampler in conjunction with an ISO8583 Config element.
The config element would set up the Q2 components, however those are registered with dynamically created names, such as jmeter-3093b7bc-mux
(see https://github.com/tilln/jmeter-iso8583/blob/1.0/src/main/java/nz/co/breakpoint/jmeter/iso8583/ISO8583Config.java#L352) to avoid name clashes for tests with more than one config element.
So you would need some code to find the MUX that belongs to "Your ISO8583 Config" and use that for sending your messages.
For example, with Groovy:
import nz.co.breakpoint.jmeter.iso8583.ISO8583Config
import org.apache.jorphan.collections.SearchByClass
import static org.jpos.q2.iso.QMUX.getMUX
import static nz.co.breakpoint.jmeter.iso8583.MessagePrinter.asString
def mux = getMUX new SearchByClass(ISO8583Config.class).with {
// find all config elements in test plan:
ctx.engine.test.traverse(it)
// get dynamic mux name of "your" config element:
it.searchResults.find { it.name == 'Your ISO8583 Config' }.getMuxName()
}
// construct message:
def msg = new org.jpos.iso.ISOMsg()
msg.with {
setMTI('0800')
set(11, '123456')
// etc
}
// send message with timeout of 1000 milliseconds:
def response = mux.request(msg, 1000)
return response ? asString(response) : 'Timeout'
@tilln
Thansk for Guide and Example. Works Perfectly!
@timonych With this approach you would not be able to use the ISO8583 Crypto PreProcessor, and the request messages are not rendered in the results (View Results Tree or JTL file) though.
As an alternative that may still meet your requirement to programmatically build or extend the messages I would suggest looking at using an ISO85383 Sampler in conjunction with a JSR223 PreProcessor (or JSR223 PostProcessor for response processing), which is what I had in mind when creating this plugin.
This way you can use sampler methods like
to modify the message, then apply crypto operations and send/receive with this plugin.
For example:
sampler.with {
addField('0', '0800')
addField('11', '123456')
}
Hello,
Is it possible to use JSR223 Sampler with Groovy to send ISO message?
It's more flexible to use parameters and body as template.