Pratik
Pratik

Reputation: 11745

Get Biztalk's message count through C# .NET

How can I get total message sent / received at any given point of time by the BizTalk Server through C# .NET?

Any Ideas to achieve this?

Upvotes: 0

Views: 1432

Answers (3)

Saravana Kumar
Saravana Kumar

Reputation: 596

You can get that information from querying Tracking Database MessageInOutEvents table. This is one single table where all the activities are stored.

The only requirements is you should have switched off the global tracking property in your BizTalk environment.

Upvotes: 0

StuartLC
StuartLC

Reputation: 107407

A simple approach would be to use the existing BizTalk Perfmon Counters to monitor messages (albeit since the last Host instance restart)

Assuming that you've got a BizTalk Server called BizTalkServer with a SendHost and ReceiveHost configured, the below message counters should give an indication of the messages sent / received:

PerformanceCounter msgsReceivedCounter = new 
    PerformanceCounter("BizTalk:Messaging", "Documents received", "ReceiveHost", "BizTalkServer");
msgsReceivedCounter.ReadOnly = true;
PerformanceCounter msgsSentCounter = new 
    PerformanceCounter("BizTalk:Messaging", "Documents processed", "SendHost", "BizTalkServer");
msgsSentCounter.ReadOnly = true;

lblSent.Text = string.Format("{0}",  msgsSentCounter.NextValue());
lblReceived.Text = string.Format("{0}",  msgsReceivedCounter.NextValue());

Note that if you have more than one BizTalk host in your group, you will need to aggregate across all hosts.

More on using the PerformanceCounter class in C# here. More on the BizTalk PerfMon Counters here.

Upvotes: 1

Fabio
Fabio

Reputation: 730

Message tracking in BizTalk is done using BAM. Of course, you could write your own database and data access API, but why would you?!? See Using Business Activity Monitoring for a primer. Don't be put off by the learning curve - once you get over it, you'll love it!

This book has a very good section on BAM, don't be put off by the version - the basic concepts still apply to 2010.

And finally this tool will speed up your development.

Upvotes: 2

Related Questions