Book Giveaway: Grails In Action Exclusive Chapter Download
DZone and Manning Publications have partnered to bring you an exclusive chapter from 'Grails in Action' (by Glen Smith and Peter Ledbrook). This chapter covers what messaging is, how it works, and how it aids scalable architectures. It describes how to implement queues and topics with a popular JMS server. You'll also learn how scheduling is implemented in grails and more.
Understanding Messaging and Scheduling
In this chapter, we’ll keep you in that enterprise headspace, but we’ll look at sending intra-application messages. In particular, we’ll examine how different components in an application can communicate internally while different events in the application’s lifecycle unfold. One of the most popular ways of doing that is via messaging queues, an architecture sometimes referred to as message-oriented middleware (MOM).
If you’ve been around enterprise circles for a while, you’ve probably used or heard of MOM architectures. You might be thinking it’s some kind of heavyweight old-school technology that just won’t die. Nothing could be further from the truth. In fact, with the birth of service-oriented architecture’s (SOA’s) Enterprise Service Bus (ESB), and the rise of massive Web 2.0 social networking sites, we’re experiencing an explosion of interest in messaging architectures.
You might be wondering why these styles of architecture have had such a resurgence in recent years. From Twitter to Digg to LinkedIn, if you look behind any of today’s big Web 2.0 applications, you’ll find that they’re backed by an extensive messaging infrastructure. These messaging architectures are so prevalent at high-volume sites for three reasons:
- They lead to loosely coupled architectures, which means you can replace parts of your infrastructure without any client downtime.
- They have high scalability—you can add more components to process work on your queue.
- They offer a reliable transport that ensures your messages and transactions don’t get lost in the system.
In this chapter, we’ll add a messaging system to Hubbub so we can create a link between Hubbub and Jabber, a popular instant messaging (IM) system. By the time we’re done, you’ll be able to post messages to your Hubbub account via your IM client, and we’ll also bridge the other way so you can be notified of your friends’ Hubbub posts in your IM client. Along the way, you’ll learn the ins and outs of all the common messaging scenarios and get some ideas on how to apply them to your current projects.
But messaging isn’t the only asynchronous game in town. In many situations, a lightweight scheduling solution is all you need. Kicking off a daily backup? Sending out daily digest emails? Regenerating your full text index? Every developer needs to deal with these kinds of scheduled events occasionally, and Grails offers a robust and easily configurable scheduler based on the popular Quartz framework. We’ll look at the different ways you can schedule jobs—how to write daily-digest type jobs, how to turn them off and on while your application is running, and how scheduling works in clustered environments.
We’ll get into the details of scheduling a little later. For now, let’s sink our teeth into some messaging.
Click here to download the entire chapter
The above introductory excerpt was taken from Grails in Action, published in May 2009. It is being reproduced here by permission from Manning Publications. Manning early access books and ebooks are sold exclusively through Manning. Visit the book's page for more information.
| Attachment | Size |
|---|---|
| ManningChGrailsiACH12.pdf | 694.42 KB |
| book_contest_grailsinaction.jpg | 29.21 KB |
- Login or register to post comments
- 2584 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
dbailey31 replied on Fri, 2009/07/31 - 1:20pm
tomaslin replied on Sat, 2009/08/01 - 8:51am
I've been working with Grails for about a year and a half. It has its rough edges but I have never been so productive with a Java web framework the same way I have been with Grails before. It has a very supportive and forward-thinking user community, and the way you can easily integrate third party java libraries easily via the robust plugin infrastructure ( 250+ plugins! ) is just mind blowing.
If you're suffering from Java fatigue, you owe it to yourself to check out Grails.
Peter Ledbrook and Glen Smith are very well known in the community. Their credentials are impeccable. Glen Smith has done a lot of development with Grails and hosts the Grails podcast, Peter works for SpringSource and has contributed to many plugins like JSecurity. The book is packed with knowledge but reads more like a crazed conversation with a deranged guru ( in a good way ) than a tech manual. I highly recommend it.
Oh, DZone, please fix your commenting system. It returns service unavailable whenever it thinks a message is spam.
Jonathan Garay replied on Sat, 2009/08/01 - 12:30pm
pramatr replied on Sun, 2009/08/02 - 3:57am
After tweaking grails default scaffolding, I managed to get a fully functional demo application working in a few hours and managed to clock up several hours of development without a single server restart (this was only cut short by the need to sleep). This was made possible by a feature within Grails known as auto reloading, which confirmed to me, when working with Java I'm sick of restarting my server!
Even though I'm still learning the framework and there is very much I don't know, I'm making real progress which is made evident in the artefacts I've produced. Grails has so far provided a really impressive and effortless development experience. I really love it when you find technology which just seems to work and does exactly what you expect it to do. Lately I really have been having fun with Grails and can't remember the last time I was so productive.
If you don't believe the hype try it out for yourself, it really does just work!
thevery replied on Sun, 2009/08/02 - 6:37pm
srpsco replied on Thu, 2009/09/03 - 11:47pm
phonx replied on Wed, 2009/09/09 - 9:20pm
r_sudh replied on Thu, 2009/09/24 - 8:49pm