i'm developing an application that has a sender and a listener, but there could be multiple listeners, and there could be millions of users, how best to design the system for scalability using JMS and databases? any ideas or links?
Seems like you can implement this using JMS topic destination. Sender can send message to topic and listner can subscribe to listen message published on topic. By this way resposibilty of scalabilty will be trasffred to JMS topic provider or Application server. But while designing system you must decide the quality of service which is realiabilty/persistence which will in turn affect scalabilty of system. JMS implemantation internaly uses DB for persitence.
It would not be good idea to use database for this. You have to design your own notifiaction system to notify the listener in case new message comes. It would be really bad if listener have to poll the database for new messages.
Multiple sender and multiple reciever can use same JMS topic. For scalability don't allow durable subscription. Which helps in minimize the use of resources at JMS server. So million of reciever will get the message if they are subscribed to topic and connected at the time of message publication. Millions of sender can send/publish messages to the topic, no problem .