Monday, December 12, 2011

BizTalk 2010 R2 announced

Last week Microsoft announced the next release of BizTalk Server, for now called 2010 R2. Charles Young already wrote an overview of the features and product positioning, but I highlight two: the support for Informix V11 (I’ve had this need more than once, and had to resort to ODBC as an alternative – it was even announced for BizTalk 2010 and then dropped in RTM), and the further integration with the Azure Service Bus. The current BizTalk Server 2010 Feature Pack already supports limited integration with it – basically, exposing services in the bus, but in my tests I’ve had inconsistent behavior using it and connection drops, and the lack of logging is a problem.

I also find the new licensing models interesting, namely to support hosting scenarios, but I can’t really see how the product is going to support this if it doesn’t support application isolation today.

Tuesday, August 9, 2011

AutoMapper

AutoMapper is a «convention-based object-to-object mapper». According to the description, «AutoMapper uses a fluent configuration API to define an object-object mapping strategy. AutoMapper uses a convention-based matching algorithm to match up source to destination values. Currently, AutoMapper is geared towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is better suited for serialization, communication, messaging, or simply an anti-corruption layer between the domain and application layer.»

I’ve been using AutoMapper to map entity objects between data and service layers, as well as service and UI layers. What I mean with mapping is doing stuff such as:

public TDestination Map(TSource src) {

TDestination dest = new TDestination ();

dest.Field1 = src.Field1;

dest.Field2 = src.Field2 + src.Field3;

dest.Field3 = src.Field10;

// …

return dest;

}

This is boring and repetitive code, and it’s what AutoMapper wants to avoid writing.

In its simplest usage, we setup the mapper with:

using AutoMapper;

[…]

Mapper.CreateMap<TSource , TDestination>();

and then convert by calling:

TDestination dest = Mapper.Map<TSource , TDestination>(srcObject);

By default, AutoMapper only maps properties that have the same names on the source and destination, however you can parameterize the mapper in a different way. For example, assuming that Field10 in TSource becomes Field3 in TDestination, you can write:

Mapper.CreateMap<TSource , TDestination>()
    .ForMember( dst => dst.Field3, options => options.MapFrom(src => src.Id));

You can add as many ForMember clauses as you want. Also note that dst, options are src are not variable names, but are part of the lambda function definitions.

After the map is setup like this, the call to Map will now convert the objects correctly.

So AutoMapper is an extremely convenient way to map between objects, and more convenient the more similarity there is in the names of the properties of the objects being mapped.

 

However, and quite obviously, AutoMapper does this by using reflection, and I wanted to measure the impact of doing these conversions this way, compared with the hand-coded assignments shown at the top.

I created two examples: in the first, the two objects have exacly the same structure, so AutoMapper does all the work. In the second, the destination type has the same fields, but with different names, so I had to use ForMember once for each of the 6 fields in my test classes.

I then created a loop that converted using either of the two methods a number of times and printed out the elapsed time. Here are the results:

Type of Conversion Number of loop iterations Elapsed time using AutoMapper Elapsed time hand-coded map Ratio
Direct 100.000 2 sec, 165 ms 20 ms 1:108
With Property Renames 100.000 3 mins, 14 secs, 157ms 25 ms 1:7726

The first time was according to what I expected, but the second was actually much larger.

Getting these results, I then tried an optimization, which was to create the map outside of the test loop – but still after the timer start (assuming it could be created and stored in some in-memory cache), and re-ran the tests. This time the results where much better, especially in the renames case, showing that setting up the map with renames can have a large impact on the execution times. The following table shows the results.

Type of Conversion Number of loop iterations Elapsed time using AutoMapper Elapsed time hand-coded map Ratio
Direct 100.000 2 sec, 611 ms 24 ms 1:109
With Property Renames 100.000 2 sec, 508 ms 27 ms 1:93

Quite surprising that the renames option is now actually faster than the automatic direct conversion.

 

My conclusion: I’ll go on using AutoMapper for its convenience when writing code, but if performance is an issue, I’ll just directly hand-code the mapping.
Pre-creating and populating a cache of Mappers would also be a viable alternative, but hard to justify in terms or architecture.

Check out the codeplex site for more features of AutoMapper, such as Flattening or Projection, or contact me if you want the source code I used for these tests.

Thursday, July 21, 2011

WPC2011 and the Future of BizTalk

Following Tony Meleg’s presentation at Microsoft World Partner Conference, there’s a lot of discussion going on about the future of BizTalk Server. The following is a link to some pages with opinions about this issue:

This is just a sample of some of the discussion going on. My take?

  1. I’m sorry Microsoft has almost stopped evolving BizTalk since version 2004, in terms of core engine features, BAM, the rules engine, and low latency support;
  2. As much as love Azure and cloud technologies, including the new Integration stuff, I still can’t see how it can handle integration with onPrem systems such as SAP R/3 or Oracle, low latency, or large volumes of data.
  3. BizTalk is still the leading integration middleware world-wide.

To conclude: Cloud integration will probably gain its space and win some scenarios where it makes sense. But BizTalk, or perhaps more generally ESB/EAI scenarios, will not go away. Your car’s engine is not a utility that you can put on the cloud :).

Monday, July 11, 2011

Instrumentation Best Practices for High Performance BizTalk Solutions + BizTalk Software Factory for BizTalk 2010

This one slipped me last year. A Microsoft whitepaper about Instrumentation Best Practices for High Performance BizTalk solutions. A reminder of the impact of trace and debug on BizTalk Developments. It covers Pipeline Components, Maps, Orchestrations, custom .Net components and even Business Rules. An interesting read.

Another interesting link is BizTalk Software Factory 3.0. This new version supports BizTalk Server 2010/Visual Studio 2010, which you can download from Codeplex. Everything that further accelerates BizTalk development is welcome.

Tuesday, June 21, 2011

Windows Phone 7– Outlook sync

I own a Windows Phone 7, and one of the problems I’ve had since day one is the inability to sync my local Outlook with the phone. My initial approach was to add the phone’s live account to Outlook, and then do copy&paste of contacts and appointments to this account. No need to say this is extremely inefficient...

My friend Tiago Pascoal found the solution for me: a miracle little $20 tool called gSyncit. This tool sits on your tray icon and syncs from your Outlook into your gmail account. You can then setup the Google account on your phone, and voila! The tool sync contacts, appointments, tasks and notes.

I’ve been using it with Outlook 2010 x64 and my feedback is very positive, I highly recommend it.

It’s just a pitty that I ended up having to buy an app to do something Zune Software should handle for me out-of-the-box, and on top of this using gmail as a bridge.

Note: I have no affiliation whatsoever with Fieldston Software.

Editing .ODX Files / Regenerate Orchestration Code

Everybody with some experience with BizTalk Server knows that sometimes the ODX files get garbled and have to be fixed manually. I’ve had situations where the compilation of an orchestration works fine, but when viewing the orchestration in the visual studio designer, there are shapes with the red icon of error in it. When things like this happen, or you get those strange “Errors exist for one or more children”, what you can do is have BizTalk re-generate the code part of the ODX.

To do this, edit the ODX file in notepad, and look for the string:

#endif // __DESIGNER_DATA

Then, carefully remove all the text after this line and until the end of the file. Save the file and re-open it in the Visual Studio Designer, and make some change to is (such as adding a newline in an Expression Shape). This will cause the full re-generation of the code part of the ODX that follows the string above, and it will probably fix your strange problems.

An old hint, but a useful one!

Thursday, June 2, 2011

When are Instance Subscriptions created, after all?

I stumbled with a situation where a Main orchestration calls a sub-orchestration, and this sub-orchestration sends back to Main a new message, using Direct Binding. The non-obvious behavior here is that the first Orchestration calls the second synchronously, so in theory the send in the second should fail, because the subscription is not there yet.

Since I knew that publishing with Direct Binding fails the sender orchestration if there is no subscription, I did a small test to check what was happening.

This is the main orchestration:

orch_main

The first Send initializes a correlation set, and the second receive follows it. The Main Orchestration passes the initially received message as a parameter to the sub-orchestration, which simply maps it into a new one and returns the result:

orch_sub

I deployed this and did a Search for subscriptions in the Administration Console. The result is curious: the subscription for the Reply message (the result of the map) is not there yet when at “Wait 1”, but it’s created after the correlation set is created, so its there when “Wait 2” is reached. This is why the publish in the sub-orchestration doesn’t actually fail.

This behavior might be different in some cases, as reported here by Yossi: When is a subscription created for a correlation set passed as a parameter?.

Friday, May 27, 2011

Visual Studio 2010 and BizTalk 2010 File Locking Problems

I’ve had several situation with large solutions in VS2010 where assemblies get locked and references need to be constantly fixed, failing compilations. I would get errors when copying the DLL’s from the OBJ into the BIN folders, or even copying a schema assembly into the bin folder of the maps project which uses it. One “detail” (or not) was that the BizTalk and C# projects in the solution where upgraded from previous versions (BTS2004).

Using SysInternal’s Handle.exe tool, I found it was Devenv itself locking the assemblies.

I’ve tried several solutions that didn’t work, including:

  • disable vs extensions
  • stop windows indexing service
  • make sure Copy Local is set to True in all the references
  • the same fix that was used with VS2008+BTS2009 (documented here) of setting Private True in the project file;
  • adding the the famous GenerateResourceNeverLockTypeAssemblies config in the project files (documented here, see Benson’s response).

What eventually solved the issue was a variation of the first solution Benson gave in the previous link, and which is documented here in a StackOverflow response by Godeke: code a small command line tool (VisualStudioLockWorkaround) that removes locks and which you add as a pre-build script to the troublesome VS projects. It’s ugly, but it solved my problem, after some hours of trying to figure out what was happening.

Monday, February 14, 2011

Microsoft Business Integration RoadShow 2011 (Lisboa, 28/Fev)

Another year, another Business Integration Roadshow. This year I’ll be unable to present, as I’ll be attending Microsoft’s MVP Summit in Redmond, but my two colleagues Tiago Oliveira and Raúl Ribeiro will present a session on the integration of BizTalk Server 2010 together with Windows Azure – “BizTalk + Azure – Better Together”. You can expect a few surprises and a eye-opener demo. :-)

More information and registration for the event can be found here.

BizTalk Server 2010 Feature Pack

The BizTalk Server 2010 Feature Pack is an add-on to BizTalk Server 2010 that allows BizTalk functionality to be invoked from Windows Azure’s Service Bus. The feature pack specifically includes “BizTalk Server 2010 AppFabric Connect for Services”, the feature that allows you to do this.

You can read more about how it works on the BizTalk Server Team Blog. Great feature!

Tuesday, January 25, 2011

BizTalk and Gartner Oct’2010

Gartner’s Magic Quadrant for Application Infrastructure for Systematic Application Integration Projects (October 2010) places Microsoft in the leader’s quadrant for integration, with BizTalk Server and the global integration platform, as the company with a clear lead in the ability to execute dimension.
Gartner_Oct2010

Gartner’s report can be found here with all the details. Check the Microsoft section to learn about the strengths and cautions to have. Some interesting details are: “the least-expensive perpetual license of commercial offerings that Gartner analyzed”, “BizTalk Server installed base of more than 10,000 customers — two-thirds are estimated to be BizTalk Server 2006 Enterprise Edition”, “Microsoft garnered 13 % of the ESB suite market software revenue” or the ever important skills question: “results in the availability of skills, services and add-ins”.