Tuesday, July 24, 2012

Gotcha: BAM API Anomaly

Scenario:
A helper class is created to log activities using BufferedEventStream class available with BAM API. We created an instance of this helper class in orchestrations and called various methods from the helper class to  ActivityStart, Error, EndActivity, ActivityUpdate etc.

Issue:
We observed that, some of the entries we logged using UpdateActivity method are randomly not stored into BAMPrimaryImport database(thus not showing up on BAM Portal). We also observed that, UpdateActivity call prior to EndActivity call seems to be having this issue more often.

Fix:
In each BAM API call in the helper class, we are creating new BufferedEventStream object. Since BufferedEventStream is asynchronous in nature and we are creating separate instances of these, I suspected that there could be random cases where UpdateActivity calls might be logged after EndActivity calls. I read from the documentation that, EndActivity should be the last method to be called. So we then created an instance varible of type BufferedEventStream and used it in all calls rather than creating separate instance of it in every method. After doing this, we did not find any issues with activity entries on BAM portal.

We have spent quite a bit of time to troubleshoot this issue with few other alternatives until we finally figured out the fix. I hope this post helps and saves time, if any one else finds similar issues.

Monday, December 12, 2011

Gotcha: Initial Value property of BizTalk orchestration integer variable

Define a variable in an orchestration and choose type as int32. We can see that value property is blank and we can tab out from property window. But if we specify some default value for Initial Value property , tab out, go back and try to delete it , we get a popup window with error as "Property value is not valid.".
To me , this looks like a bug in editor (unless I miss something here!!!).

Here is quick workaround to be able to assign blank value to an already assigned  integer variable,
Change type from int32(System.Int32) to char and again change it back to int32. Now we can see that, Initial Value property has blank value and we can tab out from the window with no errors.

HTH.

Saturday, December 10, 2011

Gotcha: BizTalk Map

Did you ever find that, simply mapping link from source schema node to target schema node in BizTalk map doesnt stick as you intended to the mapping surface, but everything else seems to look fine?

Here is something to check out, see if value property on target schema node is set to some default value.If there is any value set, then we would not be able to map to that node until we clear out that value.

Although this looks like a simple check, it could very well take quite a bit of troubleshooting time if not realized soon enough.

HTH.

Monday, November 21, 2011

Gotcha: Host instance set up during BizTalk Server reinstallation

Recently we had an intance where one of VM's had crashed which has BizTalk server installed on it with its databases on SQL Server hosted on a different machine. We then reinstalled and set up BizTalk Server and associated components. Since the other machine which has SQL Server was not down, we could see that all our application configuration (like applications, bindings, hosts, host instances etc.)  remained intact. Although all host instances were listed,  status of all host instances was shown as "Status Unavailable" which is because physical windows process for each host instance is not there on the machine which is just re-configured. Fortunately, it is easy to get the processes back on the machine by doing the following,
  1. Right click on host instance
  2. Click on Configure and just enter password (account name is already populated)
 We can now see that respective windows processes get created and status is changed to Stopped.

Another important step needed is to install BizTalk application assemblies into GAC.

HTH.

Monday, October 17, 2011

SQL query for multi keyword search

I recently came across a scenario where user enters multiple search keywords separated by delimitor character and needs to retrieve all rows from SQL Server database when certain column contains at least one of the words in the given list. I thought, this is common scenario with search screens. Thus I am posting queries I used to do this, if anyone likes to use this approach.

User enters list of search words like, 'word1,word2,word3'.

Here is function that returns a table with list of words as single column record set,

CREATE FUNCTION SplitStrings

(@String varchar(MAX), @Delimiter char(1))
RETURNS @Results TABLE (Item varchar(200))
AS
BEGIN
DECLARE @INDEX INT
DECLARE @SLICE varchar(8000)
SELECT @INDEX = 1
IF @String IS NULL RETURN
WHILE @INDEX !=0
BEGIN
-- GET THE INDEX OF THE FIRST OCCURENCE OF THE SPLIT CHARACTER
SELECT @INDEX = CHARINDEX(@Delimiter,@STRING)
-- NOW PUSH EVERYTHING TO THE LEFT OF IT INTO THE SLICE VARIABLE
IF @INDEX !=0
SELECT @SLICE = LEFT(@STRING,@INDEX - 1)
ELSE
SELECT @SLICE = @STRING
-- PUT THE ITEM INTO THE RESULTS SET
INSERT INTO @Results(Item) VALUES(@SLICE)
-- CHOP THE ITEM REMOVED OFF THE MAIN STRING
SELECT @STRING = RIGHT(@STRING,LEN(@STRING) - @INDEX)
-- BREAK OUT IF WE ARE DONE
IF LEN(@STRING) = 0 BREAK
END
RETURN
END

Then use above function in your query as shown in the sample query below,
 
SELECT * FROM table1, SplitStrings(@SearchWords,',')
WHERE CHARINDEX(item,SearchColumn)>0
 
You could use RTRIM/LTRIM functions on item if you need to get rid of leading or trailing spaces.
 
PS: Although this does work to get what we need, this may not be the best way to do this. There could be some other better ways also to do the same. Please do look for other ways if this is not optimal solution for your needs. 
 
HTH.

Monday, May 2, 2011

Gotcha: BizTalk HTTP adapter on IIS 7.0 and above

Recently I needed to set up HTTP receive adapter(BizTalk 2009) on my Windows 7 development machine which has IIS 7.0. Source system is going to send a simple date value through query string parameter of HTTP site URL (like http://server/AppName/BTSHTTPReceive.dll?MyDate=datevalue). I followed instructions stated here on MSDN documentation and tested the set up by pointing to the site URL in a browser window(IE9). But I did not get the response as expected and observed some popup windows on my browser.

After closely looking at different steps explained in the link mentioned below, I realized that my request is really not POST, but GET . So I needed to input GET verb as well in step 8 of instructions for IIS 7.0 section. After making this change, I got the response that expected in the browser.

HTH.

Monday, March 7, 2011

Gotcha: Order of input parameter of BizTalk Map functoid

I often tend to oversee this and realize only after wasting few test cycles.

When a functoid has multiple input parameters and any input link other than last link is deleted and added, new link gets added as the last link instead of in its original position. This would adversely affect end result of functoids for which ordering is important (like Value Mapping, String Concat etc).

For eg. when we delete and add first input of value mapping functoid, then second parameter becomes first which may or may not result a boolean value and boolean expression becomes second parameter. Eventually, we will not get result as expected (if this is not realized soon enough, we may suspect end result of boolean expression and spend more time on tweaking it)

HTH.

Monday, January 31, 2011

Fix: "Error occurred while configuring the connection uri. Invalid URI: The hostname could not be parsed."

While generating schemas using WCF-SQL Adapter wizard, following error occurs if server name and instance name are not provided separately in Server Name and Instance Name fields under Config Adapter\Uri Properties tab,

"Error occurred while configuring the connection uri. Invalid URI: The hostname could not be parsed."

HTH.

Wednesday, January 19, 2011

Tip: To find last updated timestamp of SQL Server objects

Recently, I was having a need to quickly find the recently deployed stored procedure between two SQL Servers. But I found that, only Created date property is available when I right clicked and looked at the properties of Stored procedure. We can get this information by querying for modify_date column in Sys.Objects system view (or object specific views like Sys.Procedures/Sys.Tables/Sys.Views etc.)

HTH.

Monday, January 17, 2011

Tip: How to add shortcut/hot key to open Source Control explorer in Visual Studio

Although we currently have various ways to open Source Control Explorer in Vistual Studio IDE, I though it would be nice to have a shortcut or hot key to open Source Control Explorer (as we access it frequently for various needs while working in team environment). We can seet that, View->Other Windows-> Source Control Explorer does not have any shortcut key associated with it like other options do. But VS team has not left us without options to add/update these shortcut keys at our will. Here is how we can add our own shortcut key to open Source Control Explorer,
  1. Navigate to Tools->Options->Environment->Keyboard
  2. Type view.tfssource in "show commands containing" criteria and we can see respective command listed in the results list 
  3. Place cursor in "Press shortcut keys" text box and type in the key that you like to use as shortcut (make sure that, you are providing a key which is not currently being used) and click on Assign and OK buttons.

Now we can directly open the Source control by hitting our custom shortcut key. We can follow similar steps to have our own custom shortcut keys for any feature that has an associated command.

HTH.

Thursday, January 6, 2011

TIp: related to adapters of BizTalk Adapter Pack

After installing the BizTalk Adapter Pack, we can see it listed in the programs list and bindings get listed when we choose WCF-Custom adapter type. But I recently realized that, we need to manually add each adapter of Adapter pack in order use directly instead of WCF-Custom adapter with respective binding type. Steef has explained these steps in detail nicely in this blog post. Although we could technically use both WCF-Custom and explicit WCF adapter, properties in the Configuration wizard of explicit WCF adapter provides more relevant properties for respective receive location or send port. One of the observations I had was, send port of WCF-Custom->sqlBinding  type shows polling properties which are applicable only for receive location and these are not shown if we use WCF-SQL adapter and also we get neat categorized view of properties with this. If there are any other major differences between WCF-Custom and explicit WCF adapter, please feel free to mention as comment to this post.

Also remember that, name of the adapter is not updatable once it is added and the work around to do this is to delete the adapter and add it again.

Thanks.

Saturday, December 4, 2010

Tip: Replicating BizTalk Server 2010 dashboard settings across Host(Instance)s

One of the core enhancements introduced with BizTalk 2010 edition is improved BizTalk Settings Dashboard. This feature provides us an unified location to set various performance tuning settings at Group or Host or Host Instance level. In order to open this settings window, right click on BizTalk Group and choose Settings. We can also find Import and Export options on this window which allows us to migrate settings between various environments (like QA, UAT, PROD etc.) using Import and Export buttons. Here is an interesting use case of this Import/Export feature.

It is very common that we create multiple Hosts(InProcess and/or Isolated) and/or multiple Host instances under each Host as needed. It would also be common that we might want to set similar settings (with minor changes) on these hosts and/host instances. Since there are lot of settings available to fine tune the performance, it would be lot of manual effort to manually configure these settings across multiple host/host instances. So we can simplify this by configuring settings on one Host and/or one Host Instance and export to an xml file. And then Import this file on same server and map the Host/HostInstance(on Source side) that we configured to all other Hosts/Host Instances(on Destination side). After finishing the wizard, we can see that settings get replicated as intended and we can then go ahead make if there is any slight modifications needed for specific Host/Host instance. Here is sample screen shot of mapping part of the wizard,

HTH.

Tuesday, November 23, 2010

Tip: Verification of imported BizTalk assemblies after deployment

As we all know, we need to import and install BizTalk assemblies in order to use at run time and these assemblies get GACed during install operation and inserted into BizTalkMgmtDb database during import operation. If we are not updating version for the assemblies and overwrite with new assemblies each time(although this is not preferrable), it is important to make sure that assemblies are imported and installed correctly.

We can easily verify the timestamp on assemblies in GAC to make sure that Install operation is successful. We can verify import operation of Schemas by looking at schema content(not timestamp though) inside BizTalk Admin Console( =>Schemas=> =>Right click and choose Schema View). But unfortunately there is no such direct way to verify contents or timestamp of  other types of BizTalk artifacts like map, orchestration etc. A work around to verify that would be to query against bts_assembly table in BizTalkMgmtDb database*. Here is a sample query to view recently deployed assemblies on top of the result set,

select * from bts_assembly order by dtDateModified desc

*Microsoft does not recommend accessing BizTalk databases directly.

HTH.

Monday, November 8, 2010

Tip: Specifying Key file path for BizTalk projects

As we know, key file needs to be specified for any BizTalk project in order for assembly to have strong name before GAC/deploy the same. We could specify this key file either through project properties or in AssemblyInfo.cs file. We can conveniently specify the path to key file if we choose the later. But if we specify the path to key file using Project Properties window, I observed that a copy of key file is being created in respective project folder and same is being referenced. But there may be times where we might want to specify key file from a different location to avoid multiple copies of key file. Here are couple of such scenarios,

1. When we like to maintain key file at some common location(like at root level) and share the same across multiple BizTalk projects/solutions

2. When we migrate BizTalk solutions from previous versions, they might contain the path to key file. If we need to change this through browse option, we get local copy of key file and lose the ability to choose different location.

Here is a manual work around to specify key file path at BizTalk project level,

Open BizTalk project in some text editor (like Notepad), and we can observe the following section in that,

For BizTalk Server 2010 project:
< PropertyGroup >
<SignAssembly > true/false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile><path to key file here></AssemblyOriginatorKeyFile>
</PropertyGroup>

For BizTalk Server 2009 project:

<PropertyGroup >
<AssemblyOriginatorKeyFile><path to key file here></AssemblyOriginatorKeyFile>
<SignAssembly > true/false</SignAssembly>
</PropertyGroup>

Specify key file path in the AssemblyOriginatorKeyFile node and save the file. Now we can see the same path in Properties window as well.

Fix : Dll locking issue by Visual Studio

I have observed the following error while building BizTalk schemas and maps projects.

Unable to copy file "obj\Deployment\Schemas.dll" to "bin\Deployment\Schemas.dll". The process cannot access the file 'bin\Deployment\Schemas.dll' because it is being used by another process.

I could get rid of this annoying error after doing following tasks,

1. Paste the following script in PreBuild events section of
Schema Project->Properties window (found about this script on this blog entry),

if exist "$(TargetPath).locked" del "$(TargetPath).locked"

if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

2.Set CopyLocal property of Schemas dll to False

UPDATE [06.14.2015]:
Here is another alternative to get rid of this error:

We get this error most likely when we add references to other projects or dll file from project bin directory directly. Instead build and GAC the referenced project and then add reference from GAC. This way even if we open both projects in different Visual Studio windows, we will not see this locking error.

HTH.

Tuesday, October 6, 2009

Tip - Missing Add Service Reference in Visual Studio 2008(and above)??

If we choose any Framework earlier than .NET Framework 3.0 while creating project or migrate an existing project from older version of Visual Studio, we might not find Add Service Reference in the context menu when you right click on the project. Here is a way to update to the framework version of the project and get Add Service Reference option in the context menu (Project should be saved before doing this) ,

Right click on the project and navigate to the following path,

Compile->AdvancedCompileOptions(button)->TargetFramework(dropdown)

Change the Framework version to .NET Framework 3.0 (or above)

Now we should be able to see Add Service Reference option!!!!!!

HTH..

Thursday, August 27, 2009

Exception Caught: Cannot load source/destination schema: .

Issue: Ever got the following exception while trying to build BizTalk map project?
Exception Caught: Cannot load source/destination schema:. .. Either the file/type does not exist, or if a project dependency exists, the dependent project is not built.

Cause: You might probably have an empty namespace for schema file(not schema node) shown in the error above. Usually when we create a schema,respective project name is assigned as namespace by default. But when we add any existing schema which does not have namespace(most likely received from third parties), this issue might occur.

Fix: Easy..Just provide a valid value to namespace property of schema file , build schemas project(if you have seperate project for Schemas which is a good practice indeed) and build map project now.

HTH

Tuesday, April 14, 2009

Tip - Solution name is invisible in solution explorer!!!!

Ever wondered why you are not able to see the solution name in order to add more projects after adding first project to the solution ?? Show All files also doesnt get the Solution back..Here is a tip to get it back...


Go to Tools->Options ->Projects and Solutions ->General and select Always show solution checkbox ..thats it!! any guess, why would this not be a default setting for VisualStudio??


Anyways, go ahead and explore all the Visual Studio menu items once to get to know more of such environment settings.

HTH

Sunday, April 12, 2009

Installed BizTalk Server 2006 or BizTalk Server 2006 R2?

It is very easy to differentiate between most of the Biztalk Server versions by just looking at the Start Menu Program list or Administration Console etc. But things are not very straightforward when it comes to differentiate between Biztalk Server 2006 and 2006 R2. As BizTalk Server name on Start menu and Help->About <> on Administration Console do not clearly show whether current Biztalk Server installation is 2006 or 2006 R2 descriptively(rather Product version is mentioned which is not very intuitive). So I just thought of listing some quick ways to easily find it here,
  • While loading Visual Studio, Biztalk Server 2006 or Biztalk Server 2006 R2 is shown as one of the installed project templates in splash popup like window
  • WCF Adapters stack are shown under Platform Settings->Adapters in Admin Console only for Biztalk Server 2006 R2
  • Respective Product Version(3.5.1602.0 for BizTalk Server 2006 and 3.6.1404.0 for R2) is shown at following places,
    • Help->About<> in any BizTalk Server's MMC
    • Value of ProductVersion Key at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BizTalk Server\3.0 in the registry
    • Biztalkdbversion table in BizTalkMsgBoxDb
I am sure, there may be some more ways to find the same. Here is another informative blog about easily finding Biztalk Server versions.

HTH

Saturday, March 21, 2009

Some random BizTalk Server facts!!!

Here is an attempt to compile some vital information related to BizTalk server that might be useful to be aware of. I will keep updating this post as I find more interesting facts to share with. Also please feel free to let me know, if there are any corrections to the facts listed below or other useful facts.
  • Default number of Retry's that an atomic shape in an orchestration has (not sure yet, if this can be reset to different value) : 20
  • Number of levels that scopes can be nested within an orchestration: 44
  • Default Isolation Level for Atomic Transaction Type: ReadCommitted
  • Two of the ACID properties that may not be guaranteed by Long Running Transaction are: Atomicity and Isolation
  • Only called orchestrations may have Compensation. Any compensation on top-level orchestration will be ignored by Runtime engine.
  • out and reference parameters can not be passed with Start Orchestration shape (may be due to asynchronous nature of Start shape)

HTH