Monday, July 22, 2013

Sonar - Code Quality Management

This Sonar tool is saving me a lot of time these days. Gone are the days where I need to worry about the developer following the coding standards of JAVA, HTML and JS.
I only need to worry about the business logic review these days.

This open source tool is surely a must have for every team. Check it out.
http://www.sonarsource.com/

The developers are also benefited as they are able to improve in their coding standards by using this tool.

Few plugins which are impressive are
http://docs.codehaus.org/display/SONAR/Quality+Index+Plugin
http://docs.codehaus.org/display/SONAR/Toxicity+Chart+Plugin
http://docs.codehaus.org/display/SONAR/Motion+Chart+Plugin

There are lot more though which can be easily added.


Wednesday, January 23, 2013

Exception Handling - Non happy path

When a application or process is developed, the main requirement would be quite simple or might look simple. But have a look at the below diagram which shows a process which is part of an application (courtesy: workflowpatterns).

Figure 1: Options for handling work items

The solid lines (which are only 3) indicate the normal state through which the execution will flow. We could accomplish this normal flow with some programming knowledge and some technical skills.

But the tricky part is the flow indicated using dotted lines. There are 17 of them!
These will not be considered during most of the discussions with the business owner. Many of them might be even missed during design and implementation. But they are important for sure. These dotted flows make the application fail proof and allows the support team to maintain the application without nightmares.

If you think you can develop an application within a few days, then you are surely not considering these dotted lines, as this is the part which takes more time during the development and testing cycle.
If you don't want to get stuck with maintaining the application for long and don't want to have sleepless nights on production issues, then consider all possible dotted lines (in other words the Non-Happy paths) for your application. Also make sure you let your business owners know the importance of handling all exception scenarios. This might take a little longer for your application to go live, but it will stay live for longer.

Thursday, October 25, 2012

Spatial Data Visualization

Have been working on spatial data visualization lately.

Two interesting open source spatial tools were analysed by me for my new project. OpenGeo and GeoMondrian. I also analysed OBIEE map viewer which is a proprietary product from Oracle. Out of them OpenGeo turned out to be a pleasant surprise.

I would like my software to be like OpenGeo because of its excellent documentation and nice administrative features. I am surprised that a open source project can be so neatly executed.

I am yet to use it on a live project, but it has surely impressed me.

Friday, April 27, 2012

Configuring SAF agent

Below are the steps on how to create a SAF agent with file persistent store that receives messages from a publisher and forwards to another JMS server configured with JDBC persistent store.
Create two Domain1 and Domain2. Domain1 will be configured with SAF agent where as Domain2 will be configured with destinations where the consumer will listen to receive and process messages.
Domain2 configuration
  • Create JDBC data store
  • Create Persistent store based on the above JDBC data source
  • Create a new JMS server based on this JDBC persistent store
  • Create a new JMS module
  • Create a new Subdeployment for this JMS module and choose the JMS server created above
  • Create a new Connection factory
  • Create a new Queue and configure this to use the subdeployment
Domain1 configuration
  1. Create File based persistent store
  2. Create a new JMS server based on this JDBC persistent store
  3. Create a new Store-And-Forward agent.
    1. Since we are using JMS, this can only be a "Send-only" agent. 
    2. Also make sure "Logging enabled" option is selected. This allows the message to be logged in the server log file
  4. Create a new JMS module
  5. Create "Remote SAF Context" resource
    1. select the name of the remote SAF context
    2. provide the URL context for the SAF agent to login. This will be pointing to domain2 we created above.
    3. provide the credentials to logon to the aboe domain
  6. Create "SAF Error Handling" resource
    1. choose the name
    2. set Message Handling Policy to "Always-forward" since we are neither interested in discarding any messages nor re-directing them to error destination
  7. Create a new Connection factory
  8. Create a new "SAF Imported Destinations" resource in the JMS module
    1. select Remote SAF Context created above
    2. select SAF Error Handling resource created in previous step
  9. After creating the "SAF Imported Destinations" and saving the configuration, create required SAF destinations for the remote destinations
    1. create a new Queue
    2. choose Queue name
    3. choose Remote JNDI name. This will be the destination JNDI name configured in Domain2
    4. Save the Queue
    5. Select the Queue and provide "Local JNDI Name". This will be used by the publisher to publish any messages to this destination
This should configure the SAF agent to forward the messages successfully to the remote destinations. Now we can publish a message to the SAF destination and consume messages on the remote destination.

.

Tuesday, April 24, 2012

Thursday, April 19, 2012

Get Records having the 2nd highest value

SQL to fetch all records having the 2nd highest value in a given column. This is for Oracle(pl-sql) dialect


SELECT *

FROM some_table

WHERE val=

(SELECT MAX(val)

FROM some_table

WHERE val <>

(SELECT MAX(val) FROM some_table

)

);


If you need only the 2nd largest value, then you can use

SELECT MAX(val)

FROM some_table

WHERE val <>

(SELECT MAX(val) FROM some_table

)


Similar statement holds good for 2nd smallest as well. Use MIN instead of MAX.
.

Latest transaction for all users

Here is SQL to fetch the last transaction records for all users. Note that this is for Oracle (pl/sql)


SELECT *

FROM some_table t

INNER JOIN

(SELECT user_id,

MAX(record_id ) AS record_id

FROM some_table

GROUP BY user_id

) v

ON p. record_id = v. record_id;