Java Reference
In-Depth Information
The other type of messaging domain, pub/sub, is facilitated by means of message topics. Publishers address
messages to a specific topic, and subscribers can subscribe to a specific topic to consume messages. Topics differ from
queues because they can contain multiple messages, and the messages can have more than one consumer. Messages
sent to a topic are anonymous, meaning that publishers do not have to address to a specific consumer. Clients that
subscribe to a topic can only consume messages that have been sent to the topic after the subscription time, and
subscribers must remain active in order to continue consuming messages.
JMS Resources
The JMS API utilizes administrative resources in order to create and consume messages. We refer to these resources as
JMS resources. There are a couple of different types of JMS resources that can be created: Connection Resources and
Destination Resources. The Connection resources are used to create connections to a provider. There are three types
of connection resources that can be created:
ConnectionFactory : Instance of javax.jms.ConnectionFactory interface. Can be used to
create JMS Topics and JMS Queue types.
TopicConnectionFactory : Instance of javax.jms.TopicConnectionFactory interface
QueueConnectionFactory : Instance of javax.jms.QueueConnectionFactory interface
JMS connection factory resources are very similar to JDBC connection factories in that they provide a pool of
connections that an application can use in order to connect and produce a session. There are many attributes that can
be provided when creating connection factory resources:
Initial and Minimum Pool Size : The initial and minimum number of connections that will
be created and maintained by the connection pool.
Maximum Pool Size : The maximum number of connections that can be created within the
Pool Resize Quantity : The number of connections that will be removed when the pool idle
timeout expires.
Idle Timeout : The maximum amount of time that connections can remain in the pool if
they are idle. (Seconds)
Max Wait Time : The maximum amount of time that a caller will wait before a connection
timeout is sent. (Milliseconds)
On Any Failure : If set to true (checked), all connections will be closed and reconnected on
Transaction Support : The level of transaction support ( XATransaction ,
LocalTransaction , NoTransaction . The default is empty.
Connection Validation : If set to true, then connections will need to be validated.
Connection factory and destination resources are created and reside within an application server container.
They can be created using an IDE, such as Netbeans, or by using the application server administrative tools. The
most important piece of information to provide when creating a destination is the name. As with any JMS resource,
the JNDI name should begin with the jms/ prefix. When creating a destination resource, a unique name must also
be provided for the Destination Resource Name, although other Java EE application servers may or may not make this
a mandatory specification.
Search WWH ::

Custom Search