Author |
Message
|
loslor |
Posted: Tue Sep 30, 2008 1:06 am Post subject: MQ Classes for .NET problems |
|
|
Newbie
Joined: 30 Sep 2008 Posts: 2
|
Hi,
First I apologize for asking for help in my first message. I've come to this forum in my desperate search for a solution.
I'm developing an application in VB.NET that gets and puts messages in queues. These messages are packed in groups, that is, have the message flags field set to message in group, and the last message of the group has also the last message in group flag activated.
That's what I see in the WebSphere MQ Explorer when I browse one of the given queues. Then I use my app to get the messages. My code is something lile this:
Code: |
Dim qmi As MQQueueManager
Dim qi As MQQueue
Dim mi As MQMessage
Dim getOp As MQGetMessageOptions
qmi = New MQQueueManager(<QManagerName>)
qi = qmi.AccessQueue(<QueueName>, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING)
mi = New MQMessage
getOp = New MQGetMessageOptions
qi.Get(mi, getOp)
|
Which is pretty much the code I've found around in examples. My problem is that when I check the property "MessageFlags" of the message I obtain a 0, and the property "GroupStatus" of the MQGetMessageOptions object has a value of 32, that according to the reference is "Message not in group".
What am I missing? It must be something stupid I've done and I'm not being able to figure out, or that I hope.
Any idea?
Thanks in advance |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 30, 2008 7:19 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
check out your get message options. You may not want to use the default which is what your code is doing....  _________________ MQ & Broker admin |
|
Back to top |
|
 |
loslor |
Posted: Tue Sep 30, 2008 10:01 am Post subject: |
|
|
Newbie
Joined: 30 Sep 2008 Posts: 2
|
I've been diving through the options (I guessed it would be there), but the only thing I see I could be missing is the option: "MQC.MQGMO_ALL_MSGS_AVAILABLE". I can't try it now from here but I'll do it first thing in the morning.
Any other clue?
Regards
P.D: thx for the fast answer btw |
|
Back to top |
|
 |
zlj |
Posted: Sun Nov 16, 2008 6:03 pm Post subject: |
|
|
 Apprentice
Joined: 13 Nov 2008 Posts: 32
|
Hi loslor
I do not very understand what you mead. I used to do this to get message from queue.
1.Get a message queue instance.
Quote: |
public static MQQueueManager GetQueueManager(string queueManagerName)
{
MQQueueManager mqMgr = new MQQueueManager(queueManagerName);
return mqMgr;
}
|
2.Get message queue instance
Code: |
public static MQQueue GetQueue(MQQueueManager mqMgr, string queueName, int openOptions)
{
MQQueue queue = mqMgr.AccessQueue(queueName, openOptions);
return queue;
}
|
openOptions=MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING
3.Receive message from queue
Code: |
public static object Receive(MQQueue queue, int WaitInterval)
{
MQGetMessageOptions gmo = new MQGetMessageOptions();
//在同步点控制下获取消息
//get message at synchronous point
gmo.Options = gmo.Options + MQC.MQGMO_SYNCPOINT;
//如果在队列上没有消息则等待
//if no message in queue, waiting!
gmo.Options = gmo.Options + MQC.MQGMO_WAIT;
//如果队列管理器停顿则失败
//if queue manager QUIESCING then failed.
gmo.Options = gmo.Options + MQC.MQGMO_FAIL_IF_QUIESCING;
gmo.WaitInterval = WaitInterval;
MQMessage outMsg = new MQMessage();
//outMsg.Format = MQC.MQFMT_STRING;
queue.Get(outMsg, gmo);
object message = outMsg.ReadObject();
return message;
}
|
I am chinese, not good at english, sorry.
Regard! |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Nov 16, 2008 6:11 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What you have in your gmo are syncpoint,wait, fail if quiescing
You need to add msg in group and all msg available...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
zlj |
Posted: Mon Nov 17, 2008 12:46 am Post subject: |
|
|
 Apprentice
Joined: 13 Nov 2008 Posts: 32
|
fjb_saper wrote: |
What you have in your gmo are syncpoint,wait, fail if quiescing
You need to add msg in group and all msg available...
Have fun  |
Thank u. |
|
Back to top |
|
 |
zpat |
Posted: Mon Nov 17, 2008 3:07 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
You might want to add MQGMO_CONVERT as a good practice.
Use Syncpoint only if you want to allow rollback and can handle backed out messages (and of course use commit at some point). |
|
Back to top |
|
 |
|