Wednesday, July 29, 2009

TransactionScopeOption vs TransactionScopeOptions

TransactionScopeOption in System.Transaction

What is the differences between TransactionScopeOptions when we use it to create TransactionScope.
We have the following option at our disposal.

1. TransactionScopeOption.Required

TransactionScope created here is dependent on the root TransactionScope.

2. TransactionScopeOption.RequiresNew

Creates an entirely new TransactionScope

3. TransactionScopeOption.Suppress

TransactionScope created here is independent of root TransactionScope.

Code below shows an example of how transactionScope takes effect when you stop your application in s1.Complete();
Data gets committed in TransactionScopeMixRequiresNew and TransactionScopeMixSupress method but not TransactionScopeMixRequires.

using (TransactionScope s1 = new TransactionScope(TransactionScopeOption.Required))



/// if you stop your application here
/// TransactionScopeMixRequiresNew and TransactionScopeMixSupress's data
/// gets committed into the database



Implementing TransactionScope is pretty straight forward. However, my testing so far tells me that TransactionScope run without hitting "Communication with the underlying transaction manager has failed" if your Application / Database server reside on the same domain.

When i try running the application from a remote location, it fails badly. I had to stick to the same domain.


To use TransactionScope, there are a few requirements that i've noticed.

a) Use a single connection. You can use the using() block if you going to execute several sql continously and then immediately close your connection. Otherwise, maintain your connection open throughout the TransactionScope. Finally call transactionScope method's called Completed.

b) If you have external connection, declared outside out the transaction block that won't work either.

For example :-

SqlConnection OUTSIDECONNECTION = new SqlConnection(myConnectionString);

using (TransactionScope scope = new TransactionScope())
///// do something external OUTSIDECONNECTION ////
//// create you own connection instance ////

DTC Troubleshooting link

I found this very useful.

Monday, July 27, 2009

Testing Code Contracts

Normally you would add reference to System.System.Diagnostics.Contracts to define your code contracts. To test it, here's how you do it.

Download Contract checker from the following url

Install it and then open your Visual Studio 2010, goto Project Explorer's Properties. You are able to locate "Code Contracts" you're good to go :)

Nunit2.5 giving System.NullReferenceException when you're trying to add assembly?

Create your NUnit GUI project, ("C:\Program Files\NUnit 2.5\bin\net-2.0\nunit.exe") and then drag + drop your assembly into NUnit. That should do it. :) It is that easy.

Sunday, July 12, 2009

Ferdinand : Scalable Query Result Caching for Web Applications

Summary : Uses disk caching method to enhance performance for database application.

Users connect directly to a proxy. Each proxy consist of STATIC web cache. These servers are connected to each other via DHT and commmuicate with each other using publish / subscribe infrastructure.

If a request is in the cache, it is retrieve immediately. If not, it is query from database. Cache is expected to be huge, therefore disk caching method is used.

Ferdinand uses database template request and offline analysis to gurantee consistency of data in database. Notification is sent to master group and everybody synchronize their data.

Prototype implementation

Apache as the web server.

MySQL - webservier

Ferdinand - custom JDBC driver

Pastry - DHT's related task.

Scribed - Publish / Subscribe component

Saturday, July 11, 2009

Cloud computing and Data Analysis.

Daniel Abadi in Data Management In the Cloud concludes that cloud computing is more suitable for large scale data analysis as oppose to transactional based system. Thus more research is expected in this area.

Part of the reason why are as follows:-

1. Transactional application does not necessarily adopt a share nothing model.

2. Maintaining ACID properties for transaction over cloud is complex.

More research in cloud computing's database evolve around the following areas:
a) fault tolerance - continue query execution in the advent of failure
b) heterogeneous cluster
c) easy of use

Sunday, July 05, 2009

Installing PHP on Apache 2.2.11 (Win32) PHP/5.2.5

Please download your Apache server and PHP. I'm assuming you installed your PHP into C:\PHP folder.

Please modify your httpd.conf file located in your conf folder with the following settings.

LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php

Restart your server. That's it.

Apache Configuration

Sample using Redirect

Redirect /myservice http://localhost:8080/service
Sample using Alias

Alias /svc c:/test/appfolder
Allow from all