ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » How can check XMS connection state?

Post new topic  Reply to topic
 How can check XMS connection state? « View previous topic :: View next topic » 
Author Message
kugynok
PostPosted: Tue Jul 29, 2014 8:18 am    Post subject: How can check XMS connection state? Reply with quote

Newbie

Joined: 21 Jul 2014
Posts: 7

Hi all!

I use IBM MQ 7.5 MXS .NET, and I want implement to reconnection, but I dont find the connection state.

How can check connection state is LIVE?
Help me please!
Thank you!

K.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jul 29, 2014 10:07 am    Post subject: Re: How can check XMS connection state? Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

kugynok wrote:
Hi all!

I use IBM MQ 7.5 MXS .NET, and I want implement to reconnection, but I dont find the connection state.

How can check connection state is LIVE?
Help me please!
Thank you!

K.


The connection state is checked on each API call.
If you use asynchronous delivery you may want to only use an unmanaged connection and be sure you add an exception listener to the connection. (prior to V8 )
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kugynok
PostPosted: Tue Jul 29, 2014 8:55 pm    Post subject: Reply with quote

Newbie

Joined: 21 Jul 2014
Posts: 7

Hi!

I do not fully understand what you wrote, can you explain to me?

I use an unmanaged connection and add an exception listener to the connection. But how can resolve when connection was broken? Need to reconnection manual or automatic?

Thank you!

K.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jul 30, 2014 4:27 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

kugynok wrote:
Hi!

I do not fully understand what you wrote, can you explain to me?

I use an unmanaged connection and add an exception listener to the connection. But how can resolve when connection was broken? Need to reconnection manual or automatic?

Thank you!

K.

Depends on the type of connection (bindings vs client), how it was broken, how long it was broken for etc...
What have you tested so far?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kugynok
PostPosted: Wed Jul 30, 2014 4:48 am    Post subject: Reply with quote

Newbie

Joined: 21 Jul 2014
Posts: 7

Client connection:

Code:

Code:
 public void Connect(string username, string password, string ip, int port, int reconnectTime, string qmName, string chName, string queueIn)
        {


            try
            {
                //Create connection
                XMSfactoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
                Connectionfactory = XMSfactoryFactory.CreateConnectionFactory();

                Connectionfactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, qmName);
                Connectionfactory.SetStringProperty(XMSC.WMQ_HOST_NAME, ip);
                Connectionfactory.SetIntProperty(XMSC.WMQ_PORT, port);
                Connectionfactory.SetStringProperty(XMSC.WMQ_CHANNEL, chName);
                Connectionfactory.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V2);
                Connectionfactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT_UNMANAGED);

                // In case of network issues - reconnect to same queue manager
                Connectionfactory.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, XMSC.WMQ_CLIENT_RECONNECT_Q_MGR);
                Connectionfactory.SetStringProperty(XMSC.WMQ_CONNECTION_NAME_LIST, String.Format("{0}({1})", ip, port));
                Connectionfactory.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT, reconnectTime); ;

                if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    Connection = Connectionfactory.CreateConnection(username, password);
                }
                else
                {
                    Connection = Connectionfactory.CreateConnection();
                }
                Connection.ExceptionListener = new ExceptionListener(XMSExceptionHandler);

                Connection.Start();
                MqConnected = true;

                Log.AddDbAndFile("Az MQ csatlakozott! \r\n", "I",
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType +
                        "." + System.Reflection.MethodBase.GetCurrentMethod().Name);

            }
            catch (XMSException e)
            {
                CheckConnection(e);
                IniFile.Error = "Nincs kapcsolat az MQ szerverrel!";

                Log.AddDbAndFile("Hiba történt! \r\n" +
                    e.ToString() + " \r\n", "E",
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType +
                        "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception e)
            {
                IniFile.Error = "Nincs kapcsolat az MQ szerverrel!";

                Log.AddDbAndFile("Hiba történt! \r\n" +
                    e.ToString() + " \r\n", "E",
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType +
                        "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
            }
        }


private void CheckConnection(XMSException exception)
        {
            if (exception.ErrorCode == "CWSMQ0006")
            {
                this.MqConnected = false;
            }
            else
            {
                this.MqConnected = true;
            }

            if(exception.ErrorCode=="XMSWMQ2014")
            {
                this.MqConnected = false;
                Session = null;
                Connection = null;
            }
        }

        private void XMSExceptionHandler(Exception e)
        {
            if (e is XMSException)
            {
                var ex = e as XMSException;
                IniFile.Error = "MQ hiba: " + ex.ErrorCode;
                CheckConnection(e as XMSException);
            }
           
            Log.AddDbAndFile("Hiba történt! \r\n" +
                    e.ToString() + " \r\n", "E",
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType +
                        "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
        }





Tested:

1. Create Connection
2. MQ server off
3. Try get message (( Connection.CreateSession)I catched the exception: Error Code: XMSWMQ2014)
4. Session.CreateConsume(Dest) (thow nullRefencesObject exception)

I try resolve this problem.

Thank You for help me!

K.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » How can check XMS connection state?
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.