Sunday, November 27, 2005

During the Code Reviews we had past couple of weeks I got a chance to look back at how we've done JMS development. I’d like to share what I’ve learnt with u guys.

One thing we noted during the reviews is that we have not paid enough attention at all to optimization of JMS. And by the comments I found in many forums this is the norm in many projects. So from now on I’m determined to pay more attention to performance whenever I do JMS related development :).

Before dwelling in to the tips I’d like to note down the basic steps of getting JMS to work.

  1. Lookup JMS connection factory
  2. Create connection & session
  3. Lookup destination (Queue or Topic)
  4. Create producers or consumers
  5. Create Msg
  6. Send or Receive Msgs

Now let’s see what we can do to improve our JMS related work. Of course I’ve not tried all of them and would like to here more about the implementation aspects of these from you guys. (Specially points 6 and 9)

  1. Close Resources (Connections, Sessions, Producers, Consumers) in a finally block
  2. Start Connections after starting producer/consumer
  3. Always start consumers before the producers to stop initial messages getting queued
  4. Choose DUPS_OK_ACKNOWLEDGE or AUTO_ACKNOWLEDGE unless it’s really necessary to use CLIENT_ACKNOWLEDGE
  5. Choose Non-durable messages wherever possible to avoid persistency overhead
  6. Process messages concurrently through a ConnectionConsumer using server session pool where each session in the pool would execute separate message concurrently (I think the implementation of this is Vendor specific. Any ideas?)
  7. Set the TimeToLive value as low as feasible (default is for messages to never expire).
  8. Configure number of message driven beans by specifying instance pool size in jboss.xml file.
  9. Use separate transactional sessions and non-transactional sessions for transactional and non-transactional messages.

Tuesday, November 15, 2005

I've been invloved in reviewing the code of our product and load testing and found out/realised some important practices that should be followed in J2EE projects. Here are few of them which are of course open for discussion,

Today I will list down some EJB related practices...

1. Never use the ejbConstructor for getting any work done (Typically resource initializations). The spec does not gurantee the call back of the constructor. Instead use the ejbCreate() method for any resource initilizations etc...Similarly use the init() method in Servletes.

2. Return PK in in ejbCreate() methods.

3. Use DTOs in ejbCreate() when there are too many parmas coming in.

4. Always use CMR (Container Managed Relations) to manage the relations. This will result in less code and straight forward finder methods thus improving code quality and performance.

5. Use the EJBHomeFactory pattern to reduce JNDI calls and cache EJBHomes.

6. Tune Stateless session beans instance pool size.Give maximum beans as equal to maximum number of client accesses.

7. Tune Entity beans instance pool size and instance cache size. Give maximum beans in pool as equal to number of maximum concurrent client accesses. Cache size must be equal to concurrent active clients accessing the bean.

Any comments or experience on these or any other ideas is mostly welcome.




Monday, November 07, 2005

Greaaaaaaat News people. I'm a proud owner of a digital camera for the first time :). After exceeding my initial budget by approximately 150% I've bought a Canon A620. I've used it for a week or so now and I'm really impressed. Specially with it's image quality and ease of use. From reviews I've heard that it's powerful too interms of manual operations and printing options. I'll find those features eventuall :). For the time being I'm very happy with what I've got. You can find a review on A620 here and the specification here.

If u guys have any good sites where I could learn digital photography a bit send them in.