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.