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 » General Discussion » Connecting MQ from VB.Net - Connection broken error

Post new topic  Reply to topic
 Connecting MQ from VB.Net - Connection broken error « View previous topic :: View next topic » 
Author Message
msdeepan
PostPosted: Wed Mar 07, 2012 9:43 pm    Post subject: Connecting MQ from VB.Net - Connection broken error Reply with quote

Newbie

Joined: 07 Mar 2012
Posts: 2

Hi,

I'm a newbie to IBM MQ.
In my project, i have to continiously watch a remote MQ, get the message and update my local database.
For this I have created a windows service(VB.Net) with single thread.

I have completed the coding and i'm able to connect to the queue and get messages. But after some time (10 mins approx.) we are getting the MQRC_CONNECTION_BROKEN error. We tested the connection settings, everything is fine. This error is thrown whenever the service has consumed all the availabe messages and waiting for new messages. I have posed my code below. Can anyone please validate it and let me know what i have done wrong.

Code:
Public Function Listen(ByVal a_qmName As String, ByVal a_queueName As String, ByVal a_qHost As String, ByVal a_qPort As Int32, ByVal a_qChannel As String, ByVal a_qDefinition As String) As String
Dim ls_ReturnMsg As String
        Dim lm_mqMessage As New MQMessage()
        Dim lh_qProperties As New Hashtable
        lh_qProperties(MQC.HOST_NAME_PROPERTY) = a_qHost
        lh_qProperties(MQC.PORT_PROPERTY) = a_qPort
        lh_qProperties(MQC.CHANNEL_PROPERTY) = a_qChannel

        Try
            Dim li_openOptions As Integer = MQC.MQOO_INPUT_AS_Q_DEF Or MQC.MQOO_FAIL_IF_QUIESCING
            Dim lqm_mqManager As New MQQueueManager(a_qmName, lh_qProperties)
            Dim lq_queue As MQQueue = lqm_mqManager.AccessQueue(a_queueName, li_openOptions)


            Dim lo_gmo As New MQGetMessageOptions()
            lo_gmo.Options = MQC.MQGMO_FAIL_IF_QUIESCING Or MQC.MQGMO_WAIT
            lo_gmo.WaitInterval = MQC.MQWI_UNLIMITED
            'wait for message
            lq_queue.[Get](lm_mqMessage, lo_gmo)
            lq_queue.Close()
            ls_ReturnMsg = lm_mqMessage.ReadString(lm_mqMessage.MessageLength)


            lo_OpvMqDB.WriteToErrorLog(a_queueName + ": Message Accessed.", ls_ReturnMsg)
            'release resource.
            lqm_mqManager = Nothing
            lq_queue = Nothing
            lo_gmo = Nothing
            System.GC.Collect()

 Catch MqEx As MQException
        LogError(a_queueName + ": MQ Error occured while accessing the queue." + MqEx.Message.ToString(), MqEx.ReasonCode.ToString() + " - " + MqEx.Message.ToString())
       ls_ReturnMsg = "Exception: " + a_queueName + " : Error occured while accessing the queue." + MqEx.Message.ToString()

 Catch lo_ex As Exception           
            lo_OpvMqDB.LogError(ls_QueueId + " - " + "Error occured while accessing the queue.", lo_ex.Message.ToString())
            ls_ReturnMsg = "Exception: " + a_queueName + " : Error occured while accessing the queue." + lo_ex.Message.ToString()
 End Try
 Return ls_ReturnMsg
End Function
Back to top
View user's profile Send private message
exerk
PostPosted: Thu Mar 08, 2012 12:35 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

Please enclose code within the appropriate tags (as I have done for you) as it makes it easier to read. Thank you.

I'm no developer, but are you actually closing the queue after every GET?

Code:
lq_queue.[Get](lm_mqMessage, lo_gmo)
lq_queue.Close()


And it's possible a firewall rule is reading your connection as stale and killing it, so talk to your network people and see what information they can provide.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
msdeepan
PostPosted: Thu Mar 08, 2012 12:54 am    Post subject: Reply with quote

Newbie

Joined: 07 Mar 2012
Posts: 2

Thanks for ur quick response jedi.. Actually the problem happens during wait only. Otherwise i'm able to access even there are hundreds of messages already pending in the queue
Back to top
View user's profile Send private message
exerk
PostPosted: Thu Mar 08, 2012 12:55 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

If you are pulling hundreds of messages from a queue a firewall will see the connection as active - and you haven't answered my question.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
ankurlodhi
PostPosted: Tue Mar 13, 2012 7:09 am    Post subject: Reply with quote

Master

Joined: 19 Oct 2010
Posts: 266

or it can be a matter of heartbeat intervel when the connection stays idle more the specified value in the heartbeat intervel the connection goes inactive state.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Mar 13, 2012 9:46 pm    Post subject: Reply with quote

Grand High Poobah

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

You really want to review releasing resources... you are not doing that
Also on the MQException you need to print out the reason code...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » Connecting MQ from VB.Net - Connection broken error
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.