I've started working on my master thesis. To those of you who don't know, it is going to be about "Distributed Transactions in SOA". Pretty challenging and very interesting! There is still not much information about this, but in general the topic for distributed transactions has been around for like 20 years now. That said, there is a substantial research behind, but what is missing right now is the "glue", which will bring that knowledge to the SOA world.
I am planning to implement two different concurrency protocols - WS-AtomicTransation and WS-BusinessActivity. Nonetheless, WS-Coordination is the coordination protocol used in both of these concurrent protocols, so I have implement it as a pre-requisite. Well these protocols are still a work in progress by OASIS Web Services Transactions group (link).
Starting with WS-AtomicTransactions, I ended up on a problem, which occurred to be well-known in the distributed transactions and concurrency control namespace. It is called "heuristic outcomes" and it about the two-phase commit (2PC) protocol. Let's consider that after the first phase (the preparation phase), all participants reply with PREPARE/COMMIT message. Accordingly, the coordinator decides to commit the whole transaction and thus starts sending COMMIT message to all of the participants. But .. suddenly after he has sent the COMMIT message to 3 of the participants, an unexpected network outage occurs. So the remaining let's say 2 participants are waiting for their COMMIT message, but it doesn't arrive. To summarize - we have 3 participants which have already committed the transaction and another 2 which are wondering what to do (from here comes the term "heuristic outcomes", because the final decision of these 2 will make is somehow heuristic). Well, so far I haven't seen a resolution for this issue - it is rather relied upon that the logging system will be pretty sophisticated so that the administrator of your system will see this non-conformity and will manually "compensate" the COMMIT changes of the 3 participants and thus bring the whole system back in a consistent state.
Tuesday, April 18, 2006
Sunday, April 16, 2006
Query Notifications in ADO.NET 2.0
Query Notifications are a new feature part of ADO.NET 2.0. I gotta admit that the rationale behind it is really valuable - getting notifications back from the database server, when a given dataset of interest is changed. I've implemented the same functionality with MSSQL 2000 requiring periodical server polls, but this is really not very performant solution. With ADO.NET 2.0 and its Service Broker, you can have quick and elegant solution.
While the idea behind QN is really easy to understand, the documentation and examples are still kinda scarce. Not only this, but there turned out to be very small details, which may give you couple of hours in debugging in order to detect them.
To start with, here is a list of articles about Query Notifications in ADO.NET 2.0:
1. Query Notifications in ADO.NET 2.0 [link]
2. Using Query Notifications [link]
3. Enabling Query Notifications [link]
4. Using a Dependency to Detect Changes in the Server [link]
All of these will give you some very good understanding of what QN is all about. However, I found some problems with the examples in them, so don't be confused if you try them and they are not working - it is not you :)
Speaking of problems, one of the subtle things you should have in mind is that the query assigned to the SqlCommand object must be fully qualified (that is the table name should include the table owner, you should enumerate all interested columns in the SELECT clause rather than putting a simple * for ALL columns). Actually if you take a look at the following article:
5. Using SqlDependency for data change events [link]
you will see a bunch of things which the author has experienced (the same as me) while dealing with QN.
Another problem that I got was with my OnChangeEventHandler event handler. I initially received OnChange notifications although there were no DML operations on the monitored dataset. The info that I got from the SqlNotificationEventArgs parameter for this event was the following:
e.Source = Statement
e. Type = Subscribe
e.Info = Invalid
The reason for this was that my SELECT statement was using * for all the column names instead of fully qualifying the columns put in interest. I bet that if this is a problem, then the description of it should be somehow more descriptive and showing more symptoms of what actually caused the specific problem.
Another problem that I got was with the QN registration for the specific database you want to enable it. For this, you should check out the following article:
6. Using Query Notifications in .NET 2.0 to handle ad-hoc data refreshes [link]
SqlDependency is one way to use Query notifications in your application. What is worth noting about it, is that one SqlDependency is good only for a single notification. That said, after one notification has been generated through your SqlDepedency, you should re-create it if you want further changes to be captured. Another cool thing with SqlDependency, is that it can easily applied to ASP.NET cache object (check out article 1 for more information).
While the idea behind QN is really easy to understand, the documentation and examples are still kinda scarce. Not only this, but there turned out to be very small details, which may give you couple of hours in debugging in order to detect them.
To start with, here is a list of articles about Query Notifications in ADO.NET 2.0:
1. Query Notifications in ADO.NET 2.0 [link]
2. Using Query Notifications [link]
3. Enabling Query Notifications [link]
4. Using a Dependency to Detect Changes in the Server [link]
All of these will give you some very good understanding of what QN is all about. However, I found some problems with the examples in them, so don't be confused if you try them and they are not working - it is not you :)
Speaking of problems, one of the subtle things you should have in mind is that the query assigned to the SqlCommand object must be fully qualified (that is the table name should include the table owner, you should enumerate all interested columns in the SELECT clause rather than putting a simple * for ALL columns). Actually if you take a look at the following article:
5. Using SqlDependency for data change events [link]
you will see a bunch of things which the author has experienced (the same as me) while dealing with QN.
Another problem that I got was with my OnChangeEventHandler event handler. I initially received OnChange notifications although there were no DML operations on the monitored dataset. The info that I got from the SqlNotificationEventArgs parameter for this event was the following:
e.Source = Statement
e. Type = Subscribe
e.Info = Invalid
The reason for this was that my SELECT statement was using * for all the column names instead of fully qualifying the columns put in interest. I bet that if this is a problem, then the description of it should be somehow more descriptive and showing more symptoms of what actually caused the specific problem.
Another problem that I got was with the QN registration for the specific database you want to enable it. For this, you should check out the following article:
6. Using Query Notifications in .NET 2.0 to handle ad-hoc data refreshes [link]
SqlDependency is one way to use Query notifications in your application. What is worth noting about it, is that one SqlDependency is good only for a single notification. That said, after one notification has been generated through your SqlDepedency, you should re-create it if you want further changes to be captured. Another cool thing with SqlDependency, is that it can easily applied to ASP.NET cache object (check out article 1 for more information).
Thursday, April 06, 2006
SqlDateTime overflow problem and DATETIME columns allowing NULLs
Couple of hours spent in debugging and finally you see the problem is cased by a completely different reason. This was my today's experience.
So you have T-SQL insert statement for a table which has one of its columns defined as DATETIME which allows NULLs. You are passing an uninitialized variable for exactly this column in your INSERT (not purposely of course :) ), and the error you get is:
What do you do? Well, I was very confused seeing this message. I hit the Internet for a similar problem but I was totally deluded in stories that SqlDataType is not compatible with .NET DataTime type. Obviously I was on a wrong direction. Thus, after I reviewed my code, I saw that the value of the DateTime column, which allows NULLs is not actually NULL but rather DateTime.MinValue - indeed, and this is normal because each .NET variable once defined it is initialized with some default value (which in the DateTime case is DateTime.MinValue). Unfortunately, DateTime.MinValue doesn't really fit into the range of possible values for SqlDataTime.
What is the resolution? Well, I am using .NET 2.0, where there is a very neat generic type named Nullable. Check out this article for more info about it. Put shortly, using this type I am able to pass NULL values for the DATETIME column allowing nulls without getting the extremely confusing exception shown above.
So you have T-SQL insert statement for a table which has one of its columns defined as DATETIME which allows NULLs. You are passing an uninitialized variable for exactly this column in your INSERT (not purposely of course :) ), and the error you get is:
System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between
1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
What do you do? Well, I was very confused seeing this message. I hit the Internet for a similar problem but I was totally deluded in stories that SqlDataType is not compatible with .NET DataTime type. Obviously I was on a wrong direction. Thus, after I reviewed my code, I saw that the value of the DateTime column, which allows NULLs is not actually NULL but rather DateTime.MinValue - indeed, and this is normal because each .NET variable once defined it is initialized with some default value (which in the DateTime case is DateTime.MinValue). Unfortunately, DateTime.MinValue doesn't really fit into the range of possible values for SqlDataTime.
What is the resolution? Well, I am using .NET 2.0, where there is a very neat generic type named Nullable
Wednesday, April 05, 2006
LoginStatus control does the work
Today I was fighting with the well-known problem with Back button in Internet browsers for a session agnostic Web applications. Simply put, you have a Web app and at some point of time you want to sign out. Then you normally destroy the user's server side session, but the problem is that the user still can hit his Back button on the Internet browser and see a the cached content from the pages he/she has visited.
Well, this problem has been resolved long time ago - I remember it since the early ASP days. So normally what is done is to set the content expiration to immediate to *all* pages within your Web application. Of course, sometimes, this may be not desirable, but still in my cases it was essential not to give the user the possibility to go back. So the solution is to set 3 HTTP headers to all HTTP responses - Pragma, CacheControl and Expires.
Today, I had the same problem while implementing the logout functionality of our ASP.NET 2.0 based Web application (just to mention we are using very cool stuff like Microsoft Atlas, SQL 2005, Virtual Earth API - fascinating, isn't it?). Again, the old solution seems to be working (setting the aforementioned HTTP headers), but I somehow decided to try out the LogingStatus control. This control changes its state based on the current user status - if he is logged in it is a link which will allow him to Logout and if he is not authenticated - it will be "Login" link. And here are the good news - if you use this control, there is no need to set these headers to your whole application - it is done automatically to you when you use this control. Pretty sweet! :)
Well, this problem has been resolved long time ago - I remember it since the early ASP days. So normally what is done is to set the content expiration to immediate to *all* pages within your Web application. Of course, sometimes, this may be not desirable, but still in my cases it was essential not to give the user the possibility to go back. So the solution is to set 3 HTTP headers to all HTTP responses - Pragma, CacheControl and Expires.
Today, I had the same problem while implementing the logout functionality of our ASP.NET 2.0 based Web application (just to mention we are using very cool stuff like Microsoft Atlas, SQL 2005, Virtual Earth API - fascinating, isn't it?). Again, the old solution seems to be working (setting the aforementioned HTTP headers), but I somehow decided to try out the LogingStatus control. This control changes its state based on the current user status - if he is logged in it is a link which will allow him to Logout and if he is not authenticated - it will be "Login" link. And here are the good news - if you use this control, there is no need to set these headers to your whole application - it is done automatically to you when you use this control. Pretty sweet! :)
Monday, April 03, 2006
Cycle Clipboard Ring command
Visual Studio 2005 rules! Today I found the command named "Cycle Clipboard Ring" (on the Edit menu in VS2005 or using the default keyboard shortcut CTRL + SHIFT + V). While ago while I was so deep into the Visual Studio 6 development, I used a very popular tool named Visual Assist which was really like the paradise for all Visual C++ developers using VS6. So this tool had the same feature like "Cycle Clipboard Ring" I am referring now. I personally find it very useful to see a quick menu of all of your previously copied code blocks so that you can easily paste them. Love it!
Talking about "hidden" commands, there is one more I discovered today being very popular in Java IDEs in particular. This time this feature is part of ReSharper for Visual Studio 2005 (still a beta and not very stable thus, but still has very useful features without which I feel like I will get back in 1st grade :) ). Well this feature is named "GotoRecentFiles" and on the default keyboard scheme is accessed thru CTRL + E. This gives you a popup window with all of your recently accessed files. Sweet!
To some of you these features may not be very significant, but still when you deal with huge code bases, you want to minimize your time to switch between files and to somehow boost your productivity without dealing with routine things. I hope that this post will give some delight to those of you who are used to such kind of "widgets".
Talking about "hidden" commands, there is one more I discovered today being very popular in Java IDEs in particular. This time this feature is part of ReSharper for Visual Studio 2005 (still a beta and not very stable thus, but still has very useful features without which I feel like I will get back in 1st grade :) ). Well this feature is named "GotoRecentFiles" and on the default keyboard scheme is accessed thru CTRL + E. This gives you a popup window with all of your recently accessed files. Sweet!
To some of you these features may not be very significant, but still when you deal with huge code bases, you want to minimize your time to switch between files and to somehow boost your productivity without dealing with routine things. I hope that this post will give some delight to those of you who are used to such kind of "widgets".
Subscribe to:
Posts (Atom)