KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
1.) From a .net client, how do I test if the client is connected to the server (i.e. can send and receive) Yes, I could send a message inside a try block and catch the ensuing exception but I'm hoping for a more elegant solution. 2) How do I open, close, and re-open connections? In my attempts to resolve question 1 above I discovered that if I open a connection then call connection.Close() I am not able to obtain another connection from the connection factory (see code fragment below). I receive error message XMSCC0008 I am using a very standard vanilla MQ configuration . Here is how my client connects: ISession session = MQAccess.GetSession(MQAccess.Connection); IDestination destination = session.CreateTopic(SubTopicName); Consumer = MQAccess.GetConsumer(session, destination); Consumer.MessageListener = new MessageListener(HandleMQSubEvent); MQAccess.Connection.Start(); where MQAccess is a small utility class. Edited the question to add MQAccess code: public static class MQAccess { public static readonly MQConfigurationSectionHandler ConfigSettings; public static readonly IConnectionFactory ConnectionFactory; private static readonly IConnection connection; public static IConnection Connection { get { return connection; } } static MQAccess() { ConfigSettings = (MQConfigurationSectionHandler) ConfigurationManager.GetSection("mq-configuration"); XMSFactoryFactory factory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ); ConnectionFactory = factory.CreateConnectionFactory(); ConnectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, ConfigSettings.Hostname); ConnectionFactory.SetIntProperty(XMSC.WMQ_PORT, ConfigSettings.Port); ConnectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, ConfigSettings.Channel); if (ConfigSettings.QueueManager == string.Empty) { Connection
Tags (comma-separated)
Save Edits
Cancel