320 likes | 447 Views
EEC-681/781 Distributed Computing Systems. Lecture 6 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University wenbing@ieee.org. Message-Oriented Communication. Persistence and Synchronicity in Communication Message-oriented transient communication
E N D
EEC-681/781Distributed Computing Systems Lecture 6 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University wenbing@ieee.org
Message-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 EEC-681: Distributed Computing Systems
Synchronous 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 EEC-681: Distributed Computing Systems
Synchronous 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) EEC-681: Distributed Computing Systems
Asynchronous 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 EEC-681: Distributed Computing Systems
Persistent 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 EEC-681: Distributed Computing Systems
Transient Communication • TransientCommunication – 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 EEC-681: Distributed Computing Systems
Message-Oriented Transient Communication • Berkeley Sockets • Message-Passing Interface EEC-681: Distributed Computing Systems
Berkeley Sockets EEC-681: Distributed Computing Systems
Berkeley Sockets Connection-oriented communication pattern using sockets EEC-681: Distributed Computing Systems
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 EEC-681: Distributed Computing Systems
Application A Application B Message-Oriented Middleware Messaging API Messaging API Messaging Clients Messaging Clients Message-Oriented Persistent Communication Message-Oriented Middleware (MOM) EEC-681: Distributed Computing Systems
Receiver Sender MOM Messages Characteristics 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 message queuingand publish/subscribe communications EEC-681: Distributed Computing Systems
Producer Queue Consumer send(m1) send(m2) receive() m1 Message Queuing Put message into queue Consume message A message queue offers point-to-point communication: each message produced has one consumer EEC-681: Distributed Computing Systems
Producer Consumer Consumer Publish/Subscribe Broker publish(m1) Pass message to broker send(m1) publish(m2) send(m1) Dispatch message to all consumers send(m2) send(m2) publish(m3) Publish/subscribe offers one-to-many communication: each message published can have many subscribers EEC-681: Distributed Computing Systems
Message Queuing Application EEC-681: Distributed Computing Systems
Publish/Subscribe Application publish(“EEC693”, HW1); publish(“EEC693”, HW2); publish(“EEC681”, Lab1); publish(“EEC681”, Lab2); subscribe (“EEC681”); subscribe (“EEC693”); subscribe (“EEC681”); subscribe (“EEC693”); subscribe (“EEC681”); EEC-681: Distributed Computing Systems
Java Message Service • Standard Java API • Message delivery models • Two messaging models EEC-681: Distributed Computing Systems
JMS Messaging Domains • Publish and subscribe (topic) • Many consumers per message • Point-to-point (queue) • One consumer per message EEC-681: Distributed Computing Systems
JMS Components JMS Client JMS Client Connection Connection Session Session Producer Consumer Message Server Destination Message Message EEC-681: Distributed Computing Systems
Connections 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 EEC-681: Distributed Computing Systems
Creating Connections and Sessions JMS Client ConnectionFactory create JNDI Store Message Server Connection ConnectionFactories Destinations Session Session Session EEC-681: Distributed Computing Systems
JMS Message Types EEC-681: Distributed Computing Systems
TopicSession QueueSession createStreamMessage( ) createTextMessage( ) TextMessage StreamMessage Creating a Message EEC-681: Distributed Computing Systems
Automatically assigned headers JMSDestination JMSDeliveryMode JMSMessageID JMSTimestamp JMSExpiration JMSRedelivered JMSPriority Developer-assigned headers JMSReplyTo JMSCorrelationID JMSType JMS Message Headers EEC-681: Distributed Computing Systems
Producers, Consumers, and Destinations Producer Consumer Bind to destination Bind to destination Read message Message Server Send message Consume message Destination EEC-681: Distributed Computing Systems
Creating Destinations JMS Client JNDI Store Message Server Topic ConnectionFactories Destinations lookup Queue EEC-681: Distributed Computing Systems
Producing a Message create message Session create Message Destination MessageProducer produce message EEC-681: Distributed Computing Systems
MessageListener onMessage(message) MessageConsumer Message receive() Consuming Messages Incoming messages Asynchronous Message Delivery acknowledge Message Server Incoming messages acknowledge Synchronous Message Delivery EEC-681: Distributed Computing Systems
Filtering with Message Selector Publisher Departments.Sales JMSPriority = 2 Pipeline = 20000 not delivered Subscriber delivered Subscriber Message Server Departments.Sales Pipeline > 20000 Departments.Sales Pipeline > 15000 not delivered delivered Subscriber Subscriber Departments.Sales JMSPriority > 5 Departments.Sales JMSPriority >= 2 AND Pipeline > 10000 EEC-681: Distributed Computing Systems
Browsing a Queue Message1 QueueBrowser Message2 getEnumeration() Message3 Enumeration nextElement() Message4 EEC-681: Distributed Computing Systems
Accessing Message Content get<type>(Name) Message MapMessage TextMessage ObjectMessage StreamMessage BytesMessage getText() getObject() read<type>() EEC-681: Distributed Computing Systems