The SendMSMQMessage sample application that is located in
the BizTalk Server SDK samples folder is not configured to use any one of the
system queues to receive a NACK. To make the SendMSMQMessage application use
journaling and the dead letter queue, replace the code behind the
Send
exact button click event with the following code:
try
{
MessageQueueTransaction myTransaction = new MessageQueueTransaction();
MessageQueue mq = new MessageQueue(textBoxAddr.Text);
System.Messaging.Message msg = new System.Messaging.Message();
msg.Label = "TestMessageLabel";
StreamWriter wr = new StreamWriter(msg.BodyStream,System.Text.Encoding.Unicode);
wr.Write(textBoxBody.Text);
wr.Flush();
myTransaction.Begin();
msg.UseJournalQueue = true;
msg.UseDeadLetterQueue = true;
mq.Send(msg,myTransaction);
myTransaction.Commit();
textError.Text = "Success.";
}
catch (Exception ex)
{
textError.Text = ex.ToString();
}
After you replace the code, when you click the
Send
exact button to send a message to your MSMQT receive function and the
message fails validation, a NACK is sent back to the originating Message
Queuing server and your message is stored under the system dead letter queue.
Additionally, if the message validation was successful, a positive
acknowledgement (ACK) is sent back to the originating Message Queuing server,
and your message is now viewable under the system journal queue.
Note If you require different behavior in BizTalk Server 2004, you may
want to use the Microsoft BizTalk Server 2004 Adapter for Message Queuing 2.0.
For example, you may want to decouple the transport failures from the transform
failure and to see the failed message as suspended within BizTalk Server.