带有 .Net Core 2.2 的 WebsphereMQ
WebsphereMQ with .Net Core 2.2
我正在尝试使用 .Net Core 2.2 连接到 WebsphereMQ 队列。
我真的很困惑如何做到这一点。在展示我正在尝试(和失败)的内容之前,我想澄清一下:
- 我应该使用哪个库以及如何获取它? (NMS?AMQP?WebsphereClient?)
- 我看到一些示例显然使用了安装 WebsphereMQ 时附带的一些 DLL (???)。那是对的吗?我需要安装 WebsphereMQ 吗? (现在我把它放在远程服务器上,我可以连接到我需要的队列)。
到目前为止我尝试的是安装 WebSphereMQClient 并尝试使用以下代码连接到队列:
public void StartListener()
{
try
{
var xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
var cf = xff.CreateConnectionFactory();
cf.SetStringProperty(XMSC.WMQ_HOST_NAME, WebsphereMqHost);
cf.SetIntProperty(XMSC.WMQ_PORT, WebsphereMqPort);
cf.SetStringProperty(XMSC.WMQ_CHANNEL, WebsphereMqChannel);
cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, WebsphereMqQueueManager);
cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
var conn = cf.CreateConnection();
var sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
var queue = sess.CreateQueue(QueueName);
var consumer = sess.CreateConsumer(queue);
consumer.MessageListener = OnWebsphereMsg;
conn.Start();
}
catch (Exception e)
{
_logger.LogError(e);
}
}
但是我在第一行得到一个异常:
System.Exception: Fatal error. Failed to initialize XMSFactoryFactory ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'IBM.XMS.Client.Impl.XmsFactoryFactoryImpl' threw an exception. ---> System.TypeInitializationException: The type initializer for 'IBM.XMS.Util.Tr' threw an exception. ---> System.TypeInitializationException: The type initializer for 'IBM.XMS.Util.ConfigMgr' threw an exception. ---> System.MissingMethodException: Method not found: 'System.AppDomainSetup System.AppDomain.get_SetupInformation()'.
at IBM.XMS.Util.ConfigMgr..cctor()
--- End of inner exception stack trace ---
at IBM.XMS.Util.Tr.ResolveTraceSpec()
at IBM.XMS.Util.Tr.LoadTraceConfig()
at IBM.XMS.Util.Tr..cctor()
--- End of inner exception stack trace ---
at IBM.XMS.Util.Tr.Register(Type aClass, String group, String resourceBundleName)
at IBM.XMS.Client.Impl.XmsFactoryFactoryImpl..cctor()
--- End of inner exception stack trace ---
at IBM.XMS.Client.Impl.XmsFactoryFactoryImpl.GetClientFactory(Int32 connectionType)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at IBM.XMS.XMSFactoryFactory.GetXmsFactory(Int32 connectionType)
--- End of inner exception stack trace ---
at IBM.XMS.XMSFactoryFactory.GetXmsFactory(Int32 connectionType)
at IBM.XMS.XMSFactoryFactory.GetInstance(Int32 connectionType)
at MyApp.Integrations.Configurations.WebsphereMqIntegrationsManager.StartListener(ListenersEnum listener, Dictionary`2 parameters).
我注意到 WebsphereMqClient 不符合 .NET 标准。这个错误是因为它引起的吗?如何使用我的 .NET Core 应用程序连接到 Websphere?
谢谢,
amqmxmsstd.dll 是必须使用的库,它可以从 MQ v9.1.1 获得。以下是关于将 XMS 与 Microsoft .NET Core 结合使用的信息中心 link。
Using XMS with Microsoft .NET Core
您需要 amqmdnetstd.dll 和 amqmxmsstd.dll 来开发 XMS .NET 应用程序,并且这两个 dll 都是使用 .NET 构建的 Standard.Following infocenter link 谈论框架用于构建这些库。
Installing IBM MQ classes for .NET Standard
正如 Josh 所指出的,您可以使用 MQ Redist 客户端来获取库。
从 IBM MQ Redist clients
下载“9.1.1.0-IBM-MQC-Redist-Win64”
我正在尝试使用 .Net Core 2.2 连接到 WebsphereMQ 队列。 我真的很困惑如何做到这一点。在展示我正在尝试(和失败)的内容之前,我想澄清一下:
- 我应该使用哪个库以及如何获取它? (NMS?AMQP?WebsphereClient?)
- 我看到一些示例显然使用了安装 WebsphereMQ 时附带的一些 DLL (???)。那是对的吗?我需要安装 WebsphereMQ 吗? (现在我把它放在远程服务器上,我可以连接到我需要的队列)。
到目前为止我尝试的是安装 WebSphereMQClient 并尝试使用以下代码连接到队列:
public void StartListener()
{
try
{
var xff = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
var cf = xff.CreateConnectionFactory();
cf.SetStringProperty(XMSC.WMQ_HOST_NAME, WebsphereMqHost);
cf.SetIntProperty(XMSC.WMQ_PORT, WebsphereMqPort);
cf.SetStringProperty(XMSC.WMQ_CHANNEL, WebsphereMqChannel);
cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, WebsphereMqQueueManager);
cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
var conn = cf.CreateConnection();
var sess = conn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
var queue = sess.CreateQueue(QueueName);
var consumer = sess.CreateConsumer(queue);
consumer.MessageListener = OnWebsphereMsg;
conn.Start();
}
catch (Exception e)
{
_logger.LogError(e);
}
}
但是我在第一行得到一个异常:
System.Exception: Fatal error. Failed to initialize XMSFactoryFactory ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'IBM.XMS.Client.Impl.XmsFactoryFactoryImpl' threw an exception. ---> System.TypeInitializationException: The type initializer for 'IBM.XMS.Util.Tr' threw an exception. ---> System.TypeInitializationException: The type initializer for 'IBM.XMS.Util.ConfigMgr' threw an exception. ---> System.MissingMethodException: Method not found: 'System.AppDomainSetup System.AppDomain.get_SetupInformation()'.
at IBM.XMS.Util.ConfigMgr..cctor()
--- End of inner exception stack trace ---
at IBM.XMS.Util.Tr.ResolveTraceSpec()
at IBM.XMS.Util.Tr.LoadTraceConfig()
at IBM.XMS.Util.Tr..cctor()
--- End of inner exception stack trace ---
at IBM.XMS.Util.Tr.Register(Type aClass, String group, String resourceBundleName)
at IBM.XMS.Client.Impl.XmsFactoryFactoryImpl..cctor()
--- End of inner exception stack trace ---
at IBM.XMS.Client.Impl.XmsFactoryFactoryImpl.GetClientFactory(Int32 connectionType)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at IBM.XMS.XMSFactoryFactory.GetXmsFactory(Int32 connectionType)
--- End of inner exception stack trace ---
at IBM.XMS.XMSFactoryFactory.GetXmsFactory(Int32 connectionType)
at IBM.XMS.XMSFactoryFactory.GetInstance(Int32 connectionType)
at MyApp.Integrations.Configurations.WebsphereMqIntegrationsManager.StartListener(ListenersEnum listener, Dictionary`2 parameters).
我注意到 WebsphereMqClient 不符合 .NET 标准。这个错误是因为它引起的吗?如何使用我的 .NET Core 应用程序连接到 Websphere?
谢谢,
amqmxmsstd.dll 是必须使用的库,它可以从 MQ v9.1.1 获得。以下是关于将 XMS 与 Microsoft .NET Core 结合使用的信息中心 link。 Using XMS with Microsoft .NET Core
您需要 amqmdnetstd.dll 和 amqmxmsstd.dll 来开发 XMS .NET 应用程序,并且这两个 dll 都是使用 .NET 构建的 Standard.Following infocenter link 谈论框架用于构建这些库。 Installing IBM MQ classes for .NET Standard
正如 Josh 所指出的,您可以使用 MQ Redist 客户端来获取库。 从 IBM MQ Redist clients
下载“9.1.1.0-IBM-MQC-Redist-Win64”