Sunday, March 18, 2012

ActiveMQ Network Of Brokers (Network Connector) Vs Network Bridge

Network Connector:

ActiveMQ network of brokers configuration is achieved using network connector. A network connector specifies one or more ActiveMQ servers/brokers where messages are forwarded or pushed from the ActiveMQ server which has this network connector is configured.

Following diagram makes it clear:



There is a duplex property on network connector configuration which allows bi-directional message flow similar to network bridge. Wth this property set to true, all destinations configured in network connector will be available for bi-directional message flow, where as in network bridge one can choose explicit destinations. For example you want to forward all the messages from Hub to spoke but only want to forward selective destination message from spoke to hub then a network bridge is better.

Network Bridge:
A network bridge configuration on a ActiveMQ server/broker, allows message to be selectively consumed from other ActiveMQ brokers or forwarded from this source ActiveMQ server/broker to other ActiveMQ server/broker.

Following diagram makes it clear:


Promote your blog

Thursday, March 15, 2012

Spring enable @Transactional annotation

In Spring to enable @Transactional Annotation processing you would need to specify  <tx:annotation-driven>
in your Spring xml configuration file.

Example:
<tx:annotation-driven transaction-manager="txManager"> </tx:annotation-driven> Promote your blog

Sunday, March 11, 2012

HBase Composite Row Key Design: Doing Table Scan Using Partial Row Key Part2

In my previous blog I described how to design HBase table row key which allows partial row key scan. Now in this second blog lets look at another example of composite row key where we will have 3 seperate fields in the key.

The key will consist of userId, date and sessionId. Something like this:

userIdBytes+seperatorByte+dateStringByte+seperatorByte+sessionIdBytes
Here seperatorByte should be choosen in such a way which does not conflict with userId and sessionId bytes values. For example use LF (decimal 10)


This key design allows partial key scan in following ways:

  • To find all the sessions for a given user just specify  userIdBytes as start row when creating table Scan object.
  • To find all the session for a given user on a given date or a given range of date  just specify  userIdBytes+seperatorByte+dateStringByte  as start row and end row, when creating a table Scan object.
  • To find a specific sessionId, specify whole key userIdBytes+seperatorByte+dateStringByte+seperatorByte+sessionIdBytes, as start row, when creating table Scan object.
So we can see the key design facilitates two different ways of doing a partial scan on the HBase table.




Promote your blog

Tuesday, March 6, 2012

HBase Composite Row Key Design: Doing Table Scan Using Partial Row Key

HBase is a column oriented NoSql Database which uses Hadoop file system as the data storage.The rows in HBase are stored in sorted order, meaning they are alphabetically sorted.Typically one creates an HTable with one or more column family and store data in it.

A column family is a collection of dynamic columns, meaning column name can be defined when storing data and so one can have n number of columns and there is no limit to it.Data in a table is stored using a row key and specifying column family, column name and column value. The row key is just a byte array.


The row key of a HBase table can be a composite key, consisting of multiple individual keys.For example one can design a key to keep track of user and number of session a user has.In this case a row key can be:


userIdBytes+seperatorByte+sessionIdBytes.


Here seperatorByte should be choosen in such a way which does not conflict with userId and sessionId bytes values. For example use LF (decimal 10)

This row key design allows partial table scanning, where to get all the sessionIds for a user one can simple create a HBase Scan object with userId as the start row of the Scan and get all table rows for this userId. Meaning one can get all the rows which start with this userId.

The other advantage of this key design is that one can extract sessionId from the row key itself without actually loading data from HBase.




Promote your blog