Book Giveaway: Grails In Action Exclusive Chapter Download

DZone 's Guide to

Book Giveaway: Grails In Action Exclusive Chapter Download

· Java Zone ·
Free Resource

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.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}