作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找使用 MQI 实现消息分段的“正确”方法。
主要我需要实现接收部分,但出于测试目的我还想实现发送端。
也许我太笨了,无法正确搜索,但我还没有找到很多关于这个主题的文档/示例。迄今为止最好的解释: http://www.tek-tips.com/viewthread.cfm?qid=33458 (我认为这是从 ibm 开发人员 pdf 中获取的)。这是一些伪代码/无 Java 代码的一般解释。
mqget 调用有很多标志和可能性,也有对 mqueue 的简单访问。
我尝试过的代码示例将遵循,但也许有人对此有一些经验?
最佳答案
这个示例有帮助吗?如果消息长度超过队列的最大消息长度,我在这里允许队列管理器对消息进行分段。
MQQueue mqQueue = queueManager.accessQueue("SEG.Q", CMQC.MQOO_OUTPUT | CMQC.MQOO_INPUT_AS_Q_DEF | CMQC.MQOO_FAIL_IF_QUIESCING | CMQC.MQOO_PASS_ALL_CONTEXT);
/**
* Put a message and allow it to segmented if the length of each
* the message we are putting exceeds the maximum message length.
* For test purpose, the maximum message length has been set to
* 500 bytes on queue.
*/
MQMessage msgPut = new MQMessage();
byte [] largeBuffer = new byte[2000];
for(int i = 0; i< 2000; i++){
largeBuffer[i] = 'A';
}
msgPut.write(largeBuffer);
msgPut.messageFlags = MQConstants.MQMF_SEGMENTATION_ALLOWED;
MQPutMessageOptions pmo = new MQPutMessageOptions();
mqQueue.put(msgPut,pmo);
System.out.println("Message put successful");
/* Now receive the same message but as a complete message
* instead of segments
*/
MQMessage msgGet = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = CMQC.MQGMO_COMPLETE_MSG;
mqQueue.get(msgGet,gmo);
关于java - IBM MQI : How to implement message segmentation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29409206/
我正在寻找使用 MQI 实现消息分段的“正确”方法。 主要我需要实现接收部分,但出于测试目的我还想实现发送端。 也许我太笨了,无法正确搜索,但我还没有找到很多关于这个主题的文档/示例。迄今为止最好的解
我是一名优秀的程序员,十分优秀!