我正在尝试在MQ消息上设置自定义标头,但是当我这样做时,我得到一个MQException(2142),其中2195也写入StdErr。在下面的代码中,有一个mqMessage.setStringProperty的调用...如果我删除该行,这个代码可以工作。我想按照我在这里看到的内容:How to use JMS Properties on IBM MQ JMS Interface?
private MQQueueManager qm;
private MQQueue queue;
private void initialize() throws Exception {
MQEnvironment.hostname = "myhost";
MQEnvironment.port = 1234;
MQEnvironment.channel = "channelname";
qm = new MQQueueManager( "QMgrName" );
queue = qm.accessQueue(
"QueueName",
CMQC.MQOO_OUTPUT | CMQC.MQOO_FAIL_IF_QUIESCING );
}
private void sendMessage() throws Exception {
MQMessage mqMessage = new MQMessage();
mqMessage.format = CMQC.MQFMT_STRING;
mqMessage.messageId = CMQC.MQMI_NONE;
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = CMQC.MQPMO_NO_SYNCPOINT;
// The problem line
mqMessage.setStringProperty("header.name", "value");
mqMessage.writeString( "This is a test");
queue.put(mqMessage, pmo);
}
答案 0 :(得分:0)
问题是您的变量名称无效:
" header.name"
将其更改为headerName,它将起作用。