donderdag 19 juli 2012

Difference between 2 dates in C#

I tried to do a simple DateTime calculation in C#. What I wanted to achieve is to know how many years, months and days where between 2 DateTime variables. Or at least I thought this would be easy. Turns out there is know real out-of-the-box functionality available to handle this in C#.

The only thing available out-of-the-box in C# is using TimeSpan. Unfortuanately the only calculations TimeSpan can return is the number of days, hours, minutes, seconds and milliseconds. But how about the years, months and days than?

Here's a simple method to show the possibilities of the TimeSpan:
public void PrintDateDiffUsingTimeSpan(DateTime begin, DateTime end)
        {
            TimeSpan span = end - begin;

            StringBuilder str = new StringBuilder();
            str.Append("Total span: ");
            str.Append(span.Days + " days, ");
            str.Append(span.Hours + " hours, ");
            str.Append(span.Minutes + " minutes, ");
            str.Append(span.Seconds + " seconds, ");
            str.Append(span.Milliseconds + " milliseconds");

            Console.WriteLine(str.ToString() + "\n");


            Console.WriteLine("Total Days: " + span.TotalDays);
            Console.WriteLine("Total Hours: " + span.TotalHours);
            Console.WriteLine("Total Minutes: " + span.TotalMinutes);
            Console.WriteLine("Total Seconds: " + span.TotalSeconds);
            Console.WriteLine("Total Milliseconds: " + span.TotalMilliseconds);
        }

I ended up using a freely available .NET library called 'Time Period'. The source code can be found here. There's also an on line demo and documentation available.
Here's a simple method to show some the possibilities of the TimeSpan:

  public void PrintDateDiff(DateTime begin, DateTime end)
        {
            DateDiff diff = new DateDiff(begin, end);
            
            StringBuilder str = new StringBuilder();
            str.Append("Total difference: ");
            str.Append(diff.ElapsedYears + " years, ");
            str.Append(diff.ElapsedMonths + " months, ");
            str.Append(diff.ElapsedDays + " days");

            Console.WriteLine(str.ToString() + "\n");

            Console.WriteLine("Total Days: " + diff.Days);
            Console.WriteLine("Total Weeks: " + diff.Weeks);
            Console.WriteLine("Total Weekdays: " + diff.Weekdays);
            Console.WriteLine("Total Quarters: " + diff.Quarters);
            Console.WriteLine("Total Hours: " + diff.Hours);
        }

There are much more possibilities in the DateDiff class of the Time Period library. There are even much more classes available in the library. To know more of the capabilities of this library I again refer to the documentation.

Source: http://www.itenso.com/en/

dinsdag 17 juli 2012

BizTalk Server Performance

Have you ever wanted to evaluate the performance of your Biztalk installation?
Evaluating your performance could be done by analyzing quite some counters in the performance monitor of Windows. Or maybe by using the Performance Analysis of Logs (PAL) Tool.

However I just found a recently released tool to benchmark your biztalk environments.
The tool is called blogical and can be found on codeplexe here.

How it works:
  1. After the user has started the application and specified the BizTalk Group, the tool analyzes its configuration, finding all the BizTalk servers, Messageboxes etc.
  2. Secondly, the user gets to select one of two scenarios: Messaging or Orchestration. Each scenario has a set of tested environments such as
    • “Single server (2*Quad CPU, 4GB RAM)”
    • “1*BTS (1*Quad CPU. 4GB RAM) + 1*SQL(1*Quad CPU, 8GB RAM)”.
    • “2*BTS (2*Quad CPU. 8GB RAM) + 2*SQL(2*Quad CPU, 16GB RAM)”.
  3. The user selects the environment which most resembles his/her own.
  4. The user then starts the Indigo Service, a console application hosting a service which will be called from the BizTalk Send port.
  5. As the user clicks “Run test”, the tool continues to start ports and orchestrations. It will also start the Perfmon collector sets if the user has chosen to create those.
  6. As the test proceeds the user can monitor the counter values through the gauges (CPU utilization, Received msgs/sec and Processed msgs/sec). The default test duration is 30 minutes, with a warm-up of 2 minutes.
  7. Finally, the user is presented a result, which is either Succeeded or Failed.

For more information:
Benchmark your BizTalk Server (Part 1)

How to install:
Benchmark your BizTalk Server (Part 2)

BBW Drill Down:
Benchmark your BizTalk Server (Part 3)

High Scores:
http://blogical.se/bbw


Another thing I wanted to share with you regarding performance of Biztalk installations is the Microsoft BizTalk Server 2009 Performance Optimization Guide .
This guide provides in-depth information for optimizing the performance of a BizTalk Server solution.

Also check BizTalk Health Check post on Technet Wiki. It's a list of checkpoints that should be covered when performing a health check

vrijdag 13 juli 2012

Promote using Correlation initialisation inside a loop

I assume you already know how to promote properties when sending a message from an orchestration to the messagebox.
This can of course be achieved by initializing a correlation set with containing all context properties you like to promote. But that 's not why I'm posting this blog. If you need more info on how to promote properties from an orchestration I'll refer you to this blog.

Problem

The problem is when you try to do this from a send shape inside a loop, you'll get an error when building the project in visual studio.
The received error is "Correlation set may be initialized only once".

Solution

The solution to this issue is actually real easy. All you have to do is create a scope inside the loop. And place the send shape (and even other shapes if needed) in the created orchestration. The benefit of the orchestration is that you can define the correlation set on the scope itself (instead of as a global correlation set).
Now can initialize your correlation set on your send shape inside the scope.

And that's all you'll have to do!! It really is that easy! :)

donderdag 12 juli 2012

Passed the Microsoft BizTalk Exam

As of yesterday I can call myself a Microsoft Certified Technology Specialist (MCTS): Microsoft BizTalk Server 2010.

I passed the exam 70-595: Developing Business Process and Integration Solutions by Using Microsoft BizTalk Server 2010. I did this making only a single mistake, not bad at all :).

All I did as preparation was reading the book (MCTS): Microsoft BizTalk Server 2010 (70-595) Certification Guide once. This together with the practical knowledge I had gathered on the job made sure I passed the exam easily.

So all credits go to the authors of the book (Johan Hedberg, Kent Weare , Morten la Cour). They definitely achieved their goal. Also the sample questions (and their answers) were very helpful in the preparation.

woensdag 13 juni 2012

Identify Performance Bottlenecks in BizTalk

I found a series of blogs on how to identify Performance bottlenecks in BizTalk Environments.
Also look at this article on finding and eliminating bottlenecks

Here's an short overview of all the steps, including a link to the more detailed explanation:

Step 1: Monitoring BizTalk Host Instances via Windows Performance Counters


 The first place to measure the BizTalk performance can be done using Performance Counters. These counters let you monitor all components like the message box, orchestrations, adapters, etc… .

Step 2: Analyzing BizTalk Adapters


A deeper look at the adapter performances, again using some performance counters.

Step 3: Analyze Pipelines


It is important to understand the impact of Pipeplines that are used. Because each of the pipelines have a significant impact on the overall BizTalk performance as they perform actions on every single message that gets through BizTalk
One way to analyze what is really going on in pipelines is using an Application Performance Management Solution with Transactional Tracing capabilities, like dynaTrace for example.

Step 4: Analyzing Orchestration


Orchestration can get quite complex sometimes, but how to analyze the performance of these orchestrations?

The actual logic behind the Orchestration Definition is compiled into an assembly, loaded into BizTalk, and gets executed when messages are processed by that Orchestration Definition. A more detailed overview of the execution of such an orchestration can be generated with PurePath for example.

Another way to analyze the orchestration performance can again be done using performance counters.  BizTalk provides a set of counters for the Orchestration Engine as well as for the MessageBox.

Step 5: Analyzing external service calls (SendPorts)


Often BizTalk Orchestration makes a call to an external web service. PurePath can also give you an idea of the time consumed for this external web service call.


FINAL NOTE


As a final note I would like to point out to use the MessageBox Viewer Tool. The tool gives an overview of what might be wrong in your installation.
This tool runs a set of tests and queries against the MessageBox database an creates a nice report. The result can be viewed using the tool or it can generate an HTML report.

dinsdag 12 juni 2012

Best practices on Biztalk Tracking

I announced in a previus post that I joined the blogging team on biztalkadminsblogging.com.
However it took untill today before my first blog post was created.

I gave it a long thought what my first blog post should cover. the result is a post on some best practices for the usage of tracking in BizTalk... hope you like it!

The actual post can be found here http://www.biztalkadminsblogging.com/index.php/item/83-best-practices-for-tracking

vrijdag 1 juni 2012

New blog site: Windows Azure Road trip

There is a brand new developers' blog site on Windows Azure, called windows azure roadtrip. three specialist developers, each in thier own programming language, will be posting some blogs regularly.

Maarten Balliauw (a .NET developer) kicked it off with the very first blog post 'Winsows Azure when you code .NET: what & Why'.
The other blog writers are Michelangelo van Dam (a PHP developer) and François Hertay (a Java developer).

Keep a close eye on this webiste, more useful blog posts to come.

Resource: https://www.azure-roadtrip.be/