how is yahoo messenger's architecture (or msn messenger's, news alert's)

Hi,
   I want to develop an instant messaging system like yahoo or msn
messenger. I have a website with oracle database, jsp, Apache
webserver. I want to develop an application connecting to my oracle
database and to recieve or send messages, notifications.
   I can say that people have yahoo account(mail) and they use yahoo
messenger for instant messages and notifications(such as : you have
new mail!).I need something like this. I need to access my web site's
database via a program.
   I don't know where to start. COM, API, socket programming?
   I would appreciate anyone's help and also suggestions for any
documents or articles in the internet.
  John