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 » dotnet MQ V7 - overwriting MQMessage object

Post new topic  Reply to topic
 dotnet MQ V7 - overwriting MQMessage object « View previous topic :: View next topic » 
Author Message
hopsala
PostPosted: Wed Aug 04, 2010 4:23 am    Post subject: dotnet MQ V7 - overwriting MQMessage object Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

My dotnet extravaganza continues. We've been getting System.AccessViolationException on queue.Get() statements.

Sadly I can't post the real code, but here's the general idea:
Code:
...
MQMessage msg = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.Options = MQC.MQGMO_BROWSE_FIRST + MQC.MQGMO_LOCK + MQC.GET_WAIT;
queue.Get(msg, gmo);
...
gmo.Options = MQC.MQGMO_UNLOCK;
queue.Get(msg, gmo);

The first Get() call returns normally with a message and some data, the second crashes with AccessViolationException. When I change Options before the second Get() to MQGMO_GET_MESSAGE_UNDER_CURSOR it works fine.

I suspect the problem is that we try to get with an MQMessage object that already contains a message, but I'm not sure if this is how dotnet behaves, nor was I able to find anything in the lit or samples. Possibly this is just a bug and I should open a PMR.

Basically my question is - can you queue.Get() twice on the same MQMessage object?

Thanks!
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Aug 04, 2010 4:48 am    Post subject: Re: dotnet MQ V7 - overwriting MQMessage object Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

hopsala wrote:
The first Get() call returns normally with a message and some data, the second crashes with AccessViolationException. When I change Options before the second Get() to MQGMO_GET_MESSAGE_UNDER_CURSOR it works fine.


Accepting that my .NET is only slightly better than my Java, does the 2nd Get call crash, or does it crash a few line later when you try and use the object? The 2nd call will unlock the previously browsed message (and I refrain from the usual lecture on the evils of browsing) but it doesn't return a message.

Evidience - if you get a message on the 2nd call it would have a valid message in the object & apparently works; you don't get a message and it doesn't. Hence my question.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
hopsala
PostPosted: Wed Aug 04, 2010 5:07 am    Post subject: Re: dotnet MQ V7 - overwriting MQMessage object Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Vitor wrote:
Accepting that my .NET is only slightly better than my Java, does the 2nd Get call crash, or does it crash a few line later when you try and use the object?

The 2nd Get crashes immediately, and the MQMessage is out of scope so I can't really tell you what happens to the object.

Vitor wrote:
The 2nd call will unlock the previously browsed message (and I refrain from the usual lecture on the evils of browsing) but it doesn't return a message.

Yea, that's what I gather it's supposed to do, and that's why this is such an odd problem. I really don't see why I should be getting AccessViolationException, but I vaguely remember getting a similar exception using the WMB message classes because I tried to write into an initialized message object. Other than that, I'm drawing a blank here.

And no need to lecture me as to the evils of browsing as I entirely concur. This particular client uses browsing as a poor man's MQCMIT mechanism
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Aug 04, 2010 5:10 am    Post subject: Re: dotnet MQ V7 - overwriting MQMessage object Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

hopsala wrote:
Vitor wrote:
Accepting that my .NET is only slightly better than my Java, does the 2nd Get call crash, or does it crash a few line later when you try and use the object?

The 2nd Get crashes immediately, and the MQMessage is out of scope so I can't really tell you what happens to the object.


If it's still in scope before the call then it sounds like yes you can't make 2 calls on the same object. If it's not in scope, found your problem....!

hopsala wrote:
no need to lecture me as to the evils of browsing as I entirely concur. This particular client uses browsing as a poor man's MQCMIT mechanism


The customer is always right. Even if the customer is barking mad.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
hopsala
PostPosted: Wed Aug 04, 2010 5:12 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Oh, and I forgot to mention a funny little side-effect - After SharingViolation occurs, any attempt to either get, put or close the queue later in the code ends up with RC=2219 (MQRC_CALL_IN_PROGRESS). Apparently this exception somehow locks the handle in Get despite the fact that the call is already finished. I can also see the hconn and hqueue still open in the MQExplorer long after my process has closed.
I don't believe this is relevant to the main problem, though, since the 2219 RC consistently appears only after the SharingViolationException occurs.
Back to top
View user's profile Send private message
hopsala
PostPosted: Wed Aug 04, 2010 5:29 am    Post subject: Re: dotnet MQ V7 - overwriting MQMessage object Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

Vitor wrote:
If it's still in scope before the call then it sounds like yes you can't make 2 calls on the same object. If it's not in scope, found your problem....!

Of course it's still in scope before the call, otherwise it wouldn't compile It's just that the exception is caught in another class altogether, and for the moment I don't have the code available for changes.

Anyway, if indeed MQMessage objects are one-time objects, it still seems odd that I should get such a massive System exception, rather than a neat WMQ.Exception going something like "you've already used this object, dummy!". Have you encountered this somewhere else? In Java perhaps?

Vitor wrote:
The customer is always right. Even if the customer is barking mad.

I am obliged, under legal contract, to refrain from making any disparaging comments about my barking mad client.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Aug 04, 2010 6:14 am    Post subject: Re: dotnet MQ V7 - overwriting MQMessage object Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

hopsala wrote:
Have you encountered this somewhere else? In Java perhaps?


If you seriously think I've tried anything this sophisticated in Java and made sense of what I'm seeing, your client is rubbing off on you in an alarming sense!!!!

I've not seen this in any of the .NET I've done, but that's been very straight-arrow sort of stuff.

Someone more qualified to speak on this will be along in a moment.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mvic
PostPosted: Wed Aug 04, 2010 8:46 am    Post subject: Re: dotnet MQ V7 - overwriting MQMessage object Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

What version of MQ code do you have?

Have you checked for known issues at http://www.ibm.com/support/docview.wss?rs=171&uid=swg27014224 ... AccessViolationException is mentioned twice there.

It certainly seems (to me) like it should be considered a bug.
Back to top
View user's profile Send private message
hopsala
PostPosted: Wed Aug 04, 2010 9:50 am    Post subject: Reply with quote

Guardian

Joined: 24 Sep 2004
Posts: 960

mvic wrote:
What version of MQ code do you have?

WMQ 7.0.1.

mvic wrote:
Have you checked for known issues at http://www.ibm.com/support/docview.wss?rs=171&uid=swg27014224 ... AccessViolationException is mentioned twice there.

Yeah, that's what I got too when I googled it - one of the issues is fixed in 7.0.1, the other has to do with MQGMO_CONVERT which I don't use, and the error message is different.

mvic wrote:
It certainly seems (to me) like it should be considered a bug.

Hm.
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 » dotnet MQ V7 - overwriting MQMessage object
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.