Service Oriented Architecture

sweetleafapartInternet and Web Development

Aug 7, 2012 (5 years and 12 days ago)

309 views

95
-
702 OCT

1

Master of Information System
Management

Organizational Communications and
Distributed Object Technologies

Lecture 5: JMS

95
-
702 OCT

2

Master 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 OCT

3

Master 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 OCT

4

Master 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 OCT

5

Master 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 OCT

6

Master 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 OCT

7

Master of Information System
Management

JMS API from Sun’s
Tutorial


Connection Factory




Connection


Message Producer Session Message Consumer


Destination Message Destination

creates

creates


receives from

sends to

creates

creates

95
-
702 OCT

8

Master of Information System
Management

JMS API from Sun’s
Tutorial


Connection Factory




Connection


Message Producer Session Message Consumer


Destination Message Destination

creates

creates


receives from

sends to

creates

creates

Subtypes provide

implementations

for different types

of content.

95
-
702 OCT

9

Master of Information System
Management

JMS API from Sun’s
Tutorial


Connection Factory




Connection


Message Producer Session Message Consumer


Destination Message Destination

creates

creates


receives from

sends to

creates

creates

Attach

MessageListeners

that implement

the onMessage()

method. Or, use

a Message Driven

Bean.

95
-
702 OCT

10

Master of Information System
Management

JMS API from Sun’s
Tutorial


Connection Factory




Connection


Message Producer Session Message Consumer


Destination Message Destination

creates

creates


receives from

sends to

creates

creates

Perform a JNDI lookUp()

for this administrated

object.

QueueConnection

Factory or

TopicConnection

Factory

Perform a JNDI lookUp()

for this administrated

object.

Destination resources may

be Queues or Topics.

95
-
702 OCT

11

Master of Information System
Management

JMS API from Sun’s
Tutorial


Connection Factory




Connection


Message Producer Session Message Consumer


Destination Message Destination

creates



receives from

sends to

creates

creates

A live connection to the

provider.


May be a

QueueConnection or a

TopicConnection

Must be ‘started’

before receiving

messages.

95
-
702 OCT

12

Master of Information System
Management

JMS API from Sun’s
Tutorial


Connection Factory




Connection


Message Producer Session Message Consumer


Destination Message Destination

creates

creates


receives from

sends to

creates

creates

The producer writes.

QueueSender or

TopicPublisher

The consumer

retrieves.

QueueReceiver

TopicSubscriber

95
-
702 OCT

13

Master of Information System
Management

JMS API from Sun’s
Tutorial


Connection Factory




Connection


Message Producer Session Message Consumer


Destination Message Destination

creates

creates


receives from

sends to

creates

creates

A single, serialized flow of messages

between the client and a provider.

This flow may be transacted.

QueueSession or

ToipcSession


95
-
702 OCT

14

Master of Information System
Management

Java Messaging
Architecture (Centralized)

Client

Application

Message

Broker

Client

Application

Client

Application

Client

Application

Client

Application

95
-
702 OCT

15

Master of Information System
Management

Java Messaging
Architecture

Message

Broker

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 acknowledgement

modes.

Connection

95
-
702 OCT

16

Master of Information System
Management

JMS Transaction

Message

Broker

Client

Application

Client

Application

Connections

contain transacted sessions

Begin transaction


send M1


send M2


send M3

commit or rollback

M1 M2 M3

Messages are staged by the broker until the

commit.

After commit the message may be delivered

to other clients.

Upon rollback, the messages are disposed.

95
-
702 OCT

17

Master of Information System
Management

JMS Acknowledgements

Message

Broker

Client

Application

Client

Application

Connections

contain sessions with

acknowledgement modes.

These are low level

acknowldgements, not

associated with replies that

follow requests.

M1

I got it!

95
-
702 OCT

18

Master of Information System
Management

JMS Acknowledgements

Message

Broker

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 OCT

19

Master of Information System
Management

JMS Between
Organizations(1)

JMS

Message

Broker


Client

Application

JMS Bridge



Products exist allowing these two brokers to talk.


This degree of interconnectedness may be inappropriate.



MQSeries

Message

Broker

95
-
702 OCT

20

Master of Information System
Management

JMS Between
Organizations(2)

JMS

Message

Broker


Client

Application

Web Components may act as JMS clients.






Servlet

Client

Application

Browser

Client

HTTP

95
-
702 OCT

21

Master of Information System
Management

JMS Between
Organizations(2)

JMS

Message

Broker


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 Web

client and pass data to the JMS broker.

This is less tightly coupled than connecting two JMS providers

with a bridge.



Web

Service

Client

Application

Web

Client

Using SOAP

HTTP