Tips and tricks

How to Send File to MSMQ Using C#

by Ali Raza Zaidi on December 25, 2011

During the testing of BizTalk application, which read data from MSMQ. I have to write small C# routine, this routine send data to MSMQ.  If you have no knowledge about MSMQ, Please read My Post on this here.
http://www.biztalkhq.com/what-is-msmq-and-how-to-configure-it-on-windows-7/

 

To Send File on MSMQ you have to include the dll System.Messaging in your C# or Vb.net application. To Simplest code is as follow.

 

public void FileToMSMQ(string FilePath, string MsmqName)

{

//FilePath =@”e:test.xml”;

//MsmqName= @".private$testQue";

System.Messaging.MessageQueue _TheQueue = new System.Messaging.MessageQueue(MsmqName);

System.IO.FileStream _FileStream = new System.IO.FileStream(FilePath, System.IO.FileMode.Open);

Message _Message = new Message();

_Message.BodyStream = _FileStream;

_Message.Label = System.IO.Path.GetFileName(FilePath);

_Message.Priority = MessagePriority.Normal;

_TheQueue.Send(_Message);

}
You can down sample code from here

 

 

 

 

{ Comments on this entry are closed }

Generic fault message exception handling

by Ali Raza Zaidi on September 19, 2011

 

In my current project, there are 50 operations on each port. It is very difficult and time consuming to create fault on every port operation and then add exception handler for every fault message.  This solution is not so comprehensive that if fault message is of different type what you made on each port

For example I selected “BTS.Soap_envelope_1__1.Fault on each operation,

than orchestration goes in suspended mode and process left uncompleted.

After too much search if found following exception type.

Microsoft.XLANGs.BaseTypes.UnexpectedMessageTypeException

 

Its works wonder if any fault message return my orchestration process is not break.

 

Pros: Normal exception caught and Orchestration completes its process.

Con: suspended instance of orchestration still visible at BizTalk admin with message “The instance completed without consuming all of its messages. The instance and its unconsumed messages have been suspended.”

{ Comments on this entry are closed }

Tips And Tricks For Better BizTalk Programming

by Ali Raza Zaidi on May 3, 2011

I found excellent article about better BizTalk Programming on MSDN megaizne.  This article contains

  • Multi-Part Messages
  • Direct-Bound Ports
  • Creating Web services
  • Debugging XSLT

Old but Gold, you can read it here http://msdn.microsoft.com/en-us/magazine/cc163423.aspx

{ Comments on this entry are closed }