Skip to main content

Posts

Showing posts from August, 2009

RabbitMQ java clients for beginners

Here is a sample of a consumer and producer example for RabbitMQ. The steps are
Download ErlangDownload Rabbit MQ ServerDownload Rabbit MQ Java client jarsCompile and run the below two class and you are done.
This sample create a Durable Exchange, Queue and a Message. You will have to start the consumer first before you start the for the first time.

For more information on AMQP, Exchanges, Queues, read this excellent tutorial
http://blogs.digitar.com/jjww/2009/01/rabbits-and-warrens/

+++++++++++++++++RabbitMQProducer.java+++++++++++++++++++++++++++
import com.rabbitmq.client.Connection; import com.rabbitmq.client.Channel; import com.rabbitmq.client.*; public class RabbitMQProducer { public static void main(String []args) throws Exception { ConnectionFactory factory = new ConnectionFactory(); factory.setUsername("guest"); factory.setPassword("guest"); factory.setVirtualHost("/"); factory.setHost("127.0.0.1"); factory.setPort(5672); Conne…

Why do you become so valuable when you are leaving the company?

I work for a good software company and for the last 2 years they didn't do any appraisals. This year we worked like hell on a big project within the company and were expecting to get a decent raise but due to bad economy the appraisal were not done. The company still pays the market rate and due to bad economy none of the employees were thinking of switching jobs. Suddenly I got this job offer from another cool startup and I told my CTO on phone (because he was on vacation) that I am leaving. We had a long conversation on phone and I asked for a day to decide on it. He calls up again after 10 minutes and told me that if its a monetary decision to leave the company than I can tell him and the company do something about it and the company willing to offer me employee stock options to retain me. Not that I am leaving the company because of monetary reasons but how come suddenly I became so valuable that I am being offered stock options and some more money whereas no one talked about…

Sql Optimization Tricks in oracle

When optimizing queries, the first thing I do with a slow query is figure out what it's trying to do. You can't fully optimize a query unless you know how to consider alternative ways to write it, and you can't do that unless you know what the query "means." I frequently run into a situation where I'm forced to stop and ask what they were trying to do with the query. This is database-agnostic, not related to Oracle. Dont optimize if you dont need to Use Oracle Grid Control to find the top queries and only work on them. Check Oracle Grid Alerts to see if you are doing more I/O or more CPU or insufficient SGA is allocated, if queries are doing more sorts or using sort joins than a bigger sort area can help, similarly a bigger hash area can help for hash joins. Avoid Union and use Union All if possible: - Union will require elimination of duplicates and if you know that the sets to union does not have duplicates than use Union all. Avoid correlated subqueries: -…

Oracle TM contention

Assume there exists a table DEPARTMENT. Table EMPLOYEE references DEPARTMENT using field SYS_DEPT_ID. When SYS_DEPT_ID is not indexed, and EMPLOYEE has large no of rows, this can cause long-running TM lock on delete of a DEPARTMENT row because oracle has to figure out if there are any employees working on this department or not. You can use Oracle Grid control to see the wait events and if you see a TM contention wait event than use the following query to identify these types of missing indexes so they can be added.

SELECT * FROM (
SELECT c.table_name, cc.column_name, cc.position column_position
FROM user_constraints c, user_cons_columns cc
WHERE c.constraint_name = cc.constraint_name
AND c.constraint_type = 'R'
MINUS
SELECT i.table_name, ic.column_name, ic.column_position
FROM user_indexes i, user_ind_columns ic
WHERE i.index_name = ic.index_name
)
ORDER BY table_name, column_position;

How to find constraints with same columns but different name between two databases.

How to find constraints with same columns but different name between two databases.

select
prodschema.cons prod_constraint, prodschema.tbl prod_table, prodschema.cols prod_cols, localschema.cons local_constraint, localschema.tbl local_table, localschema.cols local_cols,
'ALTER table '|| prodschema.tbl ||' rename constraint ' || prodschema.cons || ' TO ' || localschema.cons || ';' sqlchg
from
(select
constraint_name cons,
constraint_type cons_type,
table_name tbl,
ltrim(max(sys_connect_by_path(column_name, ','))
keep (dense_rank last order by curr), ',') as cols
from
(select
ucc.constraint_name,
uc.constraint_type,
ucc.table_name,
ucc.column_name,
row_number() over (partition by ucc.constraint_name, ucc.table_name order by ucc.position) as curr,
row_number() over (partition by ucc.constraint_name, ucc.table_name order by ucc.position) -1 as prev
from
user_cons_columns@build3 ucc, …

How to find index with same columns but different name between two oracle databases.

How to find index with same columns but different name between two databases.

select
targetDB.idx targetDB_index, targetDB.tbl targetDB_table, targetDB.cols targetDB_cols, sourceDB.idx sourceDB_index, sourceDB.tbl sourceDB_table, sourceDB.cols sourceDB_cols,
'ALTER INDEX ' || targetDB.idx || ' RENAME TO ' || sourceDB.idx || ';' sqlchg
from
(select
index_name idx,
table_name tbl,
ltrim(max(sys_connect_by_path(column_name, ','))
keep (dense_rank last order by curr), ',') as cols
from
(select
index_name,
table_name,
column_name,
row_number() over (partition by index_name, table_name order by column_position) as curr,
row_number() over (partition by index_name, table_name order by column_position) -1 as prev
from
user_ind_columns@sourceDB
where index_name not like 'SYS_%')
group by index_name, table_name
connect by prev = PRIOR curr and index_name = PRIOR index_name and table_na…

Changing jobs in recession

Its a tough decision to change jobs in recession as finding a new job in case of eventuality can be tough. I have been through those times once when I had landed in US and just 3 months after the VCs decided to close the company. It was a tough time at that moment to find a job without a car.

But this time its a different story. I am now in a stable company and it has a recurring revenue model and it will run for 5-10 years easily. Looks like I have become comfortable in the job. Even though I put in 10-11 hours daily at the job for 5 days a week I just feel from inside that its time to change. The job is great and I am working in the platform team that develops frameworks that are used by other teams but something is missing. Not sure what but sometimes you keep on asking yourself this question is it time for a change?

I need a new spark in my life and job. That's why when the co-founders of my previous company contacted me for a job I was dreading on it for 3-4 months but were p…

Samsung Epix is the worst phone I have used

I was using Samsung BlackJack II before and was pretty happy with its features and performance. Though I am not much of a windows mobile fan it did solved the purpose pretty well. I was very excited when my contract was getting over and saw that the big brother Samsung Epix was available from AT&T. I placed the order and waited for a loooong week to get my hands on it and Boy the touch screen and optical mouse was amazing. Problems started when I tried to connect this phone to wifi. Stupid phone wont connect to wifi. It will keep asking me for the network key. I turned off security on my wireless router and still this phone will continuously ask for Network key. I did a hard reset on phone and tried again and finally it connected to wifi. But after few mins the wifi connection was lost and it keeps asking for network key again. After 4 hours of struggling to get wifi working I gave up on it. Than I saw that an ID1 patch from Samsung is available. It took me 1 hour to get it up and…