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.

Sunday, September 18, 2011

Observation while managing multiple configurations with Azure Configuration Wizard

Azure SDK 1.5 (recently released during Build-2011 event) provides us ability to add multiple configuration files(For eg. Local, Staging, QA, PROD etc.) and we can choose any of these configuration files during Package or Publish options.

When we use properties window to set configuration (right click on any role under roles and choose Properties) and  see that lot of properties are disabled, this is due to the fact that Service Configuration is not set to "All Configurations". This actually makes sense, as all those disabled properties are either specific to Service Definition file or common for all configuration files.

Sunday, August 28, 2011

GuestBook sample in WAPTK can be used this way too!!!

In this blog post, I would like the share my experience on how I could leverage GuestBook sample in WAPTK to address a real life issue.

I and my wife were doing a voice chat with her parents who are in India during this weekend and they reported that they were having an issue while creating a profile on a web site (You can see the registration here) and the issue is, the photo they have taken using Sony digital camera was having nearly 2 MB size and expected max size for photo on this site is 10KB. And there is a help link with some instructions on how to reduce the size of large image to fit within the expected size limit. Before I went down the path of following those instructions, I fortunately remembered about the Guestbook sample that has been used in several Azure training sessions. I thought of giving it a try and immediately ran the application from the recent downloaded version of training kit. Guess what...after uploading the image of 2 MB in size, I could get thumbnail image of size 3KB and then they were able to successfully create profile using the thumbnail image. All this has happened in just couple of minutes!! I guess, they thought that I might have some magical tool to get this done so quickly :-)

I am not sure, DPE team or whoever is responsible for these training kits would have have ever thought that their great work is going to be used to solve some real world problem like this. Anyways, I and my family personally would like to send Kudos to the team for helping us this way.