没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
public static void sendMsg(String msgStr) {
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE;
System.out.println("发送openOptions=="+openOptions);
MQQueue queue = null;
try {
// 建立Q1通道的连接
System.out.println("准备连接队列:"+queueString);
queue = qMgr.accessQueue(queueString, openOptions, null, null, null);
System.out.println("队列连接成功");
MQMessage msg = new MQMessage();// 要写入队列的消息
msg.format = MQC.MQFMT_STRING;
msg.characterSet = 1381;
msg.encoding = 1381;
// msg.writeObject(msgStr); //将消息写入消息对象中
msg.writeString(msgStr);
MQPutMessageOptions pmo = new MQPutMessageOptions();
msg.expiry = -1; // 设置消息用不过期
queue.put(msg, pmo);// 将消息放入队列
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (queue != null) {
try {
queue.close();
} catch (MQException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE;
System.out.println("发送openOptions=="+openOptions);
MQQueue queue = null;
try {
// 建立Q1通道的连接
System.out.println("准备连接队列:"+queueString);
queue = qMgr.accessQueue(queueString, openOptions, null, null, null);
System.out.println("队列连接成功");
MQMessage msg = new MQMessage();// 要写入队列的消息
msg.format = MQC.MQFMT_STRING;
msg.characterSet = 1381;
msg.encoding = 1381;
// msg.writeObject(msgStr); //将消息写入消息对象中
msg.writeString(msgStr);
MQPutMessageOptions pmo = new MQPutMessageOptions();
msg.expiry = -1; // 设置消息用不过期
queue.put(msg, pmo);// 将消息放入队列
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (queue != null) {
try {
queue.close();
} catch (MQException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}







资源评论

- #标题与内容不符
- #内容缺失
- #文件乱码
- #引导二次消费
- #需要密码
- #运行出错
- #毫无价值
- #上传者态度恶劣
- #无法联系上传者
wiv3871
- 粉丝: 3
- 资源: 678

上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
已下载
下载帮助

资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
