web server - Borland Technical Publications

web server - Borland Technical Publications web server - Borland Technical Publications

techpubs.borland.com
from techpubs.borland.com More from this publisher
12.11.2014 Views

Naming Support and Configuration Naming Support and Configuration Since MDBs have no interfaces, MDBs do not have JNDI names in the normal sense like EJBHome objects do. Instead, they are associated with two objects that must preexist in JNDI before the MDB is deployed. These are: ■ a connection factory to use for connecting to the JMS services provider and ■ a queue/topic on that provider to listen to for incoming messages The JNDI names for these objects are specified in the MDB's ejb-borland.xml deployment descriptor. The captures the resource connection factory used to connect to the JMS service provider. The element captures the actual topic/queue on which the MDB is to listen. Once these elements are specified, the MDB has all the information it needs to connect to the JMS service provider, receive messages, and send replies. Connecting to JMS Connection Factories from MDBs MDBs provide a special case for connecting to JMS connection factories. In ejbjar.xml, attaching a JMS resource to an MDB requires the entry in the MDB's declaration. For example: MyMDBTopic ... javax.jms.Topic Durable ... Consult the J2EE 1.3 Specification for the proper uses of this element. Again, the Borland-specific XML file binds the logical name with the JNDI name. It uses two elements to accomplish this: and . First, let's examine the element from the ejb-borland.xml DTD: It's hardly a complicated element. Its value is the JNDI name of the JMS topic or queue connection factory. That is, it is identical to the element found within the declaration we just discussed. So, the ejb-borland.xml declaration for an MDB looks like this: MyMDBTopic ... serial://resources/tcf Now, we need to specify the JNDI name of the individual queue or topic. This is done with the element. Let's have a look at its DTD entry. Chapter 20: Message-Driven Beans and JMS 185

Clustering of MDBs This is yet another simple element. It's value is essentially identical to the value of the element found within the declaration discussed above. Now our XML looks like the following: MyMDBTopic ... serial://resources/tcf serial://resources/tcf ... Note Once deployed, you can access datasources from the MDB MyMDBTopic. The connection factory objects are much like JDBC datasources and the names of topics and queues are similar to specifying a database table name. The connection factory objects themselves are typed, for example TopicConnectionFactory and QueueConnectionFactory, depending upon what you are listening for. Furthermore, each of subtype of XA flavor is are needed when global transactions are in effect. In the typical development environment, there is only one JMS service provider, so only a pair of connection factories are required: one for topics and one for queues. Go to Chapter 23, “Using JMS” for detailed information on configuring these. You must use an XA connection factory when the MDB is deployed with the REQUIRED transaction attribute. The whole idea of this deployment is to enable the consumption of the message that drives the MDB to share the same transaction as any other work that is done from within the MDB.onMessage() method. To achieve this the container performs XA coordination with the JMS service provider and any other resources enlisted in the transaction. Clustering of MDBs The clustering of MDBs differs from the clustering of other enterprise beans. With MDBs, producers put messages into a destination. The messages will reside in the destination until a consumer takes the messages off the destination (or, if the messages are non-durable, when the server hosting the destination crashes). This is a pull model since the message will just reside on the destination until a consumer asks for it. The containers contend to get the next available message on the destination. MDBs provide an ideal load-balancing paradigm, one that is smoother than other enterprise bean implementations for distributing a load. The server that is the least burdened can ask for and obtain the message. The trade-off for this optimal loadbalancing is that messaging has extra container overhead by virtue of the destination's position between the producer and the consumer. There is not, however, the same concept of failover with a messaging service as exists in VisiBroker. If the consumer disappears, the queue fills up with messages. As soon as the consumer is brought back online, the messages resume being consumed. Of course, the JMS server itself should be fault-tolerant. The client should never notice any “failure” with the exception of response delays if such messages are expected. This kind of fault tolerance demands only a way of detecting failed consumers and activating them after failure. If you have the Borland Deployment Operations System (BDOC) installed and running, it will automatically maintain the desired state of its clustered services under active management. 186 BES Developer’s Guide

Clustering of MDBs<br />

This is yet another simple element. It's value is essentially identical to the value of the<br />

element found within the declaration discussed above.<br />

Now our XML looks like the following:<br />

<br />

MyMDBTopic<br />

...<br />

serial://resources/tcf<br />

serial://resources/tcf<br />

...<br />

Note<br />

<br />

Once deployed, you can access datasources from the MDB MyMDBTopic.<br />

The connection factory objects are much like JDBC datasources and the names of<br />

topics and queues are similar to specifying a database table name. The connection<br />

factory objects themselves are typed, for example TopicConnectionFactory and<br />

QueueConnectionFactory, depending upon what you are listening for. Furthermore, each<br />

of subtype of XA flavor is are needed when global transactions are in effect. In the<br />

typical development environment, there is only one JMS service provider, so only a<br />

pair of connection factories are required: one for topics and one for queues. Go to<br />

Chapter 23, “Using JMS” for detailed information on configuring these.<br />

You must use an XA connection factory when the MDB is deployed with the REQUIRED<br />

transaction attribute. The whole idea of this deployment is to enable the consumption<br />

of the message that drives the MDB to share the same transaction as any other work<br />

that is done from within the MDB.onMessage() method. To achieve this the container<br />

performs XA coordination with the JMS service provider and any other resources<br />

enlisted in the transaction.<br />

Clustering of MDBs<br />

The clustering of MDBs differs from the clustering of other enterprise beans. With<br />

MDBs, producers put messages into a destination. The messages will reside in the<br />

destination until a consumer takes the messages off the destination (or, if the<br />

messages are non-durable, when the <strong>server</strong> hosting the destination crashes). This is a<br />

pull model since the message will just reside on the destination until a consumer asks<br />

for it. The containers contend to get the next available message on the destination.<br />

MDBs provide an ideal load-balancing paradigm, one that is smoother than other<br />

enterprise bean implementations for distributing a load. The <strong>server</strong> that is the least<br />

burdened can ask for and obtain the message. The trade-off for this optimal loadbalancing<br />

is that messaging has extra container overhead by virtue of the destination's<br />

position between the producer and the consumer.<br />

There is not, however, the same concept of failover with a messaging service as exists<br />

in VisiBroker. If the consumer disappears, the queue fills up with messages. As soon<br />

as the consumer is brought back online, the messages resume being consumed. Of<br />

course, the JMS <strong>server</strong> itself should be fault-tolerant. The client should never notice<br />

any “failure” with the exception of response delays if such messages are expected.<br />

This kind of fault tolerance demands only a way of detecting failed consumers and<br />

activating them after failure. If you have the <strong>Borland</strong> Deployment Operations System<br />

(BDOC) installed and running, it will automatically maintain the desired state of its<br />

clustered services under active management.<br />

186 BES Developer’s Guide

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

Saved successfully!

Ooh no, something went wrong!