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 » Message Grouping with C#

Post new topic  Reply to topic
 Message Grouping with C# « View previous topic :: View next topic » 
Author Message
Calypso
PostPosted: Fri Oct 16, 2009 5:26 am    Post subject: Message Grouping with C# Reply with quote

Novice

Joined: 16 Oct 2009
Posts: 15

Hello together,

I already worked several years with IBM Websphere MQ under C++ and now C#.
But now I got a problem with the function of message grouping.
Here is a simple code:

Code:

            mqPutMsgOpts = new MQPutMessageOptions();
            mqPutMsgOpts.Version = MQC.MQMD_VERSION_2;
            mqPutMsgOpts.Options = MQC.MQPMO_LOGICAL_ORDER;// | MQC.MQPMO_SYNCPOINT;

            MQMessage mqMsg1 = new MQMessage();
            mqMsg1.WriteString("Test1");
            mqMsg1.Format = MQC.MQFMT_STRING;
            mqMsg1.MessageId = MQC.MQMI_NONE;
            mqMsg1.CorrelationId = MQC.MQCI_NONE;

            mqMsg1.Version = MQC.MQMD_VERSION_2;
            mqMsg1.MessageFlags = MQC.MQMF_MSG_IN_GROUP | MQC.MQMF_LAST_MSG_IN_GROUP;

            mqMsg1.MessageSequenceNumber = 1;

            try
            {
                mqQueue.Put(mqMsg1, mqPutMsgOpts);
            }
            catch (MQException mqe)
            {
                LogAusgabe(String.Format("Beim Einreihen der Nachricht ist ein Fehler aufgetreten ({0})!", mqe.Message), 1);
                return false;
            }

This code puts a message in the related queue with the following content:
Option: Segmentation disabled, none
GroupID:
Bytes for GroupID: 000000...
SequenceNumber: 1

When I use instead the option 'MQC.MQPMO_SYNPOINT' no error occurs
but no new message is put into the queue.

When I use 'rfhutil.exe' to test the message grouping everything works fine:
With and without the option 'Logical Order':
Option: Message in the Group, Last Message in the Group
GroupID: AMQ FLS...
Bytes for GroupID: 4144D5120...
SequenceNumber: 1

Is there somthing that I'am missing?
Thanks for your help!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Oct 16, 2009 10:09 am    Post subject: Reply with quote

Grand High Poobah

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

It's fine to use syncpointing but at some time you still have to commit or backout. You don't show the code to do that...

What is your transaction manager?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Calypso
PostPosted: Fri Oct 16, 2009 10:50 am    Post subject: Reply with quote

Novice

Joined: 16 Oct 2009
Posts: 15

Sorry, I did not understand. What do you mean with commit or backout?

Here is my whole code for that:

Code:

         ///
         /// Try to create an MQQueueManager instance
         ///
         try
         {
                mqQMgr = new MQQueueManager(MQ_Manager_Name);
         }
         catch (MQException mqe)
         {
                LogAusgabe(String.Format("Verbindung zum QueueManager konnte nicht hergestellt werden ({0})!", mqe.Message), 1);
            return false;
         }
         ///
         /// Try to open the queue
         ///
         try
         {
            mqQueue = mqQMgr.AccessQueue( MQ_Remote_Queue,
                                         MQC.MQOO_OUTPUT                   // open queue for output
                                         + MQC.MQOO_FAIL_IF_QUIESCING );   // but not if MQM stopping
         }
         catch (MQException mqe)
         {
                LogAusgabe(String.Format("Verbindung zur Remotequeue konnte nicht hergestellt werden ({0})!", mqe.Message), 1);
            return false;
         }
         ///
         /// Put the massage into the Queue
         ///

            mqPutMsgOpts = new MQPutMessageOptions();
            mqPutMsgOpts.Version = MQC.MQMD_VERSION_2;
            mqPutMsgOpts.Options = MQC.MQPMO_LOGICAL_ORDER;// | MQC.MQPMO_SYNCPOINT;

            MQMessage mqMsg1 = new MQMessage();
            mqMsg1.WriteString("Test1");
            mqMsg1.Format = MQC.MQFMT_STRING;
            mqMsg1.MessageId = MQC.MQMI_NONE;
            mqMsg1.CorrelationId = MQC.MQCI_NONE;

            mqMsg1.Version = MQC.MQMD_VERSION_2;
            mqMsg1.MessageFlags = MQC.MQMF_MSG_IN_GROUP | MQC.MQMF_LAST_MSG_IN_GROUP;

            mqMsg1.MessageSequenceNumber = 1;

            try
            {
                mqQueue.Put(mqMsg1, mqPutMsgOpts);
            }
            catch (MQException mqe)
            {
                LogAusgabe(String.Format("Beim Einreihen der Nachricht ist ein Fehler aufgetreten ({0})!", mqe.Message), 1);
                return false;
            }
Back to top
View user's profile Send private message
Calypso
PostPosted: Fri Oct 16, 2009 12:01 pm    Post subject: Reply with quote

Novice

Joined: 16 Oct 2009
Posts: 15

Ok here is the modified code with Backout(), Commit() and
active 'MQPMO_SYNCPOINT':

Code:

         ///
         /// Try to create an MQQueueManager instance
         ///
         try
         {
                mqQMgr = new MQQueueManager(MQ_Manager_Name);
         }
         catch (MQException mqe)
         {
                LogAusgabe(String.Format("Verbindung zum QueueManager konnte nicht hergestellt werden ({0})!", mqe.Message), 1);
                return false;
            }
         ///
         /// Try to open the queue
         ///
         try
         {
            mqQueue = mqQMgr.AccessQueue( MQ_Remote_Queue,
                                         MQC.MQOO_OUTPUT                   // open queue for output
                                         + MQC.MQOO_FAIL_IF_QUIESCING );   // but not if MQM stopping
         }
         catch (MQException mqe)
         {
                LogAusgabe(String.Format("Verbindung zur Remotequeue konnte nicht hergestellt werden ({0})!", mqe.Message), 1);
                mqQMgr.Backout();
            return false;
         }
         ///
         /// Put the massage into the Queue
         ///

            mqPutMsgOpts = new MQPutMessageOptions();
            mqPutMsgOpts.Version = MQC.MQMD_VERSION_2;
            mqPutMsgOpts.Options = MQC.MQPMO_LOGICAL_ORDER | MQC.MQPMO_SYNCPOINT;

            MQMessage mqMsg1 = new MQMessage();
            mqMsg1.WriteString("Test1");
            mqMsg1.Format = MQC.MQFMT_STRING;
            mqMsg1.MessageId = MQC.MQMI_NONE;
            mqMsg1.CorrelationId = MQC.MQCI_NONE;

            mqMsg1.Version = MQC.MQMD_VERSION_2;
            mqMsg1.MessageFlags = MQC.MQMF_MSG_IN_GROUP | MQC.MQMF_LAST_MSG_IN_GROUP;

            mqMsg1.MessageSequenceNumber = 1;

            try
            {
                mqQueue.Put(mqMsg1, mqPutMsgOpts);
                mqQMgr.Commit();
            }
            catch (MQException mqe)
            {
                LogAusgabe(String.Format("Beim Einreihen der Nachricht ist ein Fehler aufgetreten ({0})!", mqe.Message), 1);
                mqQMgr.Backout();
                return false;
            }


It generates a message in the MessageQueue but not as a part of
a Group!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Oct 17, 2009 4:44 am    Post subject: Reply with quote

Grand High Poobah

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

Well you need to do the rest of the work for the group now.
  • make sure of the flag options on the message.
  • set the last message in group on the last message in the group
  • either let MQ assign the group number on the first put and assign the group number to each message in the group, or use a self imposed / generated one.
  • Once you have a true group of messages put them all in the same UOW.


Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Calypso
PostPosted: Mon Oct 19, 2009 12:09 am    Post subject: Reply with quote

Novice

Joined: 16 Oct 2009
Posts: 15

Thanks for your reply!

You can generate a simple Group already with one Message.
That works fine with rfhutil.exe and that is what I tried in the
code above.

1. Here are my options:

mqMsg1.MessageFlags = MQC.MQMF_MSG_IN_GROUP | MQC.MQMF_LAST_MSG_IN_GROUP;

2. The first message is currently the last message in the group.

3. I only put one message, so MQ assined a group number (do you mean
group id?) but it is not shown in the properties of the message, when
I explore it.
When you mean the Sequence Number, I can put one under 'rfhutil'
why not in my application?

4. What do you mean with 'UOW'? I'am not familiar with english
MQ abbreviations, sorry. There is only one message and I put
it into the normal Remote Queue!


Normally before I ask for help, I simplify the problem and
therefor I tried to generate a group out of one message.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Oct 19, 2009 2:58 am    Post subject: Reply with quote

Grand High Poobah

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

Having a group of one message is fine. Yes I meant GroupID.
Does not matter if you can't see it in the message properties, can you see it in rfhutil and is it different from all hex 000?
Looking at how to see it in the properties can then be the next part of the exercise...
UOW=Unit of Work. Materializes transactional boundaries.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Calypso
PostPosted: Thu Oct 22, 2009 3:34 am    Post subject: Reply with quote

Novice

Joined: 16 Oct 2009
Posts: 15

Hello again,

I have a lot of work sorry

[img]
http://www.business-connector.de/img/rfhutil.jgp.JPG
[/img]

This image shows the settings of 'rfhutil' after the 'Write to Queue' action.
Before that the Bytes for the Message ID and the Group ID were '000...',
and it seems to be that MQ generates the IDs itself.

[img]
http://www.business-connector.de/img/TransmissionQueue.jgp.JPG
[/img]

This image shows the properties of the messages in the Transmission Queue.
The first was wrote in by rfhutil, the second by my application with the code from above.
In both cases the Message ID was generated automaticly.

Any Idea?
What Informations are also helpful?
Back to top
View user's profile Send private message
Calypso
PostPosted: Thu Oct 22, 2009 6:35 am    Post subject: Reply with quote

Novice

Joined: 16 Oct 2009
Posts: 15

Now I find the difference between my application and rfhutil!

In my application I put every message into the remote queue.
But under rfhutil I selected the transmission queue. Sorry for that!
But when I put it into the transmission queue with rfhutil it works
as expected.
When I select the remote queue under rfhutil it behaves like my
application
The description to the list where I can select an existent queue
under rfhutil sais 'Remote Queue Manager Name (remote queues only)'.

So I think the properties and options are working well also in my
application (that is, what I have to test). But these informations are lost by the MQ Manager putting
the message from the remote into the transmission queue?!
Or do they still exist and are not displayed in the properties belonging
to a single message in the transmission queue?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Oct 22, 2009 5:00 pm    Post subject: Reply with quote

Grand High Poobah

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

First put all messages into a local queue and inspect them with RFHUtil(c).
In particular make sure that you set the groupid for messages 2 to last.

If the result lives up to your expectations, change the local queue to a remote queue.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Calypso
PostPosted: Tue Nov 03, 2009 1:19 am    Post subject: Reply with quote

Novice

Joined: 16 Oct 2009
Posts: 15

It is working
Thanks a lot for your help!
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Nov 03, 2009 7:05 am    Post subject: Reply with quote

Grand High Poobah

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

Calypso wrote:
It is working


Care to post how you resolved this for the benefit of future readers?

Well done for getting it working!
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Calypso
PostPosted: Wed Nov 04, 2009 5:40 am    Post subject: Reply with quote

Novice

Joined: 16 Oct 2009
Posts: 15

My settings were correct. I only put the message into the wrong queue.
The Queuemanager sets the GroupID and the sequence number himself.
Here is the modified and final code for my task:

Code:

         ///
         /// Put the massages into the Queue
         ///
            mqPutMsgOpts = new MQPutMessageOptions();
            mqPutMsgOpts.Version = MQC.MQPMO_VERSION_2;
            mqPutMsgOpts.Options = MQC.MQPMO_LOGICAL_ORDER | MQC.MQPMO_SYNCPOINT;

            mqMsg = new MQMessage();
            mqMsg.WriteBytes(XML_message);
            mqMsg.MessageId = MQC.MQMI_NONE;
            mqMsg.CorrelationId = StrToByteArray("cor0");
            mqMsg.GroupId = MQC.MQGI_NONE;

            mqMsg.Version = MQC.MQMD_VERSION_2;
            mqMsg.MessageFlags = MQC.MQMF_MSG_IN_GROUP;

            try
            {
                mqQueue.Put(mqMsg, mqPutMsgOpts);
                mqQMgr.Commit();
            }
            catch (MQException mqe)
            {
                LogAusgabe(String.Format("Beim Einreihen der Nachricht ist ein Fehler aufgetreten ({0})!", mqe.Message), 1);
                return false;
            }

            mqMsg = new MQMessage();
            mqMsg.WriteBytes(BAL_message);
            mqMsg.MessageId = MQC.MQMI_NONE;
            mqMsg.CorrelationId = StrToByteArray("cor1");

            mqMsg.Version = MQC.MQMD_VERSION_2;
            mqMsg.MessageFlags = MQC.MQMF_MSG_IN_GROUP;

            try
            {
                mqQueue.Put(mqMsg, mqPutMsgOpts);
                mqQMgr.Commit();
            }
            catch (MQException mqe)
            {
                LogAusgabe(String.Format("Beim Einreihen der Nachricht ist ein Fehler aufgetreten ({0})!", mqe.Message), 1);
                return false;
            }

            mqMsg = new MQMessage();
            mqMsg.WriteBytes(END_message);
            mqMsg.MessageId = MQC.MQMI_NONE;
            mqMsg.CorrelationId = StrToByteArray("cor2");

            mqMsg.Version = MQC.MQMD_VERSION_2;
            mqMsg.MessageFlags = MQC.MQMF_MSG_IN_GROUP | MQC.MQMF_LAST_MSG_IN_GROUP;

            try
            {
                mqQueue.Put(mqMsg, mqPutMsgOpts);
                mqQMgr.Commit();
            }
            catch (MQException mqe)
            {
                LogAusgabe(String.Format("Beim Einreihen der Nachricht ist ein Fehler aufgetreten ({0})!", mqe.Message), 1);
                return false;
            }
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 » Message Grouping with C#
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.