Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parameter mq_message_format. #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>mqmeter</groupId>
<artifactId>mqmeter</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>

<name>mqmeter</name>
<description>MQ plugin for Jmeter</description>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/co/signal/mqmeter/MQClientSampler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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());
Expand Down