12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Error Recovery<br />

Error Recovery<br />

That said, it is possible to deploy MDBs in more than one Partition with the Messaging<br />

Server pushing messages to only one, switching to the other in case of failure. Most<br />

JMS products allow queues to behave in load-balancing or fault-tolerant modes. That<br />

is, MDB replicas can register to the same queue and the messages are distributed to<br />

them using a load-balancing algorithm. Alternately, messages may all go to one<br />

consumer until it fails, at which point delivery shifts to another. The connection<br />

established to the JMS service provider from the MDB can also provide a loadbalancing<br />

and/or fault-tolerant node. JMS service providers may provide fault-tolerance<br />

features. For specific information on clustering and fault tolerance features, refer to<br />

JMS Provider Pluggability.<br />

Keep in mind that only one MDB instance in a container that subscribes to a topic will<br />

consume any given message. This means that, for all parallel instances of an MDB to<br />

concurrently process messages, only one of the instances will actually receive any<br />

particular message. This frees up the other instances to process other messages that<br />

have been sent to the topic. Note that each container that binds to a particular topic will<br />

consume a message sent to that topic. The JMS subsystem will treat each messagedriven<br />

bean in separate containers as a separate subscriber to that message! This<br />

means that if the same MDB is deployed to many containers in a cluster, then each<br />

deployment of the bean will consume a message from the topic to which it subscribes.<br />

If this is not the behavior you desire, and you require exactly one consumption of a<br />

message, then you should consider deploying a queue rather than a topic.<br />

The following section deals with JMS <strong>server</strong> connection failures and setting connection<br />

rebind attempt properties. It also covers the redelivery of messages to the JMS service<br />

when an MDB fails to consume a message. The section on redelivery covers setting<br />

the redeliver attempt property as well as two properties for delivering messages to a<br />

dead queue.<br />

Rebinding<br />

A connection failure usually occurs after you deploy your bean, causing a need for<br />

rebind attempt. You also receive an error if you are trying to deploy your bean and a<br />

connection to the JMS <strong>server</strong> was never established. Whether a failure occurs post<br />

deployment or no connection was found during deployment, the container will<br />

transparently attempt to rebind the JMS service provider connection when you set the<br />

rebind attempt properties. This ensures even greater fault-tolerance from an MDB<br />

instance.<br />

The two bean-level properties that control the number of rebind attempts made and the<br />

time interval between attempts are:<br />

■<br />

■<br />

ejb.mdb.rebindAttemptCount: this is the number of times the EJB Container tries to<br />

re-establish a failed JMS connection for this MDB. The default value is 5 (five).<br />

To make the container attempt to rebind infinitely you need to explicitly specify<br />

ejb.mdb.rebindAttemptCount=0.<br />

ejb.mdb.rebindAttemptInterval: the time in seconds between successive retry<br />

attempts. The default value is 60.<br />

Chapter 20: Message-Driven Beans and JMS 187

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

Saved successfully!

Ooh no, something went wrong!