Dynamically Selecting an Itinerary Using Business Rule Policy in BizTalk 2013
Currently, In BizTalk 2013 when we call a Business Rule Policy Via the default pipeline ItinerarySelectReceiveXml using following ResolveConnectionString
BRI:\\policy=Mypolicy;version=1.0; will not work.
The following exception is thrown with ESB 2.2 on Microsoft BizTalk Server 2013 in event log when the ItinerarySelectReceiveXML receive pipeline is used to call the Business Rules Engine to dynamically select an itinerary (using the ESB BRI Resolver).
Exception has been thrown by the target of an invocation.
Source: Microsoft.Practices.ESB.Resolver.ResolverMgr
Method: System.Collections.Generic.Dictionary`2[System.String,System.String] Resolve(Microsoft.Practices.ESB.Resolver.ResolverInfo, Microsoft.BizTalk.Message.Interop.IBaseMessage, Microsoft.BizTalk.Component.Interop.IPipelineContext)
Error Source: mscorlib
Error TargetSite: System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
Error StackTrace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Microsoft.Practices.ESB.Resolver.ResolverFactory.Create(String key)
at Microsoft.Practices.ESB.Resolver.ResolverMgr.GetResolver(ResolverInfo info)
at Microsoft.Practices.ESB.Resolver.ResolverMgr.Resolve(ResolverInfo info, IBaseMessage message, IPipelineContext pipelineContext)
Source: Microsoft.Practices.ESB.Resolver.ResolverMgr
Method: System.Collections.Generic.Dictionary`2[System.String,System.String] Resolve(Microsoft.Practices.ESB.Resolver.ResolverInfo, Microsoft.BizTalk.Message.Interop.IBaseMessage, Microsoft.BizTalk.Component.Interop.IPipelineContext)
Error Source: mscorlib
Error TargetSite: System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
Error StackTrace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Microsoft.Practices.ESB.Resolver.ResolverFactory.Create(String key)
at Microsoft.Practices.ESB.Resolver.ResolverMgr.GetResolver(ResolverInfo info)
at Microsoft.Practices.ESB.Resolver.ResolverMgr.Resolve(ResolverInfo info, IBaseMessage message, IPipelineContext pipelineContext)
Reason : ESB Toolkit 2.2 uses Unity 2.0 which requires modifications to the esb.config file because default version of esb.config did not support the dynamic selection of Itinerary using Business rule policy in BizTalk 2013.
Resolution :
Modify
esb.config file.
a.
Take the backup
of the file and then open the file placed at following location Location : E:\Program
Files (x86)\Microsoft BizTalk ESB Toolkit\esb.config
b.
Replace
<esb.resolver> section of the esb.config file with
with below section :
<esb.resolver xmlns="http://schemas.microsoft.com/practices/2010/unity>">
<!-- Lifetime manager types -->
<alias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<!-- std type providers -->
<alias alias="string" type="System.String, mscorlib"/>
<alias alias="int" type="System.Int32, mscorlib"/>
<alias alias="bool" type="System.Boolean, mscorlib"/>
<!-- repository providers -->
<alias alias="IRepositoryProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.Facts.Repository.IRepositoryProvider, Microsoft.Practices.ESB.Resolver.Itinerary.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="SqlRepositoryProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.DataAccess.SqlRepositoryProvider, Microsoft.Practices.ESB.Resolver.Itinerary.DataAccess, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<!-- fact providers -->
<alias alias="IFactProvider" type="Microsoft.Practices.ESB.Resolver.Facts.IFactProvider, Microsoft.Practices.ESB.Resolver.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="IFactTranslator" type="Microsoft.Practices.ESB.Resolver.Facts.IFactTranslator, Microsoft.Practices.ESB.Resolver.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="ItineraryFactProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.Facts.ItineraryFactProvider, Microsoft.Practices.ESB.Resolver.Itinerary.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="ItineraryStaticFactProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.Facts.ItineraryStaticFactProvider, Microsoft.Practices.ESB.Resolver.Itinerary.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="ItineraryHeaderFactProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.Facts.ItineraryHeaderFactProvider, Microsoft.Practices.ESB.Resolver.Itinerary.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="ItineraryContentsFactProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.Facts.ItineraryContentsFactProvider, Microsoft.Practices.ESB.Resolver.Itinerary.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="ResolutionFactProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.Facts.ResolutionFactProvider, Microsoft.Practices.ESB.Resolver.Itinerary.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="DefaultFactTranslator" type="Microsoft.Practices.ESB.Resolver.Facts.DefaultFactTranslator, Microsoft.Practices.ESB.Resolver.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="ItineraryFactTranslator" type="Microsoft.Practices.ESB.Resolver.Itinerary.Facts.ItineraryFactTranslator, Microsoft.Practices.ESB.Resolver.Itinerary.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="ItineraryContentsFactTranslator" type="Microsoft.Practices.ESB.Resolver.Itinerary.Facts.ItineraryContentsFactTranslator, Microsoft.Practices.ESB.Resolver.Itinerary.Facts, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<!-- resolve providers -->
<alias alias="IResolveProvider" type="Microsoft.Practices.ESB.Resolver.IResolveProvider, Microsoft.Practices.ESB.Resolver, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<alias alias="ItineraryResolveProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.BREItineraryResolverContainer,Microsoft.Practices.ESB.Resolver.Itinerary, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 "/>
<alias alias="StaticItineraryResolveProvider" type="Microsoft.Practices.ESB.Resolver.Itinerary.StaticItineraryResolveContainer,Microsoft.Practices.ESB.Resolver.Itinerary, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 "/>
<!-- test containers -->
<container name="BRI">
<register type="IResolveProvider" mapTo="ItineraryResolveProvider" />
<register type="IFactProvider" mapTo="ItineraryFactProvider" name="ItineraryFactProvider">
<lifetime type="singleton" />
</register>
<register type="IRepositoryProvider" mapTo="SqlRepositoryProvider" name="CurrentRepositoryProvider">
<lifetime type="singleton" />
<constructor>
<param name="connectionStringName">
<value value="ItineraryDb"/>
</param>
<param name="cacheManagerName">
<value value="Itinerary Cache Manager"/>
</param>
<param name="cacheTimeout">
<value value="120" />
</param>
</constructor>
</register>
<register type="IFactTranslator" mapTo="DefaultFactTranslator" name="DefaultFactTranslator">
<lifetime type="singleton" />
</register>
<register type="IFactTranslator" mapTo="ItineraryFactTranslator" name="ItineraryFactTranslator">
<lifetime type="singleton" />
<constructor>
<param name="repositoryProvider">
<dependency name="CurrentRepositoryProvider"/>
</param>
</constructor>
</register>
</container>
<container name="ITINERARY">
<register type="IResolveProvider" mapTo="StaticItineraryResolveProvider" />
<register type="IRepositoryProvider" mapTo="SqlRepositoryProvider" name="CurrentRepositoryProvider">
<lifetime type="singleton" />
<constructor>
<param name="connectionStringName">
<value value="ItineraryDb"/>
</param>
<param name="cacheManagerName">
<value value="Itinerary Cache Manager"/>
</param>
<param name="cacheTimeout">
<value value="120" />
</param>
</constructor>
</register>
<register type="IFactProvider" mapTo="ResolutionFactProvider" name="ResolutionFactProvider" />
<register type="IFactProvider" mapTo="ItineraryHeaderFactProvider" name="HeaderFactProvider" />
<register type="IFactProvider" mapTo="ItineraryStaticFactProvider" name="StaticFactProvider" />
<register type="IFactProvider" mapTo="ItineraryContentsFactProvider" name="ItineraryContentsFactProvider" />
<register type="IFactTranslator" mapTo="DefaultFactTranslator" name="DefaultFactTranslator">
<lifetime type="singleton" />
</register>
<register type="IFactTranslator" mapTo="ItineraryFactTranslator" name="ItineraryFactTranslator">
<lifetime type="singleton" />
<constructor>
<param name="repositoryProvider">
<dependency name="CurrentRepositoryProvider"/>
</param>
</constructor>
</register>
<register type="IFactTranslator" mapTo="ItineraryContentsFactTranslator" name="ItineraryContentsFactTranslator">
<lifetime type="singleton" />
<constructor>
<param name="overrideExistingItinerary">
<value value="False"/>
</param>
</constructor>
</register>
</container>
</esb.resolver>
You can also refer the Microsoft support : https://support.microsoft.com/en-us/help/2887594/esb-toolkit-bre-itinerary-resolver-fails-with-exception
Regards,
Farhan Jamil
Senior Software Engineer
Systems Limited,Pakistan
Very helpful.
ReplyDelete