23.07.2013 Views

O'Reilly - Java Message Service

O'Reilly - Java Message Service

O'Reilly - Java Message Service

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />

only really viable for DUPS_OK_ACKNOWLEDGE. No matter what, a messaging vendor has to<br />

implement the reliability necessary to ensure guaranteed ordering, since UDP doesn't<br />

ensure that packets are received in the same order that they are sent.<br />

A messaging vendor should support some sort of error detection to know when a UDP<br />

datagram is lost. Ideally it should know that a client can't be reached due to a network<br />

boundary across an unsupported network router (see Section 7.2.4.3 later in this chapter).<br />

The JMS specification allows for a nondurable JMS subscriber to miss messages, but is<br />

intentionally vague about this since it is not a goal of the specification to impose an<br />

architecture on a JMS provider. However, for all practical purposes, nonguaranteed<br />

messaging means that messages may be lost, and that should mean they may only be lost<br />

once in a while. For both cases, some sort of acknowledgment semantics are required.<br />

7.2.4.2 Centralized and decentralized architectures<br />

A TCP-based messaging system generally uses a hub-and-spoke architecture whereby a<br />

centralized message server, or cluster of message servers, communicates with JMS clients<br />

using TCP/IP, SSL, or HTTP connections. The centralized server is responsible for<br />

knowing who is publishing and who is subscribing at any given time. <strong>Message</strong> servers may<br />

operate in a cluster spread across multiple machines, but to the clients there only appears<br />

to be a single logical server. <strong>Message</strong> servers operating in a cluster can intelligently route<br />

messages to other servers. Clustering may provide load balancing, and may help to<br />

optimize network traffic by selectively filtering and routing only the messages that need to<br />

get to a particular node. The servers are also responsible for persistence of guaranteed<br />

messages, and for Access Control Lists (ACLs) that grant permissions to subscribers on a<br />

per-topic basis. The messages are only delivered to the subscribers that are interested in a<br />

particular topic, and only to those that have the permissions to get them. A centralized<br />

server also makes it easier to add subscribers: when a new subscriber comes online; only<br />

the message server needs to know about it.<br />

At the same time, a centralized architecture may introduce a single point of failure: if the<br />

main server in a cluster (the server to which clients initially connect) goes down, the entire<br />

cluster may become unavailable. A JMS provider may solve this problem by distributing<br />

the connections across multiple servers in the cluster. If one server goes down, the other<br />

servers can continue to operate, thus minimizing the impact of the failure. Reconnect logic<br />

may also be built into the client, enabling it to find another server if its initial server goes<br />

down.<br />

Multicasting implies a drastically different architecture, in which there usually is no<br />

centralized server. Because there is no central server, there is no single point of failure;<br />

each JMS client broadcasts directly to all other JMS clients. One consequence of this<br />

architecture is that every publisher and every subscriber may have local configuration<br />

information about every other JMS client on the system. This can be an extremely<br />

important consideration for deployment administration. In the absence of a higher-level<br />

administrative framework, local configurations have to be updated on every client<br />

whenever a new client or a new topic is added.<br />

114

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!