MSMQ Message Type  
Author Message
theblackhat





PostPosted: Visual C# General, MSMQ Message Type Top

Is there a facility in MSMQ where the type of the message can be specified along with the message similar to the type we have in System V Message Queue in Unix Environment

Thanks in advance,

TheBlackHat.



Visual C#5  
 
 
Greg Beech





PostPosted: Visual C# General, MSMQ Message Type Top

The Message.BodyType property can be used to specify an integer which denotes the message body type.

If an integer is not rich enough you can use the Message.Extension property to add a byte[] of any additional data required.



 
 
theblackhat





PostPosted: Visual C# General, MSMQ Message Type Top

how to set the Message.BodyType property in the receiving end to retrieve only a set of particular messages which has got the similar BodyType

thanks


 
 
Craig Main





PostPosted: Visual C# General, MSMQ Message Type Top

Queues are not databases, and should not be accessed in a selective fashion, but should rather merely enqueue or dequeue messages for processing.

If you have a scenario where you require the selective removal of messages based on their types, I would consider using a database, or a message queue per "Message Type".

Regards

Craig


 
 
theblackhat





PostPosted: Visual C# General, MSMQ Message Type Top

so is it not possible for a program to receive selective messages from the queue

if so how will MessageType will help me doing that it has got only 3 options like Acknowledgement , Normal and Report. how will i tell the receiving program to receive only its own messages from the MessageQueue

thanks .


 
 
Craig Main





PostPosted: Visual C# General, MSMQ Message Type Top

Hi,

Correct.

There is a reason why there are three options, and they have nothing to do with your requirement to respond to particular message types. They are relevant to the messaging infrastructure itself, and are used to ensure that messages do not fail delivery.

You need to either use a queue for each different type of message, and listen to each separate queue. You are able to create as many queues as you need. Send different message types down different queues. You are also able to take messages off the queue, and multiplex them yourself. You can check the type of each message, and process it accordingly. A message queue is specifically designed to be a FIFO infrastructure. The messages are placed onto the queue at one end and read off the queue at the other end. Queues are not a database. Obviously you may hack and change the infrastructure to cater for your specific needs in any way you deem fit, however, this will have consequences to performance and stability.

To guarantee maximum throughput and transaction integrity you should place messages on the queue one at a time in a transaction. You should then remove the messages from the queue in the order they are presented to you one at a time in a transaction. If you need to check the type and process accordingly, then by all means do that. If the message is not what you expect and you wish to place it on another temporary queue, or to the back of the existing queue, then that is also an acceptable pattern. Attempting to remove messages based on an application specific message type is not a good idea. It is then better to put all the messages into a relational database with a relavent normalised structure using indexes, and read the data based on your application specific record type(s).

Think your application design and use of message queues carefully before selecting them as your enabling technology.

Regards

Craig


 
 
theblackhat





PostPosted: Visual C# General, MSMQ Message Type Top

thanks a lot craig.

i will explain my requirement if possible please help me.

i have 4 applications running and all of them use one common MSMQ and they get messages posted by another application frequently.

so all the four programs should retrieve their corresponding messages only.

but people say that its possible in unix C. they give the message type and retrieve it.

when its possible in unix y is it not possible in MSMQ Even its possible why is that we dont have a simple method to retrieve all messages of similar type.

thanks in advance.