永发信息网

请教WebSphere MQ CCSID问题

答案:2  悬赏:40  手机版
解决时间 2021-02-25 21:23
请教WebSphere MQ CCSID问题
最佳答案
websphere mq : 用于传输信息 具有跨平台的功能。
1 安装websphere mq 并启动
2 websphere mq 建立 queue Manager (如:MQSI_SAMPLE_QM)
3 建立queue 类型选择 Local类型 的 (如lq )
3 建立channels 类型选择Server Connection (如BridgeChannel)

java 代码如下:

package test.mq;
import com.ibm.mq.*;

public class FirstMqTest {
// public static void main(String[] args[]){
// FirstMqTest first = new FirstMqTest();
// first.test();
// }
public static void main(String args[]){
FirstMqTest first = new FirstMqTest();
first.test();

}
public void test(){
String qManager = "MQSI_SAMPLE_QM"; //QueueManager name
String qName = "lq";//Queue Name
try {
//configure connection parameters
MQEnvironment.hostname="172.16.17.123";//MQ Server name or IP
//MQEnvironment.port=1414;//listenr port
MQEnvironment.channel="BridgeChannel";//Server-Connection Channel
MQEnvironment.CCSID =1381;
// Create a connection to the QueueManager
System.out.println("Connecting to queue manager: "+qManager);
MQQueueManager qMgr = new MQQueueManager(qManager);
// Set up the options on the queue we wish to open
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
// Now specify the queue that we wish to open and the open options
System.out.println("Accessing queue: "+qName);
MQQueue queue = qMgr.accessQueue(qName, openOptions);
// Define a simple WebSphere MQ Message ...
MQMessage msg = new MQMessage();
// ... and write some text in UTF8 format
msg.writeUTF("Hello, World!");
// Specify the default put message options
MQPutMessageOptions pmo = new MQPutMessageOptions();
// Put the message to the queue
System.out.println("Sending a message...");


for(int j=0;j< 5;j++){
String str ="test11111111111";
str = str+j;
msg.writeUTF(str);
queue.put(msg, pmo);
}
queue.put(msg, pmo);
// Now get the message back again. First define a WebSphere MQ message
// to receive the data
MQMessage rcvMessage = new MQMessage();

// Specify default get message options
MQGetMessageOptions gmo = new MQGetMessageOptions();
// Get the message off the queue.
System.out.println("...and getting the message back again");
queue.get(rcvMessage, gmo);
// And display the message text...
String msgText = rcvMessage.readUTF();
System.out.println("The message is: " + msgText);
// Close the queue
System.out.println("Closing the queue");
queue.close();
// Disconnect from the QueueManager
System.out.println("Disconnecting from the Queue Manager");
qMgr.disconnect();
System.out.println("Done!");
}
catch (MQException ex) {
System.out.println("A WebSphere MQ Error occured : Completion Code "
+ ex.completionCode + " Reason Code " + ex.reasonCode);
}
catch (java.io.IOException ex) {
System.out.println("An IOException occured whilst writing to the message buffer: "
+ ex);
}
}
}
全部回答
快速学习就得花大量时间集中学习,那样就能在短时间内掌握。 找本书,装个mq,一边看书,一边学习。 推荐两本mq入门的中文版的书籍: 《精通websphere mq》 《ibm websphere mq 基础教程》 特别推荐后面那本 如果您认可我的答案,请采纳。 您的采纳,是我答题的动力,o(∩_∩)o谢谢!!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
【涸辙之鱼】涸辙之鱼的主要内容写什么
海参怎么煮给小孩吃
侨宾旅馆地址在什么地方,想过去办事
它凝固了变成蒸汽不是升华了吗?
专属狮子座的图案密码锁屏
请问作为师范类院校的贵州师范大学,每年会给
窗外人生王呈伟阅读答案
手机qq怎么把上面电量显示哪些都盖住了
数学(过程)
有人喝醉酒来超市闹事骂人还要打我来不及报警
鹿皮鞋上滴了一滴油,怎么清洗啊?淘宝上一般
剑豪和念帝哪个更下水道
卡宾这个地址在什么地方,我要处理点事
Mary and I ____sisters
【双城记简介】双城记内容简介英文150字
推荐资讯
如图,∠BAC是钝角,AB=AC,D,E分别在AB,AC上,且
一般较为经济的住宅,其单元数(个)和房屋长
海魂百姓鞋城我想知道这个在什么地方
bluenile上买钻石 靠谱吗
无双赵子龙武将怎么得 武将招募系统介绍
2016年9月通辽去长春的最好走公路路线
监控摄像头对于某些犯罪有没有用的;可以摄像
森林幼儿艺术乐园地址在哪,我要去那里办事
steam的文件夹里哪个文件夹可以看到dlc
万里超市地址在哪,我要去那里办事
安邦保险银保内勤怎么样
温神是什么意思
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?