Communication Technologies Flashcards

w5,6

1
Q

Basic terms: send/request data

  • who to who?
  • synonyms of send and sender?
A

sender (data) -> receiver

send: produce, push, publish, broadcast, …
sender: producer, publisher, caller, requestor, …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Basic terms: reply data/status/response

  • from who to who
  • synonyms of receive, receiver,reply
A

sender <- receiver (reply data)

receive: accept, consume, take, get, …
receiver: listener, consumer, subscriber, …
wait to receive: wait for, listen for, subscriber, callee, …
reply: response, feedback, return, …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How many receivers does the sender expect for the data sent?

A

1 receiver: one-to-one
all receivers: one-to-all
selected receivers: one-to-selected

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is MOM
- purpose?
- forms?

A

Message Oriented Middleware
- software which sits between 2 or more applications or (micro)services and allow them to exchange data in the form of messages
- form a hub-spoke architecture pattern, in contrast to peer-to-peer connections in invocation-based communication technologies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is a Common Message Structure

A
  1. Networking / communication technology related info : usually protocol/technology dependent (headers)
  2. Properties/metadata of message : usually key-value pairs
  3. Body / business data : contains application-specific business data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is AMQP
- benefits?
- supports?

A

Advanced Message Queuing Protocol
- open standard protocol for MOM : define a message format that allows standard and extensible representations of various types of data
- provide interoperability
- supports various communication patterns

Eg. RabbitMQ (pika is a python module for clients in python to interact with AMQP servers)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is RabbitMQ

A

a message-queueing software that supports AMQP
- aka message broker/queue manager

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is RabbitMQ Messaging
- how does it work?

A

broker accepts and forwards messages
- producer (publisher) sends messages to the broker
- consumer (subscriber) receives messages from the broker
message: can be anything including detailed business data or event; routed to a queue(s) via an exchange in broker and key matching pattern
broker can keep message in queue until a consumer takes the message of the queue (message storage)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

code: persistent message

  • what does persistent message mean?
A

A message may or may not be persistent (delivery_mode=2 or pika.spec.PERSISTENT_DELIVERY_MODE); if not (i.e., delivery_mode=1 or pika.spec.TRANSIENT_DELIVERY_MODE), the message would be dropped if there is no receiver online when the message is sent.

*even if the broker fails or is restarted, the message will still be available for delivery to consumers once the broker is back online.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

RabbitMQ Messaging - Exchange
- what happens

A
  1. Publish a message with a routing key
  2. Each queue is bound to some exchange(s) via a binding key
  3. Subscribe to a queue to receive messages
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Types of exchanges (3)

  • how do they work?
A
  1. Direct: delivers a message to a queue whose binding key == routing key of message sent to exchange (eg. email address)
  2. Topic: wildcard match between routing key of message and binding key of queues bound to the exchange (eg. select who to receive notif)
  3. Fanout: routes a message to all queues that are bound to it (eg. broadcast)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

which communication patterns can be implemented by which type of exchanges more conveniently? (5)

A
  • One-to-one: direct
  • One-to-all: fanout
  • One-to-selected many: topic
  • Fire-forget: direct/fanout/topic
  • Request-reply: may be implemented as two one-way messaging
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how are binding keys and routing keys matched (for topic exchange)

A

matched 0, 1, or many words

  • /* matches any 1 word
  • # matches 0, 1 or many words
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

RabbitMQ/Pika Programming Model for Python
- 3 functions

A

The connection/channel to the broker needs to be set up for each/every run of a publisher or a consumer.
The set-ups of exchange/queue may need be done only once for all sessions/connections; they can be done separately via RabbitMQ management GUI or an automated script.
In the same session/connection, a publisher/a consumer can publish/consume many messages.
“on_message_callback” refers to a function that is defined in the consumer; the function can do anything with the message received according to the business requirements.
“basic_consume” sets up a consumer and binds the “on_message_callback” function to all messages to be received.
“start_consuming” starts a loop to wait to receive any message from the queue, and automatically invokes the “on_message_callback” function to process each of the messages received. Use Ctrl + C in the cmd windows to terminate it.

ref google docs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Choice of communication technologies

A

P1: process or user needs an immediate response => communication with all the relevant underlying microservices should use invocation-based, synchronous communication

P2: process/user does not need an immediate response => communication with all the relevant underlying microservices should use message-based, asynchronous communication

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Implementation: AMQP with Direct Exchange

A
  • queue(s) are bound to a DIRECT exchange with specific binding key(s)
  • receiver(s) connect to broker and wait for messages from specific queue(s)
  • data is passed in the form of AMQP messages
  • when sending a message to the broker, the sender sets the routing key of the message according to the binding key of intended receiving queue(s)
  • after sending a message to the broker, the sender doesn’t have to wait for a reply
17
Q

names of queues in the same broker?

A

has to have a unique name

18
Q

queues of the same exchange?
- binding keys

A
  • each queue can have more than 1 binding key to the same exchange
  • different queues in the same broker can have the same binding key to the same exchange; (thus, Direct Exchange can in fact be used to implement one-to-many communication patterns too)
19
Q

messages between exchanges

A

binding keys can bind exchanges -> allow messages to be receives

20
Q

Implementation: AMQP with Fanout Exchange

A
  • queue(s) are bound to a fanout exchange with NO binding key
  • receiver(s) connect to the broker and wait for messages from specific queue(s)
  • every queue bound to the exchange gets every message sent to the exchange
21
Q

Implementation: AMQP with Topic Exchange

A
  • queue(s) are bound to topic exchange with binding key(s) / pattern(s)
  • receiver(s) connect to the broker and wait for messages from specific queue(s)
  • message is routed to queue(s) whose binding key/pattern matches the routing key of the message
22
Q

Implementation: Load balancing among AMQP Consumers

A
  • all receivers subscribed to the same queue take turns to retrieve a message from the queue (round-robin)
  • workload of receiving and processing data is evenly distributed
  • queue acts as a load balancer
23
Q

Categorisation criteria for communication (3)

A
  1. how many receivers
  2. is a reply expected
  3. do the sender and receiver need to be online at the same time
24
Q

does the sender expect a reply?

A

No: fire-forget
Yes: request-reply

25
Q

do the sender and receiver need to be online at the same time?

A

yes: synchronous
no: asynchronous (usually have some intermediaries)

26
Q

types of communication technologies (2)

A

invocation-based: data goes point-to-point
- eg. phone call , web browsing (via HTTP)

message-based: data goes through a message broker / intermediaries
- eg. email, phone voice messaging box

27
Q

what is messaging (publish-subscribe)

A
  • publish a message to a certain communication channel maintained by the broker
  • other (micro)services subscribe to the channel maintained by the broker
  • publisher is loosely coupled from the subscriber
28
Q

characteristics of communication technologies

A

invocation-based vs message based : ref google docs