是否有API可以从SQL Server存储过程连接到Websphere MQ队列并将消息放到队列中?
如果没有,实现这一目标的最好方法是什么?
发布于 2012-04-26 17:07:14
有一个比that..Check更简单的解决方案。
http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fbc34040_.htm
发布于 2011-09-22 17:40:27
为此,我将使用的解决方案是编写一个CLR存储过程并将其部署到SQL Server上。
在CLR存储过程中,我将使用MQ .NET。
更新:我使用以下代码创建了一个存储的进程:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using IBM.WMQ;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static int MQStoredProc(String queueManager, String queueName, String messageText)
{
//MQEnvironment.Hostname = "localhost";
//MQEnvironment.Port = 1414;
//MQEnvironment.Channel = "SYSTEM.DEF.SVRCONN";
MQQueueManager mqQMgr = null; // MQQueueManager instance
MQQueue mqQueue = null; // MQQueue instance
try
{
mqQMgr = new MQQueueManager(queueManager);
mqQueue = mqQMgr.AccessQueue(queueName, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING); // open queue for output but not if MQM stopping
if (messageText.Length > 0)
{
// put the next message to the queue
MQMessage mqMsg = new MQMessage();
mqMsg.WriteString(messageText);
mqMsg.Format = MQC.MQFMT_STRING;
MQPutMessageOptions mqPutMsgOpts = new MQPutMessageOptions();
mqQueue.Put(mqMsg, mqPutMsgOpts);
}
return 0;
}
catch (MQException mqe)
{
return ((int)mqe.Reason);
}
finally
{
if (mqQueue != null)
mqQueue.Close();
if (mqQMgr != null)
mqQMgr.Disconnect();
}
}
};这还不是生产就绪,但在绑定模式下与SQL服务器相同的服务器上运行的队列管理器上成功插入了消息。
发布于 2011-09-22 14:58:06
我能想到的最简单的方法是,将信息写入一个文件,然后使用rfhutil将消息导出到队列中。这将需要手动干预。另一种选择是使用JMS和JDBC编写一个简单的java应用程序。
https://stackoverflow.com/questions/7499696
复制相似问题