diff --git a/README.md b/README.md index 113002a..6931d5b 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ Use it to put and get message (optional) on MQ queue. On JMeter add a Java Reque * **mq_use_mqcsp_authentication**: The connection authentication used. Set false for Compatibility mode, or true for MQCSP authentication. * **mq_encoding_message**: Character encoding standard for your message: For EBCDIC put Cp1047. ASCII just put ASCII. * **mq_message**: The content of the message that you want. +* **mq_message_format**: MQMD Message [Format](https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.ref.dev.doc/q097520_.htm). + You can set one of the values in constants [CMQC.MQFMT_*](https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.javadoc.doc/WMQJavaClasses/constant-values.html#com.ibm.mq.constants.CMQC.MQFMT_STRING). + For example, the value of constant `CMQC.MQFMT_STRING` - `MQSTR `. #### Put & Get Message on Queue diff --git a/pom.xml b/pom.xml index 6afbc5f..93959a8 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 mqmeter mqmeter - 2.1.1 + 2.1.2 mqmeter MQ plugin for Jmeter diff --git a/src/main/java/co/signal/mqmeter/MQClientSampler.java b/src/main/java/co/signal/mqmeter/MQClientSampler.java index e66da05..cfe2a0a 100644 --- a/src/main/java/co/signal/mqmeter/MQClientSampler.java +++ b/src/main/java/co/signal/mqmeter/MQClientSampler.java @@ -117,6 +117,11 @@ public class MQClientSampler extends AbstractJavaSamplerClient { */ private static final String PARAMETER_MQ_WAIT_INTERVAL = "mq_wait_interval"; + /** + * Parameter for setting MQ Message Format. + */ + private static final String PARAMETER_MQ_MESSAGE_FORMAT = "mq_message_format"; + /** * Parameter for encoding. */ @@ -167,6 +172,7 @@ public Arguments getDefaultParameters() { defaultParameter.addArgument(PARAMETER_MQ_USE_MQCSP_AUTHENTICATION,"${MQ_USE_MQCSP_AUTHENTICATION}"); defaultParameter.addArgument(PARAMETER_MQ_ENCODING_MESSAGE, "${MQ_ENCODING_MESSAGE}"); defaultParameter.addArgument(PARAMETER_MQ_MESSAGE, "${MQ_MESSAGE}"); + defaultParameter.addArgument(PARAMETER_MQ_MESSAGE_FORMAT, "${MQ_MESSAGE_FORMAT}"); return defaultParameter; } @@ -310,6 +316,8 @@ public SampleResult runTest(JavaSamplerContext context) { private byte[] putMQMessage(JavaSamplerContext context, String message) throws MQException, IOException { MQMessage mqMessage = new MQMessage(); + String messageFormat = context.getParameter(PARAMETER_MQ_MESSAGE_FORMAT); + if (!"${MQ_MESSAGE_FORMAT}".equals(messageFormat) && !"null".equals(messageFormat)) mqMessage.format = messageFormat; log.info("Sending a message..."); mqMessage.write(message.getBytes(encodingMessage)); mqQueuePut.put(mqMessage, new MQPutMessageOptions());