SQL Server 2005 Service Broker by Roger Wolter


SQL Server 2005 Service Broker

  • Author: Roger Wolter
  • Softcover: 224 pages
  • Publisher: Rational Press (Jul 15 2005 12:00AM)
  • Book dimensions: 8.7 x 6.1 x 0.5 inches
  • ISBN: 1932577203
  • ITBookworm score: 4.0 /5

Score Reasoning

There are a couple things that kept this book from getting 5 stars. First, there’s no index. I really think that all books should give you a way to look up specific information and not make you search through the chapters to find what you’re looking for. I also really wish it would have gone into more detail on how to implement the code inside your applications. A sample application to learn from would have really been helpful. The last complaint I have is the writing style. This is just such a boring book. When trying to learn something new, it helps to relate to your book at all, and maybe even get some nice anecdotal stories or examples to help illustrate the point. If you’re not concerned with that kind of thing, then you’ll love the straight forward approach given.

Synopsis

This is a good book for getting started with Service Broker, and maybe even a little beyond. It’s short and to the point. There are plenty of examples given to illustrate the points given, and frankly, some of the examples are detailed enough you could probably just nick the code for your own applications and save yourself a lot of headache. I think it might be a bit out of order in its discussion of the topics sometimes, but when all is said and done you will probably know Service Broker pretty well. It makes absolutely no attempt to entertain you or even give you much practical advice on how to embed the code in your applications. There are times I wish it would go into further detail, but I’m clearly not the intended audience for this book. There are some practical applications and advice given on how to architect these solutions in your application framework. The one thing I question though is how much of this is found in BOL to begin with. I know for a fact that the syntax for all the commands is given in BOL, but I don’t know how much of the practical advice is given. My advice… even though this is a thorough book with good examples, start with BOL, then if there’s something you don’t understand, or you need just a little more hand-holding to get you through some of the thicker code, then you can try this book.

Who is this book really for?

This book is clearly for the professional developer or DBA. It doesn’t attempt to teach T-SQL at all, which is good. It’s highly specialized and doesn’t vire from its task even for a second. In that respect, it’s worth every dime you pay for it. If you’re not even a moderately experience developer, and more importantly, not experienced with writing (or at least trying to write) messaging applications, then this book will probably be a bit over your head. You’re clearly already supposed to know how to embed the code inside your applications and how to implement the nuances and put the pieces together. However, if you’re under the gun and you absolutely have to get up and running on Service Broker and you simply don’t have the experience to pull it off, then this book is pretty much your only resource at this point. It’s the closest thing to a beginner book you’ll find. I would read it in conjunction with BOL, and maybe even start with BOL to see how well you understand those concepts before you shell out the money here.

Writing Style

I really can’t say enough about the writing style of this book. Unfortunately, that’s not a good thing in this case. I really don’t think I’ve been this bored since my mom was explaining to me why they were only planting 2 rows of brussel sprouts this year (true store, 20 mins of soil conditions, bad backs, and lousy weather… kill me). This book reads much like the dictionary or the encyclopedia. Still, if I wanted to know about Service Broker this is probably where I’d start.

Condition

Another excellent book. This book is tough and held up to all the abuse I threw at it. My 9 mo. old son actually got a hold of this one, and aside from being slightly more gooey on one corner it held up nicely. He twisted it, bent it, threw it, and even ripped at the spine. I’m pleased with the quality of the binding and how well the pages dried out when he was finished with it.

Table of Contents

Chapter 1: What is Service Broker?

Here we start off with a quick example of an application that would use Service Broker. It’s really very quick, so don’t expect to get the full picture here… but it’ll work itself out soon enough in the rest of the book. Next we get into some very very basic architecture. Then, there’s a decent discussion of the advantages it can bring to your applications. Now you see a quick example. There’s code given that you can test out as well. It’s a basic example, but this is just the beginning. I personally think it’s too early for code, but whatever.

Chapter 2: Conversations

With conversations being the core of Service Broker, this is an important chapter to understand. It starts out just discussing the concepts of conversations like delivery, message ordering, error handling, persistence, etc. There are some admin points sprinkled throughout like the sys tables to query to find endpoints, etc. Finally, there’s an example of a BEGIN CONVERSATION statement and some brief discussion around it. Overall, it’s not a bad chapter, but it still isn’t really attempting to teach you how to program Service Broker.

Chapter 3: Conversation Groups

Here we start out talking about the need for groups and what problems they solve. That’s just a quick intro and then you get right into conversation group locking. Again, there are some admin nuggets thrown in there while it discusses the architecture. So far, this is the best chapter simply because the explanations are much clearer and there’s more relevant detail gone into. It ends with a quick discussion with advice on choosing effective groups.

Chapter 4: Queues

One of the features of Service Broker that makes it so rich is its use of queues for asynchronous messaging. As the title says, this chapter explores queues. It first talks about what queues are, and how their integrity is maintained. You then quickly get into how to work with queues including creating, enabling, and disabling them. The syntax for creating a queue is given as well. Next you get into how to examine queues for their contents and status. It’s a pretty short chapter though. No frills, it just gets right to the point then moves on.

Chapter 5: Service Broker Metadata

You start out here talking about naming conventions that will help you differentiate Service Broker objects. Message types are gone into next, along with contracts and services. Each of these sections is very short and doesn’t really go into a lot of explanation. They’re basically just defined and a little code given and that’s about it. It finishes up with some basic queries for getting metadata out of your Service Broker DB.

Chapter 6: Service Broker Programming Basics

This is the first chapter that actually shows you how to program something useful. It’s pretty long (esp. compared to some of the others). It starts out talking about the SEND and RECEIVE commands. The basic syntax is given for each one just to get your feet wet. It then goes into the specific parts of the commands like WAITFOR, TIMEOUT, TOP, and WHERE. It actually covers WHERE in some detail… I guess that makes it really important. It then discusses key words and their usage, and message body limitations and how to get around them if you need to. Next, there’s quite a bit of time given to transactions. A really nice explanation on how they’re used, when they’re rolled back etc is given. Now you get into a pretty sizeable section on receive loops. A very extensively coded example is given to illustrate the point. Error handling and conversation timers are handled next. There’s not a lot of time devoted to them, but enough to get the point across.

Chapter 7: State Handling

Here we start out talking about what state is, and the need for handling this information. It quickly gets into using the Conversation Group ID as the state key and using this to retrieve the state in a single trip. It finishes with a good deal of code demonstrating state retrieval. There’s not much else to say. It’s a very short chapter that gets down to business and doesn’t mince words doing it.

Chapter 8: Poison Message Handling

Again, we start out with a brief discussion on what poison messages are. Then, the discussion turns to your first line of protection, defensive coding. It basically just says rollback if you need to, and it’s always a good idea to code carefully (ya think?). Next, it discusses what it calls last resort protection. What’s happening here is Service Broker disables the queue automatically after 5 rollbacks in a row. It then raises an event that you can capture and do with what you like. It then discusses how Service Broker actually handles poison messages and gives you some demo code to see this behavior, including forcing the creation of a poison message so you can test it yourself. Overall, I’d say it’s a good chapter and well worth your time if you need to deal with this topic.

Chapter 9: Activation

Of course, it starts out talking about what activation is, and why you need it. It then goes into how to configure activation and gives you the syntax and discusses all of the parameters. External activation is discussed next. External activation differs from regular activation in that it takes place outside of SQL. See, normal activation is used from within an SP, but it happens from time to time when you’ve got the queue reader configured as a Windows service and you need a way to activate your queue from outside of SQL. The process for external activation isn’t straight forward since Service Broker doesn’t have an external activator, so if you have this need, you’d be wise to read this section.

Chapter 10: Service Broker Communications

Here you start out with a good discussion on creating endpoints. You of course get the code to create and query for endpoints. Next, broker protocols are give just a little time. Since it seems to be fairly irrelevant to coding Service Broker application, and so little information is given on the protocols themselves, this section seems to be simply for information only. This next section on sending a message is quite interesting. It basically follows a message from being sent from one machine to being received by another. It’s a nice high-level view of how the entire process works, and it even shows you some management tips along the way like querying the sys.routes table. You can actually create your own message routes in Service Broker, and this next section discusses that. It begins with a discussion on routing messages and how and why it’s done and then gets into the code for creating these routes. After a thorough discussion on the routing syntax, a sizeable routing example is given in code. Next, routing and mirroring are discussed with forwarding, as well as using Service Broker in SQL Express.

Chapter 11: Security

Ahh, security… the new buzzword of the compliance age. I have nothing against security itself, it just tends to get canonized to the point of being the only consideration in a process. I think this book handles security in a responsible manner. This is a sizeable chapter so security is definitely discussed fully. It discusses certificates and endpoint security as well as Service Broker specific security. Of course, there’s also a bit of code along the way to demonstrate how to accomplish your goals. There’s also a good discussion on dialog security, so you can see it gets pretty granular. Finally, it goes into when to use and not use security which I think is a discussion greatly missed in most books. It’s like being at the brake shop. The mechanics there have a way of making it sound like you’re going to die at the next stop light if you don’t spend the $200 right this second. This chapter puts security into its proper place and doesn’t over inflate its importance. It doesn’t minimize it either, but it does discuss it thoroughly though.

Chapter 12: Advantages of Service Broker

This is the first chapter in the Advanced Topics section of the book. This chapter is kinda long compared to many of the other ones, but it’s worth it if you have a large implementation. This is where you’ll learn about loose coupling, scalability, etc. A lot of time is given to scaling out Service Broker and Applications that use it. Most of it is conceptual though so don’t expect any solid code that will do your job for you. This is for those of you who know what you’re doing and just need some guidance on architecting your environment properly. Performance is discussed next. You start out with a lengthy discussion on parallel SPs and this time there’s plenty of code to go through. You finish up with transactional messaging and when Service Broker is the proper choice for your application.

Chapter 13: Reliable Service-Oriented Architecture

This is another mostly conceptual chapter, but nonetheless, a good one. Fault-tolerant SOA, reliable clients, services, etc is discussed. There is some good example code given, and it’s actually quite plentiful.

Chapter 14: Scheduling with Service Broker

This chapter is just what it sounds like and starts out talking about how to use activation and conversations to start jobs. It then moves into scheduling with conversation timers. This chapter has tons of example code for you to go through, and in fact, I would even go so far as to say that the code does most of the important talking here.

-Sean McCown, ITBookworm.com

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *

*