organizational communications and distributed object technologies
DESCRIPTION
Organizational Communications and Distributed Object Technologies. Lecture 5: JMS. Java Message Service. Introduced by Sun J2EE in 1999 See Chapter 10 of “Java Enterprise in a Nutshell” by Farley, Crawford and Flanagan - PowerPoint PPT PresentationTRANSCRIPT
95-702 OCT1Master of Information System
Management
Organizational Communications and Distributed Object Technologies
Lecture 5: JMS
95-702 OCT2Master of Information System
Management
Java Message Service
• Introduced by Sun J2EE in 1999 • See Chapter 10 of “Java Enterprise in a
Nutshell” by Farley, Crawford and Flanagan
• Web Services, CORBA, and Java RMI use, by default, synchronous communications.
• In the synchronous approach, the client makes a call and waits for a response. This is an example of tight coupling.
• In this respect, JMS promotes loose coupling.
95-702 OCT3Master of Information System
Management
Java Message Service• An API for performing asynchronous messaging.• Uses the provider architecture. • It is an abstraction API like JNDI and JDBC.• Sits on top of Message Oriented Middleware (MOM).• The MOM might be IBM MQ Series, Sonic MQ, Tibco
EMS or Apache’s Active MQ.• Microsoft has a non-JMS MOM called MSMQ.• IBM’s WebSphere Application Server offers a JMS
implementation that is reused by WebSphere ESB. The ESB adds features.
• We’ll be using the provider from Sun that is installed with Netbeans and Glassfish V2.
95-702 OCT4Master of Information System
Management
JMS Communications• Point to point Asynchronous. Similar to email. Guaranteed delivery.• Publish Subscribe Asynchronous. Similar to a bulletin board or newsgroup (one to many). One publishes to a topic and many subscribe to a topic. Guarantees may be configured.
95-702 OCT5Master of Information System
Management
Main Players
• Messaging clients (produce and consume messages)
• Message destinations (to send and receive messages)
• A JMS Message Provider
95-702 OCT6Master of Information System
Management
Where Do The Players Live?
• Typically, JMS would be deployed within an enterprise.
• The enterprise has administrative control over the entire environment.
• It may be a centralized or decentralized deployment.
• In the decentralized case, queuing logic is distributed to clients.
• In the centralized case, queuing logic is centralized (hub and spoke).
• The provider may use TCP/IP, UDP/IP or IP multicasting.
95-702 OCT7Master of Information System
Management
JMS API from Sun’s Tutorial
Connection Factory
Connection
Message Producer Session Message Consumer
Destination Message Destination
creates
creates
receives fromsends to creates
creates
95-702 OCT8Master of Information System
Management
JMS API from Sun’s Tutorial
Connection Factory
Connection
Message Producer Session Message Consumer
Destination Message Destination
creates
creates
receives fromsends to creates
creates
Subtypes provide implementationsfor different types of content.
95-702 OCT9Master of Information System
Management
JMS API from Sun’s Tutorial
Connection Factory
Connection
Message Producer Session Message Consumer
Destination Message Destination
creates
creates
receives fromsends to creates
creates
Attach MessageListenersthat implement the onMessage()method. Or, usea Message DrivenBean.
95-702 OCT10Master of Information System
Management
JMS API from Sun’s Tutorial
Connection Factory
Connection
Message Producer Session Message Consumer
Destination Message Destination
creates
creates
receives fromsends to creates
creates
Perform a JNDI lookUp()for this administratedobject.
QueueConnectionFactory or TopicConnectionFactory
Perform a JNDI lookUp()for this administratedobject.
Destination resources maybe Queues or Topics.
95-702 OCT11Master of Information System
Management
JMS API from Sun’s Tutorial
Connection Factory
Connection
Message Producer Session Message Consumer
Destination Message Destination
creates
receives fromsends to creates
creates
A live connection to theprovider.
May be a QueueConnection or aTopicConnection
Must be ‘started’before receivingmessages.
95-702 OCT12Master of Information System
Management
JMS API from Sun’s Tutorial
Connection Factory
Connection
Message Producer Session Message Consumer
Destination Message Destination
creates
creates
receives fromsends to creates
creates
The producer writes.QueueSender or TopicPublisher
The consumer retrieves.QueueReceiverTopicSubscriber
95-702 OCT13Master of Information System
Management
JMS API from Sun’s Tutorial
Connection Factory
Connection
Message Producer Session Message Consumer
Destination Message Destination
creates
creates
receives fromsends to creates
creates
A single, serialized flow of messagesbetween the client and a provider.This flow may be transacted.
QueueSession orToipcSession
95-702 OCT14Master of Information System
Management
Java Messaging Architecture (Centralized)
Client Application
MessageBroker
Client Application
ClientApplication
Client Application
Client Application
95-702 OCT15Master of Information System
Management
Java Messaging Architecture
MessageBroker
Client Application
Client Application
Broker located through JNDI.Establish a connection through a connection factory.Create sessions from the connection.Sessions have transactional characteristics and acknowledgementmodes.
Connection
95-702 OCT16Master of Information System
Management
JMS Transaction
MessageBroker
Client Application
Client Application
Connectionscontain transacted sessions
Begin transaction send M1 send M2 send M3commit or rollback
M1 M2 M3
Messages are staged by the broker until thecommit.After commit the message may be deliveredto other clients. Upon rollback, the messages are disposed.
95-702 OCT17Master of Information System
Management
JMS Acknowledgements
MessageBroker
Client Application
Client Application
Connectionscontain sessions with acknowledgement modes.These are low level acknowldgements, not associated with replies thatfollow requests.
M1
I got it!
95-702 OCT18Master of Information System
Management
JMS Acknowledgements
MessageBroker
Client Application
Client Application
M1
I got it!
AUTO_ACKNOWLEDGE If a synchronous client receives the message requested it informs the broker automatically. If an asynchronous client receives the message it informs the broker automatically.CLIENT_ACKNOWLEDGEMENT The client program is responsible for sending an acknowledgement to the broker. Call acknowledge() method on the message received.
95-702 OCT19Master of Information System
Management
JMS Between Organizations(1)
JMSMessageBroker
Client Application
JMS Bridge
Products exist allowing these two brokers to talk. This degree of interconnectedness may be inappropriate.
MQSeriesMessageBroker
95-702 OCT20Master of Information System
Management
JMS Between Organizations(2)
JMSMessageBroker
Client Application
Web Components may act as JMS clients.
ServletClient
Application
BrowserClient
HTTP
95-702 OCT21Master of Information System
Management
JMS Between Organizations(2)
JMSMessageBroker
Client Application
Web Components may act as JMS clients.In this case, a web services may expose methods to RPC style clients.Or, the web services may collect an XML document from the Webclient and pass data to the JMS broker.This is less tightly coupled than connecting two JMS providers with a bridge.
Web ServiceClient
Application
WebClient
Using SOAP
HTTP