带有 .Net Core 2.2 的 WebsphereMQ [英] WebsphereMQ with .Net Core 2.2

查看:27
本文介绍了带有 .Net Core 2.2 的 WebsphereMQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 .Net Core 2.2 连接到 WebsphereMQ 队列.我真的很困惑如何做到这一点.在展示我正在尝试(和失败)之前,我想澄清一下:

I'm trying to connect to a WebsphereMQ queue using .Net Core 2.2. I'm really confused on how to do this. I would like some clarification before showing what I'm trying (and failing):

  • 我应该使用哪个库以及如何获取它?(NMS?AMQP?WebsphereClient?)
    • 我看过一些示例,这些示例显然使用了安装 WebsphereMQ 时附带的某些 DLL (???).那是对的吗?我需要安装 WebsphereMQ 吗?(现在我在远程服务器上有它,我可以连接到我需要的队列).

    到目前为止我所尝试的是安装 WebSphereMQClient 并尝试连接到使用以下代码排队:

    What I have tried so far was installing the WebSphereMQClient and trying to connect to the queue with the following code:

        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);
            }
        }
    

    但我在第一行得到一个异常:

    But I get an exception on the first line:

    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 Standard.这个错误是因为它引起的吗?如何使用我的 .NET Core 应用程序连接到 Websphere?

    I have notice that the WebsphereMqClient is not compliant with .NET Standard. Is this error caused because of it? How can I connect to Websphere with my .NET Core app?

    谢谢,

    推荐答案

    amqmxmsstd.dll 是必须使用的库,可从 MQ v9.1.1 获得.以下是讨论在 Microsoft .NET Core 中使用 XMS 的信息中心链接.与 Microsoft 一起使用 XMS.NET 核心

    amqmxmsstd.dll is the library that has to be used and it is available from MQ v9.1.1. Following is the infocenter link which talks about using XMS with Microsoft .NET Core. Using XMS with Microsoft .NET Core

    您需要 amqmdnetstd.dll 和 amqmxmsstd.dll 来开发 XMS .NET 应用程序,并且这两个 dll 都是使用 .NET Standard 构建的.以下信息中心链接讨论了用于构建这些库的框架.安装 IBM MQ 类.NET 标准版

    You would need both amqmdnetstd.dll and amqmxmsstd.dll for developing XMS .NET applications and both these dll's are built using .NET Standard.Following infocenter link talks about the framework used to build these libraries. Installing IBM MQ classes for .NET Standard

    正如 Josh 指出的,您可以使用 MQ Redist 客户端来获取库.从 IBM MQ Redist 客户端

    As Josh pointed out,you can use MQ Redist client to get libraries. Download "9.1.1.0-IBM-MQC-Redist-Win64" from IBM MQ Redist clients

    这篇关于带有 .Net Core 2.2 的 WebsphereMQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆