34
EEC-681/781 EEC-681/781 Distributed Computing Distributed Computing Systems Systems Lecture 6 Lecture 6 Wenbing Zhao Wenbing Zhao Department of Electrical and Computer Department of Electrical and Computer Engineering Engineering Cleveland State University Cleveland State University [email protected] [email protected]

EEC-681/781 Distributed Computing Systems

Embed Size (px)

DESCRIPTION

EEC-681/781 Distributed Computing Systems. Lecture 6 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University [email protected]. Message-Oriented Communication. Persistence and Synchronicity in Communication Message-oriented transient communication - PowerPoint PPT Presentation

Citation preview

Page 1: EEC-681/781 Distributed Computing Systems

EEC-681/781EEC-681/781Distributed Computing Distributed Computing

SystemsSystems

Lecture 6Lecture 6

Wenbing ZhaoWenbing ZhaoDepartment of Electrical and Computer EngineeringDepartment of Electrical and Computer Engineering

Cleveland State UniversityCleveland State University

[email protected]@ieee.org

Page 2: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

22

Message-Oriented CommunicationMessage-Oriented Communication

• Persistence and Synchronicity in Communication• Message-oriented transient communication

– Berkeley sockets– Message-passing interface

• Message-oriented persistent communication– Message-queuing system– Message brokers (publish/subscribe)

• Java message service– A copy of JMS tutorial is available at DCS server

/software/activemq/jms-tutorial.pdf

Page 3: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

33

Synchronous CommunicationSynchronous Communication

• Client/Server computing is generally based on a model of synchronous communication:– Client and server have to be active at the time of

communication– Client issues request and blocks until it receives

reply– Server essentially waits only for incoming

requests, and subsequently processes them

Page 4: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

44

Synchronous CommunicationSynchronous Communication

• Drawbacks of synchronous communication:– Client cannot do any other work while waiting

for reply– Failures have to be dealt with immediately (the

client is waiting)– In many cases the model is simply not

appropriate (mail, news)

Page 5: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

55

Asynchronous CommunicationAsynchronous Communication

• Message-oriented middleware: Aims at high-level asynchronous communication:– Processes send each other messages, which

are queued– Sender need not wait for immediate reply, but

can do other things– Middleware often facilitates fault tolerance

Page 6: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

66

Persistent CommunicationPersistent Communication• Persistent Communication – A message that

has been submitted for transmission is stored by the communication system as long as it takes to deliver it to the receiver– E.g. from postal mail to e-mail

Page 7: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

77

Transient CommunicationTransient Communication

• Transient Communication – A message is stored by the communication system only as long as the sending and receiving application are executing– All transport-level communication services

offer only transient communication– RPC/RMI

Page 8: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

88

Message-Oriented Message-Oriented Transient CommunicationTransient Communication

• Berkeley Sockets

• Message-Passing Interface

Page 9: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

99

Berkeley SocketsBerkeley Sockets

Primitive Meaning

Socket Create a new communication endpoint

Bind Attach a local address to a socket

Listen Announce willingness to accept connections

Accept Block caller until a connection request arrives

Connect Actively attempt to establish a connection

Send Send some data over the connection

Receive Receive some data over the connection

Close Release the connection

Page 10: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1010

Berkeley SocketsBerkeley Sockets

Connection-oriented communication pattern using sockets

Page 11: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1111

The Message-Passing Interface (MPI)The Message-Passing Interface (MPI)

• MPI is used to do high performance computing on multicomputers – Use high-speed interconnection networks– Come with proprietary communication

libraries

• Need message-passing primitives at a convenient level of abstraction– Standard APIs, hardware-independent

Page 12: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1212

Message-Oriented Message-Oriented Persistent CommunicationPersistent Communication

Message-Oriented

Middleware

Application A

Messaging API

Messaging Clients

Application B

Messaging API

Messaging Clients

Message-Oriented Middleware (MOM)

Page 13: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1313

Characteristics of MOMCharacteristics of MOM

• Loosely-coupled communication: They offer intermediate storage capacity for messages, without requiring either sender or receiver to be active during message transmission

• Encompasses publish/subscribe and message queuing communications

Sender Receiver

MOM

Messages

Page 14: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1414

Message QueuingMessage Queuing

Producer Queue Consumer

send(m1)

send(m2)

receive()m1

Put message into queue

Consume message

A message queue offers point-to-point communication: each message produced has one consumer

Page 15: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1515

Publish/SubscribePublish/Subscribe

Producer Broker Consumer Consumer

publish(m1)send(m1)Pass message to

brokersend(m1)

send(m2)

send(m2)

Dispatch message to all consumers

publish(m2)

publish(m3)

Publish/subscribe offers one-to-many communication: each message published can have many subscribers

Page 16: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1616

Message Queuing ApplicationMessage Queuing Application

Page 17: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1717

Publish/Subscribe ApplicationPublish/Subscribe Application

subscribe (“EEC681”);subscribe (“EEC681”);subscribe (“EEC693”);

subscribe (“EEC681”);subscribe (“EEC693”);

publish(“EEC681”, Lab1);publish(“EEC681”, Lab2);

publish(“EEC693”, HW1);publish(“EEC693”, HW2);

Page 18: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1818General Architecture of General Architecture of Message-Queuing SystemMessage-Queuing System

• Message queueing API provides a higher abstraction to application developers

• Queue-level addressing is translated to transport-level addressing in MOM

Page 19: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

1919General Architecture of General Architecture of Message-Queuing SystemMessage-Queuing System

• A message can be handled by a centralized message server, or routed by multiple queue managers– Scalability– Secondary

processing of messages, e.g., logging, bridging

Page 20: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2020

Java Message ServiceJava Message Service

• Standard Java API

• Message delivery models

• Two messaging models

• Transactions

• Reliability levels

• Persistent messaging

Page 21: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2121

JMS Messaging DomainsJMS Messaging Domains

• Publish and subscribe (topic)– Many consumers per message

• Point-to-point (queue)– One consumer per message

Page 22: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2222

JMS ComponentsJMS Components

Message Server

Message MessageDestination

JMS Client

Connection

Session

Producer

JMS Client

Connection

Session

Consumer

Page 23: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2323

Connections and SessionsConnections and Sessions

• A connection connects to a message server

• You can create one or more sessions within a connection

JMS Client

Connection

Session

Session

Session

Page 24: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2424

Creating Connections and Creating Connections and SessionsSessions

Message Server

JNDI Store

JMS Client

Connection

Session

Session

Session

ConnectionFactory

create

ConnectionFactoriesDestinations

Page 25: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2525

JMS Message TypesJMS Message Types

Message type Message body

Message No body

TextMessage A standard Java string

ObjectMessage A serializable Java object

MapMessageA set of name/value pairs where values are Java primitives

StreamMessage A stream of Java primitives

BytesMessage A stream of uninterpreted bytes

Page 26: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2626

Creating a MessageCreating a Message

createStreamMessage( )

StreamMessage

TopicSession

createTextMessage( )

TextMessage

QueueSession

Page 27: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2727

JMS Message HeadersJMS Message Headers

• Automatically assigned headers– JMSDestination– JMSDeliveryMode– JMSMessageID– JMSTimestamp– JMSExpiration– JMSRedelivered– JMSPriority

• Developer-assigned headers– JMSReplyTo– JMSCorrelationID– JMSType

Page 28: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2828

Producers, Consumers, and Producers, Consumers, and DestinationsDestinations

Message ServerSend

messageConsumemessage

Destination

Producer

Bind todestination

Consumer

Read message

Bind todestination

Page 29: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

2929

Creating DestinationsCreating Destinations

Message Server

JNDI StoreJMS Client

Topic

Queue

ConnectionFactoriesDestinations lookup

Page 30: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

3030

Producing a MessageProducing a Message

create message

produce message

Session

MessageProducer

Message Destinationcreate

Page 31: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

3131

Consuming MessagesConsuming MessagesIncoming messages

MessageListener

onMessage(message)

Message Server

acknowledge

MessageConsumer

Message receive()

Incoming messages

acknowledge

Asynchronous Message Delivery

Synchronous Message Delivery

Page 32: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

3232

Filtering with Message SelectorFiltering with Message Selector

Message Server

Publisher

Departments.Sales

SubscriberDepartments.SalesPipeline > 15000

JMSPriority = 2Pipeline = 20000

delivered

SubscriberDepartments.SalesJMSPriority > 5

not delivered

SubscriberDepartments.SalesJMSPriority >= 2 AND Pipeline > 10000

delivered

SubscriberDepartments.SalesPipeline > 20000

notdelivered

Page 33: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

3333

Browsing a QueueBrowsing a Queue

nextElement()

QueueBrowser

getEnumeration()

Message1

Message2

Message3

Message4

Enumeration

Page 34: EEC-681/781 Distributed Computing Systems

Fall Semester 2006Fall Semester 2006 EEC-681: Distributed Computing SystemsEEC-681: Distributed Computing Systems Wenbing ZhaoWenbing Zhao

3434

Accessing Message ContentAccessing Message Content

Message

TextMessageMapMessage ObjectMessage StreamMessage BytesMessage

getText() getObject()

get<type>(Name)

read<type>()