A few weeks ago, an article appeared on O'Rielly that showed an example chat application that utilized Amazon's Simple Queue service to store chat messages. IMO, using a middle-ware Queuing system over a Web Service is a great idea (which was the motivation for me creating www.wsmq.com), and the idea of creating a chat application to demonstrate the features of a Web Service Queue is a good one. So, I borrowed the idea, and set about to create an instant messenger using WSMQ as the back-end chat storage mechanism.
I wanted to create a 100% Web-based chat, with out resorting to Java or other bits that don't play well in a web browser. The first problem I was faced with was how to make a request to the WSMQ server without refreshing the browser window. I found a good remote scripting JavaScript library from Alvaro Mendez that allows you to call any method on an ASP.NET page from within client-side JavaScript. This was the biggest hurdle for creating a usable chat application. The rest was fairly straight forward. It involved some relatively simple JavaScript, and some ASP.NET code to connect to WSMQ to queue and receive chat messages. The architecture ended up looking like this.
How does it work?
- A controller page polls for new chat conversations, using a remote scripting (RS) call to the back-end ASPX page control.
- This ASPX control connects to the WSMQ Service and peeks the users queue to check to see if there are any new conversations on the user's chat queue.
- If it finds a new conversation, it returns the user name requesting the new chat to the controller via an RS callback.
- The controller launches a new chat window and identifies the chat conversation partner.
- Each chat window polls the back-end ASPX page, which connects to WSMQ, receives the message and returns it to the calling window via a RS callback.
- When the user clicks “Send“ or presses enter in the chat window, a RS call is made to send each message to chat partner's queue.
Try it out online here, if there's no one else chatting, you can chat with yourself by clicking on your name. You can download the full project from the WSMQ beta program page. We're offering free accounts to use WSMQ Hosted version with our Beta program, so sign up if you haven't already. You'll be able to run the web application locally using the WSMQ Hosted queue as the chat message store
-Brendan
Posted
Wed, Jan 19 2005 1:50 AM
by
Brendan Tompkins