简体   繁体   English

带有.Net Core 2.2的WebsphereMQ

[英]WebsphereMQ with .Net Core 2.2

I'm trying to connect to a WebsphereMQ queue using .Net Core 2.2. 我正在尝试使用.Net Core 2.2连接到WebsphereMQ队列。 I'm really confused on how to do this. 我真的很困惑如何做到这一点。 I would like some clarification before showing what I'm trying (and failing): 在显示我正在尝试(和失败)的内容之前,我需要澄清一下:

  • Which lib should I use and how to get it? 我应该使用哪个库以及如何获取它? (NMS? AMQP? WebsphereClient?) (NMS?AMQP?WebsphereClient?)
    • I have seen some examples that aparentlly use some DLL that comes when you install WebsphereMQ (???). 我已经看到一些示例,这些示例通常使用安装WebsphereMQ(???)时附带的某些DLL。 Is that correct? 那是对的吗? Do I need to install WebsphereMQ? 我需要安装WebsphereMQ吗? (right now I have it in a remote server which I can connect to the queue I need). (现在,我将它放在可以连接到所需队列的远程服务器中)。

What I have tried so far was installing the WebSphereMQClient and trying to connect to the queue with the following code: 到目前为止,我已经尝试安装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);
        }
    }

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).

I have notice that the WebsphereMqClient is not compliant with .NET Standard. 我注意到WebsphereMqClient不符合.NET标准。 Is this error caused because of it? 是由于该错误引起的吗? How can I connect to Websphere with my .NET Core app? 如何使用.NET Core应用程序连接到Websphere?

Thanks, 谢谢,

amqmxmsstd.dll is the library that has to be used and it is available from MQ v9.1.1. amqmxmsstd.dll是必须使用的库,可以从MQ v9.1.1中获得。 Following is the infocenter link which talks about using XMS with Microsoft .NET Core. 以下是信息中心链接,该链接讨论将XMS与Microsoft .NET Core一起使用。 Using XMS with Microsoft .NET Core 在Microsoft .NET Core中使用XMS

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. 您将需要amqmdnetstd.dll和amqmxmsstd.dll来开发XMS .NET应用程序,并且这两个dll都是使用.NET Standard构建的。以下信息中心链接介绍了用于构建这些库的框架。 Installing IBM MQ classes for .NET Standard 安装适用于.NET Standard的IBM MQ类

As Josh pointed out,you can use MQ Redist client to get libraries. 如Josh所指出的,您可以使用MQ Redist客户端来获取库。 Download "9.1.1.0-IBM-MQC-Redist-Win64" from IBM MQ Redist clients IBM MQ Redist客户端下载“ 9.1.1.0-IBM-MQC-Redist-Win64”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM