import com.ibm.mq.*;
import java.util.Properties;
public class MQSender
{
// define the name of the QueueManager
private static String qManager;
// and define the name of the Queue
private static String qName;
// main method: simply call the runSample() method
public static void main(String args[])
{
if (args == null || args.length != 2)
{
System.out.println("need two arguments: <Queue Name> <message>");
System.exit(0);
}
new MQSender().runSender(args);
}
public void runSender(String args[])
{
qName = args[0];
qManager = System.getProperty ("message.queue.manager");
try
{
// Create a connection to the QueueManager
System.out.println("Connecting to queue manager: "+qManager);
MQEnvironment.channel = System.getProperty ("message.chanel.name");
MQEnvironment.hostname = System.getProperty ("message.queue.server");
MQEnvironment.port = new Integer ((System.getProperty ("message.queue.port"))).intValue();
MQEnvironment.CCSID = new Integer ((System.getProperty ("message.queue.ccsid"))).intValue();
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;
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
// 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.writeString (args[1]);
// Specify the default put message options
MQPutMessageOptions pmo = new MQPutMessageOptions();
// Put the message to the queue
System.out.println("Sending a message...");
queue.put(msg);
// 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);
}
}
}
分享到:
相关推荐
IBM WebSphere MQ 支持两种不同的应用程序编程接口:Java 消息服务(JMS)和消息队列接口(MQI)。在 IBM WebSphere MQ 服务器上,JMS 绑定方式被映射到 MQI。应用程序直接与其本地队列管理器通过使用 MQI 进行对话...
它提供了额外的功能,包括消息编辑、分析、备份/恢复、队列清除、队列和通道状态监控、将对象属性输出到 csv 等等......这个开源应用程序是用 Java 1.8 编写的,使用 NetBeans IDE 8.2 . 当前使用 IBM MQ 客户端库 ...
IBM MQ消息队列所需的jar包:IBM WebSphere MQ 支持两种不同的应用程序编程接口:Java 消息服务(JMS)和消息队列接口(MQI)。
它提供了额外的功能,包括消息编辑,分析,备份/还原,队列清除,队列和通道状态监视,将对象属性输出到csv等。...此开源应用程序是用Java 1.8编写的,并使用NetBeans IDE 8.2。 。 当前正在使用IBM MQ客户端库8.0...
本人自学IBM的WebSphereMQ自学笔记,内有MQ安装文档,建MQ的例子等。 1、 MQ6.0安装 2 1.1 启动MQ v6.0 安装程序 2 1.2 软件需求检查 2 1.3 WebSphere Eclipse Platform V3.0.1软件安装 2 1.4 网络配置检查 3 1.5 ...
WebSphere® MQ (也称...IBM 消息中间件MQ以其独特的安全机制、简便快速的编程风格、卓越不凡的稳定性、可扩展性和跨平台性,以及强大的事务处理能力和消息通讯能力,成为业界市场占有率最高的消息中间件产品。
WebSphere® MQ (也称...IBM 消息中间件MQ以其独特的安全机制、简便快速的编程风格、卓越不凡的稳定性、可扩展性和跨平台性,以及强大的事务处理能力和消息通讯能力,成为业界市场占有率最高的消息中间件产品。
学习使用WebSphere MQ for Java编程。 WebSphere MQ for Java允许用Java 编程语言写成的程序直接访问WebSphere MQ Server,或作为一个WebSphere MQ Client连接到WebSphere MQ。
IBM WebSphere MQ 支持两种不同的应用程序编程接口:Java 消息服务(JMS)和消息队列接口(MQI)。在 IBM WebSphere MQ 服务器上,JMS 绑定方式被映射到 MQI。应用程序直接与其本地队列管理器通过使用 MQI 进行对话...
WebSphere® MQ (也称...IBM 消息中间件MQ以其独特的安全机制、简便快速的编程风格、卓越不凡的稳定性、可扩展性和跨平台性,以及强大的事务处理能力和消息通讯能力,成为业界市场占有率最高的消息中间件产品。
WebSphere® MQ (也称...IBM 消息中间件MQ以其独特的安全机制、简便快速的编程风格、卓越不凡的稳定性、可扩展性和跨平台性,以及强大的事务处理能力和消息通讯能力,成为业界市场占有率最高的消息中间件产品。
同样,WebSphere MQ 消息传递的事务性本质表明来自浏览器的简单请求可以使用事务性方法安全地扩充到单独的后端进程序列。 WebSphere MQ Java 类还能使应用程序开发人员利用 Java 编程语言的强大功能创建能够在任何...
这个想法是构建一个更简单的系统版本,比如 Apache ActiveMQ、IBM MQ 系列或 JBoss Messaging。 我们使用 Java 作为编程语言,使用 PostgreSQL 作为数据库。 该系统分为三层:客户端、消息中间件和数据库。 系统...
WinMM的功能类似于IBM的MQ功能。队列缓冲可以保证信息的安全。同时WinMM还具有自我清理功能——死信清理。对于没有及时被处理的信息,在一定时间后,可以认为它是死信,因此,被放置到死信队列。 下面是使用WinMM...
消息传递指的是程序之间通过在消息中发送数据进行通信,而不是通过直接调用彼此来通信,直接调用通常是用于诸如远程过程调用的技术。排队指的是应用程序通过 队列来通信。队列的使用除去了接收和发送应用程序同时...