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):
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,
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
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
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