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):
- Which lib should I use and how to get it? (NMS? AMQP? WebsphereClient?)
- I have seen some examples that aparentlly use some DLL that comes when you install WebsphereMQ (???). Is that correct? Do I need to install 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:
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. Is this error caused because of it? How can I connect to Websphere with my .NET Core app?
Thanks,