Showing posts with label J2EE. Show all posts
Showing posts with label J2EE. Show all posts

Friday, January 18, 2008

Writing Cluster Application

Here is a checklist of things that need to be done to write good application which would work in Cluster enviroemnt

  • When accessing the cluster from outside using HTTP or RMI verify that access to the cluster is done throught load balancer, this can be either software or hardware load balancer.
  • Consider using 'Optimistic Locking' or 'Pemisitic Locking' if two or more clients may update the same row in the databse at the same time
  • If you want to cache data all over the cluster and not on a single server then don't use Singleton, you would need to user Cache framework such as GigaSpaces or OSCacheor JCache etc', this solution is good mainly for read only data or data which is mostly read.
  • In many application servers you can configure your MDB if it would run on a single server or on several servers.
  • Avoid reading files/writing to files in the code, Since you may run on different hosts in the cluster and the files may not exists on the current host which you are running
  • Use Synchronize where two threads may access the same data at the same time, This problem can also occure on non cluster system.

Please comment if you have other issues which are missing.

Wednesday, December 19, 2007

Runtime Exception or Regular Exception

This is the question that asked often, when should I throw RuntimeException and where should I throw regular Exception, this is the answer:

  • If you exception which is thrown is pure technical exception from which the client can't recover from then throw RunTime Exception in case you run in J2EE server with Transaction Manager set then it would also rollback the transaction. Even that this exception doesn't have to be declared as part of the function exception signature it is advice to declare it so the client would be aware for this exception.
  • If your exception is pure business applicative exception then this exception should be regular not RunTime exception so this exception would be displayed for the user in the end and he would be able to change something to fix it, when throwing this exception in J2EE server with Transaction Manager the transaction doesn't rollback.

Saturday, December 8, 2007

J2EE Rapid Development

Developing in J2EE environment should be fast and rapid, I have been working with all this J2Ee Servers - WebSphere, WebLogic, Netweaver, JBoss. All this application servers except JBoss take a lot of time to finish their startup, some of them take few minutes and some more then 10 minuets, this is pretty frustrating making some small change in the code and then wait more then 10 minutes for the server to start and then to wait some more minutes for the deploy to finish.

In JBoss it is pretty fast it take about one minute for the startup to finish, and about two minutes for the deploy to finish, This may save a lot of time to develop in J2EE Environment,

Not to mention the great feature of hot-deployment in which the code inside the method can be change without the need to restart the application server.

Many development managers doesn't take in consideration this thing when choosing application server, In my opinion this can save a lot of time and improve the development speed.

Links

 
RSS Feeds Submission Directory