+ All Categories
Home > Documents > Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of...

Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of...

Date post: 21-Feb-2021
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
86
Messaging: Basic Exchange, Processing and Transformation Models and Tools Hong-Linh Truong Distributed Systems Group, TU Wien [email protected] dsg.tuwien.ac.at/staff/truong @linhsolar DST Summer 2017 DST 2017 1
Transcript
Page 1: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Messaging: Basic Exchange, Processing

and Transformation Models and Tools

Hong-Linh Truong

Distributed Systems Group, TU Wien

[email protected]/staff/truong

@linhsolar

DST Summer 2017

DST 2017 1

Page 2: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Outline

Overview of streaming message-oriented data

programming

Communication - Message-Oriented Middleware

Java Messaging Service (JMS), Advanced Message

Queuing Protocol (AMQP), Message Queuing

Telemetry Transport (MQTT)

Integration - Enterprise Integration patterns

Message routing patterns

Message transformation patterns

Processing - streaming data processing with

Complex Event Processing

DST 2017 2

Page 3: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Topic complexity

DST 2017 3

Getting started with each topic of “complex *” in 10 minutes.

Thousand of pages of documents, APIs, tutorials and code

Further advanced topics will be covered in Lecture 5

Page 4: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

STREAMING MESSAGE-

ORIENTED PROGRAMMING

Overview

DST 2017 4

Page 5: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Data stream programming

Examples of data streams

Continuous media (e.g., video)

Discrete media (e.g., stock market events, twitter

events, system monitoring events, notifications)

DST 2017 5

Data stream: a sequence/flow of data units

Data units are defined by applications: a data unit can

be data described by a primitive data type or by a

complex data type, a serializable object, etc.

Streaming data: produced by (near)realtime data

sources as well as (big) static data sources

Page 6: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Some key issues

Communication

Which techniques can we use to support the

communication (send, receive, route, storage, etc.)

Data processing

Within the brokering communication infrastructures and

platforms

Within the producer and the consumer

Interoperability issues: message format, etc.

Performance issues: rates, intervals, delay, etc.

DST 2017 6

Arrival orders

Data producer

Streaming

data

Data consumer

End-to-end delay

Brokering

Communication

Infrastructures &

platformsmsg3 msg2 msg1 msg3 msg1 msg2

Page 7: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Message-oriented Middleware

(MOM)

Discrete media data units

Data units are structured messages (maybe ordered by time

stamps)

Well-supported in large-scale systems for

Persistent but asynchronous messages

Scalable message handling

Message communication and transformation

publish/subscribe, routing, extraction, enrichment

Several implementations

DST 2017 7

Apache Qpid™Amazon SQS

JMS

Apache Kafka

Page 8: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Message-oriented Persistent

Communication

Communication models

DST 2017 8

Operations

PUT/SEND/PUBLISH

GET/RECEIVE

POLL/SUBSCRIBE

NOTIFY/SEND

Fig source: Andrew S. Tanenbaum and Maarten van Steen, Distributed Systems – Principles and

Paradigms, 2nd Edition, 2007, Prentice-Hall

The receiver pulls the

data from the broker or

the broker pushes the

data to the receiver?

Broker

Page 9: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

MOM – some message processing

operations

DST 2017 9

m2IF…

m1m3

m1

m2m3

Publish/subscribe/notify; send/forward; routing operations within a broker

queue

queuesrouter/exchange

Page 10: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Message processing within data

consumer

DST 2017 10

Incoming streams

Streaming

data type m

Output complex messages

m3 m2 m1

… … …

s3 s2 s1

m1

s1

m2

s2

m3

s3Streaming

data type s

Complex/multiple streams

data processing

Application-specific data processing

Page 11: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Streaming data processing with a

network of data processing

elements

DST 2017 11

… … …

Streaming

data

processing

… … …

… … …

… … …

… … …

Streaming

data

processing

Streaming

data

processing

Page 12: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Message handling for enterprise

integration

Messages handling concepts and patterns have

been around for many years, since we need to

support cross services/organizations integration

Enterprise integration pattern is well studied but

mostly focused on business message

http://www.enterpriseintegrationpatterns.com/

Today distributed applications

not just enterprise integration patterns

also various types of measurements and log

information integration

3/29/2017DST 2017 4

Page 13: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Filter, exchange, etc.

We need several features implemented by MOM,

consumer, or external systems

Client Clientm1m2m3

Queue/Topic

m4

Exchange,

Router, Filter,

Aggregator, etc.

http://www.eaipatterns.com/

DST 2017 4

Page 14: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Syntax and semantic problems

Secretary

of the statePresidentKafka

Source: http://www.smart-

words.org/humor-

jokes/language-humor/who-

is-hu-china.html

The same

communication

protocol does not

mean that both

sides understand

the message well!

DST 2017 4

Page 15: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Message serialization and

deserialization

Remember that the sender and the receiver are diverse

In many cases, they are not in the same organization

Through communication you can send and receive the

message

But you need to guarantee the message syntax and

semantics

Solutions

Agreed in advance in the implementation or with a

standard

Know and use tools to deal with syntax differences

But semantics are domain-specific

DST 2017 4

Page 16: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Arvo

https://avro.apache.o

rg/

Support message

description

Serialize and

deserialize libraries

Work with different

languages

Python Java

Sender

Kafka

Sender

Syntax specification

DST 2017 4

Page 17: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Some other techniques

Protobuf

From Google

https://github.com/google/protobuf

Language-neutral, platform-neutral mechanism for serializing/deserializing structured data

Thrift

https://thrift.apache.org

Support also serializing and deserializing data)

Support cross-language services development

Specify services interfaces

Data exchange

Code generation

DST 2017 4

Page 18: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

JAVA MESSAGING SERVICE

Communication

DST 2017 18

Page 19: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

General concepts

Standard APIs for Java platform

DST 2017 19

Client 1msg1msg3

Client 2

Destination

Messaging System Provider

(Message

Producer)

(Message

Consumer)

msg2

Page 20: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Message Structure

Types of messages (or what is a message for?)

Application-specific semantics

E.g., notify an event, send a document, or ask for

the execution of a command

DST 2017 20

Header Properties Body (payload)

Header: pre-defined system information (e.g., storage,

routing and identification operations)

Properties: application

defined properties

Body: application-defined

Java primitive types, Map (a set of tuples), Text, Serializable

Object

Page 21: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Delivery Patterns

DST 2017 21

Point-to-point

Publish/Subscription

Fig source: http://docs.oracle.com/javaee/7/tutorial/doc/jms-concepts002.htm

Fig source: http://docs.oracle.com/javaee/7/tutorial/doc/jms-concepts002.htm

Simple question: do we

have multiple producers or

a single producer per

destination (queue/topic)?

Page 22: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Request-reply versus Request-only

messages

Request only

A sender does not expect a reply for a given request

Request-reply

A sender expects, e.g., a system ack or an application-specific

reply

Some design principles

Need to uniquely identify a request message?

Use a unique identifier

Need a reply message from a request message

Where is the return address?

Correlation between the request and reply messages (using unique

id), e.g., MessageType=REQUEST|REPLY & MessageID = ID

DST 2017 22

Page 23: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

JMS programming versus

administrative activities

DST 2017 23

Best as

Administered objects

Best as administered

objects

Best with

programming

activities

Fig source: http://docs.oracle.com/javaee/7/tutorial/doc/jms-concepts003.htm

Page 24: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Simple example from the Java

tutorial@Resource(lookup = "java:comp/DefaultJMSConnectionFactory")

private static ConnectionFactory connectionFactory;

@Resource(lookup = "jms/Queue")

private static Queue dest;

….

try (JMSContext context = connectionFactory.createContext();) {

int count = 0;

for (int i = 0; i < NUM_MSGS; i++) {

message = "This is message " + (i + 1) + " from producer";

TextMessage msg = context.createTextMessage();

msg.setText(message);

msg.setIntProperty("ID",count);

if (((i+1) %2 )==0) {

msg.setStringProperty("msgType","EVEN");

} else msg.setStringProperty("msgType","ODD");

context.createProducer()

.setDeliveryMode(DeliveryMode.NON_PERSISTENT)

.send(dest, msg);

count += 1;

}

System.out.println("Messages sent: " + count);

DST 2017 24

Page 25: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Some other JMS API features

Control message acknowledgement

By JMS provider or by the client

Message parameters

Persistent, priority, delay, and expiration

Programming temporal destinations

Nondurable versus durable subscription

Local transaction

Asynchronous sending

DST 2017 25

Generic question: how does the broker manage durable

subscription?

Page 26: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Example of temporary queues for

performance improvement

DST 2017 26

Use cases and Figs source: http://www.onjava.com/2007/04/10/designing-messaging-applications-with-temporary-queues.html

Common static queues for multiple clients Separate static queues for multiple

clients

Temporary queues

Page 27: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Outside the java world?

DST 2017 27

Source: http://docs.spring.io/spring-python/1.2.x/sphinx/html/jms.html

Page 28: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Recall

DST 2017 28

Figure source: http://queue.acm.org/detail.cfm?id=1971597

Would you use a

JMS topic or

queue?

Page 29: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

ADVANCED MESSAGE

QUEUING PROTOCOL

Communication

DST 2017 29

Page 30: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Overview

MOM, but not language- or platform- specific

For Java, C#, Python, ….

Solving message interoperability in heterogeneous

environments of MOMs

Binary wire-level protocol for message

exchange, rather than APIs

It does not include broker behaviors/capabilities but

they were in the standard before version 1.0

http://www.amqp.org

DST 2017 30

Apache Qpid™

Page 31: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Core concepts –

Message/Transport

Message representation

Defined based on type

systems for interoperability

Transport

A network of nodes

connected via links

Node: message storage,

delivery, relay, etc.

Container: includes nodes

DST 2017 31

Figs source: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-complete-v1.0-os.pdf

Page 32: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Core concept -- Transport

DST 2017 32

Figs source: http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-complete-v1.0-os.pdf

Connection

Session

Session and Connection endpoints

Links

Page 33: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Example

DST 2017 33

cloudamqp.com

Test sender

Get a free instance of RabbitMQ from cloudamqp.com

Get code from: https://github.com/cloudamqp/java-amqp-example

First run the test sender, then run the receiver

Test receiver

channel.queueDeclare(QUEUE_NAME, false, false, false, null);

for (int i=0; i<100; i++) {

String message = "Hello distributed systems guys: "+i;

channel.basicPublish("", QUEUE_NAME, null, message.getBytes());

System.out.println(" [x] Sent '" + message + "'");

new Thread().sleep(5000);

}

while (true) {

QueueingConsumer.Delivery delivery = consumer.nextDelivery();

String message = new String(delivery.getBody());

System.out.println(" [x] Received '" + message + "'");

}

Note: i modified the code a bit

Page 34: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Example: AMQP

ConnectionFactory factory = new ConnectionFactory();

factory.setUri(uri);

Connection connection = factory.newConnection();

Channel channel = connection.createChannel();

channel.queueDeclare(QUEUE_NAME, false, false, false, null);

for (int i=0; i<100; i++) {

String message = "Hello distributed systems guys: "+i;

channel.basicPublish("", QUEUE_NAME, null,

message.getBytes());

System.out.println(" [x] Sent '" + message + "'");

new Thread().sleep(5000);

}

channel.close();

connection.close();

ConnectionFactory factory = new ConnectionFactory();

factory.setUri(uri);

Connection connection = factory.newConnection();

Channel channel = connection.createChannel();

channel.queueDeclare(QUEUE_NAME, false, false,

false, null);

System.out.println(" [*] Waiting for messages");

QueueingConsumer consumer = new

QueueingConsumer(channel);

channel.basicConsume(QUEUE_NAME, true,

consumer);

while (true) {

QueueingConsumer.Delivery delivery =

consumer.nextDelivery();

String message = new String(delivery.getBody());

System.out.println(" [x] Received '" + message + "'");

}

DST 2017 34

Source code:

https://github.com/cloudamqp/java-

amqp-example

Page 35: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Performance

“RabbitMQ Hits One Million Messages Per

Second on Google Compute Engine”

https://blog.pivotal.io/pivotal/products/rabbitmq-hits-

one-million-messages-per-second-on-google-

compute-engine

https://cloudplatform.googleblog.com/2014/06/rabbit

mq-on-google-compute-engine.html

Using 32 nodes

RabbitMQ is widely used in big industries!

DST 2017 4

Page 36: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

MESSAGE QUEUING

TELEMETRY TRANSPORT

(MQTT)

http://mqtt.org

DST 2017 4

Page 37: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

MQTT Overview

OASIS Standard

ISO/IEC 20922:2016 (Message Queuing Telemetry Transport (MQTT) v3.1.1)

M2M Connectivity Protocol atop TCP/IP

MQTT brokers enable publish/subscribe messaging systems

Publisher can publish a messge within a topic that can be subscribed by many Subscribers

Simple protocols

Suitable for constrained devices.

DST 2017 4

Page 38: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Protocol Features

Lightweight protocol Small message size

QoS At most once, at least once and exactly once

Few commands/interactions: CONNECT, PUBLISH, SUBSCRIBE, UNSUBRIBE, DISCONNECT Easy to implement

Small foot-print libary

Low bandwidth, high latency, data limits, and fragile connections

Suitable for IoT (constrained devices/networks)

DST 2017 4

Page 39: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Model and Implementation

Different programming languages for OS/devices

Including Anrduino, Nanode

Mosquitto (http://projects.eclipse.org/projects/technology.mosquitto)

Paho: http://www.eclipse.org/paho/

RabbitMQ

Apache ActiveMQ

Cloud providers:

http://cloudmqtt.com (get a free account to learn MQTT)

PublisherBroker

ServerSubcriber

DST 2017 4

Page 40: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

MESSAGE ROUTING

PATTERNS

Integration

DST 2017 40

Page 41: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Integration Issues

We need several features implemented by

MOM, consumer, or external systems

DST 2017 41

Client Clientm1m2m3

Queue/Topic

m4

Exchange, Router,

Filter, Aggregator, etc.

http://www.eaipatterns.com/

Page 42: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Example of supporting technology

DST 2017 42

Best practices for solving common

problems: Integration Patterns

Also check: http://projects.spring.io/spring-integration/

Page 43: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Content-Based Message Routing:

Camel/EIP

DST 2017 43SS 2012

Source: https://camel.apache.org/content-based-router.html

Source: https://camel.apache.org/dynamic-router.html

Content-Based Router:

can be used to decide

the right destination

queue for a given

message based on the

message content

Dynamic Router: can

self-configure based on

processing messages

Page 44: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Content-Based Message Routing:

AMQP

DST 2017 44

Figs source: https://access.redhat.com/site/documentation/en-

US/Red_Hat_Enterprise_MRG/1.1/html/Messaging_User_Guid

e/chap-Messaging_User_Guide-Exchanges.html

Note: defined in AMQP 0-10

But not in AMQP 1.0

Page 45: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Message Filter/Selector

DST 2017 45SS 2012

TextMessage msg = context.createTextMessage();

msg.setText(message);

msg.setIntProperty("ID",count);

if ((count % 2 )==0) {

msg.setStringProperty("msgType",“EVEN");

}

else

msg.setStringProperty("msgType",“ODD");

JMSConsumer consumer = context.createConsumer(dest,"msgType

=‘EVEN’”);

JMS: selector based on message header and properties

CAMEL/EIP: Message Filter

https://camel.apache.org/message-filter.html

Message Selector or

Message Filter: filter

unneeded messages

Page 46: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

TRANSFORMATION

PATTERNS AND TOOLS

Integration

DST 2017 46

Page 47: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Splitter and Aggregator

DST 2017 47SS 2012

Splitter: decompose a

composite message into

different messages

Aggregator: gather all

correlated messages for

a specific purpose then

build a new composite

message

Questions: for which scenarios/use cases we can use the above-

mentioned patterns

https://camel.apache.org/splitter.html

https://camel.apache.org/aggregator2.html

Page 48: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Envelope Wrapper and Normalizer

DST 2017 48SS 2012

Envelope wrapper: wrap a

message before sending it

into a messaging system and

unwrap it after the wrapped

message leaves the

messaging system

Normalizer: route all

messages of a given type

to a suitable Message

Translator which transforms

the message to the

common format.

https://camel.apache.org/normalizer.html

http://www.eaipatterns.com/EnvelopeWrapper.html

Page 49: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Content Enricher & Extracter

DST 2017 49SS 2012

Content Enricher: obtain

required/missing data then

enrich the message with the

newly obtained data

Content Filter: remove

unimportant data items from a

message or extract only

needed information.

https://camel.apache.org/content-filter.html

https://camel.apache.org/content-enricher.html

Question: is it possible to send the to-be-enriched message to an external

service to enrich it or to send the message to an external extraction service?

Page 50: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Logstash

Codecs: stream filters within inputs or outputs that change data representation

E.g.: multilines a single event

50

Source: https://www.elastic.co/guide/en/logstash/current/advanced-pipeline.html

DST 2017 50

Page 51: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Plug-ins

51

https://www.elastic.co/guide/en/logstash/current/working-with-plugins.html

DST 2017 51

Page 52: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Logstash Grok

Grok is for parsing unstructured log data

text patterns into something that matches your

logs.

Grok syntax: %{SYNTAX:SEMANTIC}

Regular and custom patterns

A lot of exiting patterns:

https://github.com/logstash-plugins/logstash-patterns-

core/tree/master/patterns

Debug Tools: http://grokdebug.herokuapp.com/

52DST 2017 52

Page 53: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Example with NETACT Log

53

29869;10/01/2017 00:57:56;;Major;PLMN-PLMN/BSC-401441/BCF-137/BTS-

403;XYZ01N;ABC08;DEF081;BTS OPERATION DEGRADED;00 00 00 83 11

11;Processing

Simple Grok

DST 2017 53

Page 54: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Apache Nifi

From NSA

http://nifi.apache.org/

Main concepts:

Processor: components to handle data, such as

download, store, transform, etc.

FlowFile: describes how different components are

composed to create pipelines for data ingestion

Provenance (for data governance): see all usage

records in detail

54DST 2017 54

Page 55: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Apache Nifi

55

https://nifi.apache.org/docs.html

DST 2017 55

Page 56: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

COMPLEX EVENT

PROCESSING

Processing

DST 2017 56

Page 57: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Centralized versus distributed

processing topology

Complex Event Processing

(centralized processing)

Streaming Data Processing

(distributed processing)

Proces

sing

Usually only

queries/patterns are written Code processing events and

topologies need to be

written

Event cloud

Event source

Proces

sing

Proce

ssing Proces

sing

node

node

node

node

node node

Two views: streams of events or cloud of events

DST 2017 57

Page 58: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Goals of complex event processing

Group and process events in a specific time

(how long?) and space (size) constraints

Detect special events

Finding correlation and causality

Aggregation events

Queries for period time

DST 2017 58

Page 59: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

TIBCO Systems

Source: http://www.tibco.com/blog/2015/10/05/how-to-extend-big-data-

architectures-with-rules-and-visualization/

DST 2017 59

Page 60: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

WSO2 Carbon

CEP/Siddhi

Source:

https://docs.wso2.com/display/CEP420/W

SO2+Complex+Event+Processor+Docum

entation

DST 2017 60

Page 61: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Apache Flink

DST 2017 61

Source: https://flink.apache.org/introduction.html

Page 62: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Common concept in these systems

The way to connect data streams and obtain events Focusing very much on connector concepts and well-defined

event structures (e.g., can be described in XML, JSON, POJO)

Assume that existing systems push the data

The way to specify “analytics” Statements and how they are glued together to process flows of

events

High-level, easy to use

The engine to process analytics requests Centralized in the view of the user so the user does not have

to program complex distributed applications

Underlying it might be complex (for scalability purposes)

The way to push results to external components

62DST 2017 62

Page 63: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Basic concepts

DST 2017 63

m1m2m4 .. .... A stream of events

Arrival order

Window

If we

• specify a set of conditions for the window and events within the

window

then we can

• get a set of events filtered from the window that match these

conditions

Conditions: can be specified using an SQL-alike language or pre-

defined functions

Sliding window size: time or

size of events

Page 64: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Event Representation, Streams and

Views

DST 2017 64

Event sources: via MOM, files, different IO

adapters/connectors, etc.

Event representation & views POJO (Plain Old Java Object), Map, Object-array, XML

SQL-alike tables

Event Stream

Events ordered based on their arrival times

Event Sink A component receiving events via its listener that declares

some statements on interesting events

Page 65: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Windows and Times

DST 2017 65

Source: https://ci.apache.org/projects/flink/flink-docs-release-1.2/concepts/programming-model.html

Page 66: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Window size and slide

DST 2017 66

Source: https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/windows.html

Page 67: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Batch/Tumbling Windows

DST 2017 67

Source: https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/windows.html

Page 68: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Flink Window processing

DST 2017 68

Trigger: send the results

Evictor: remove elements from a window in certain conditions

Lateness: allow late time-based events

Windows function: computation applied to windows

Type of

windows

Source: https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/windows.html

Page 69: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Flink CEP Patterns

DST 2017 69

Source: https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/libs/cep.html

Page 70: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Flink CEP Patterns

DST 2017 70

Source: https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/libs/cep.html

Page 71: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Example with Base Transceiver

Station

DST 2017 71

station_id,datapoint_id,alarm_id,event_time,value,valueThreshold

1161115016,121,308,2017-02-18 18:28:05 UTC,240,240

1161114050,143,312,2017-02-18 18:56:20 UTC,28.5,28

1161115040,141,312,2017-02-18 18:22:03 UTC,56.5,56

1161114008,121,308,2017-02-18 18:34:09 UTC,240,240

1161115040,141,312,2017-02-18 18:20:49 UTC,56,56

1161114050,143,312,2017-02-18 18:47:40 UTC,28.5,28

1161115016,121,308,2017-02-18 19:01:14 UTC,241,240

1161114061,121,301,2017-02-18 18:59:03 UTC,76,80

1161114011,121,308,2017-02-18 18:51:09 UTC,241,240

Data

Page 72: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Simple example

DST 2017 72

AMQP Connector

Patterns

Output

Page 73: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Monitoring

DST 2017 73

Page 74: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Results

DST 2017 74

Detected: station_id=1161115006 for datapoint_id=121 at Sat Feb 18 21:54:30 CET

2017 alarm_id=308 with value =240.0 --> station_id=1161115006 for

datapoint_id=116 at Sun Feb 19 02:20:22 CET 2017 alarm_id=303 with value

=999999.0

Detected: station_id=1161114011 for datapoint_id=121 at Sat Feb 18 20:57:34 CET

2017 alarm_id=308 with value =241.0 --> station_id=1161114011 for

datapoint_id=116 at Sun Feb 19 00:59:18 CET 2017 alarm_id=303 with value

=999999.0

Page 75: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

SQL-alike CEP

We can register/view stream as a table (like

SQL)

Then apply SQL-alike statements with windows

for detecting events and patterns

Tools: Esper, WSO2, and certain streaming

databases

DST 2017 75

Page 76: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Example of WSO2 Siddhi

76

Source: https://docs.wso2.com/display/CEP420/SiddhiQL+Guide+3.1

DST 2017 76

Page 77: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

SQL-alike conditions

DST 2017 77

@Import('mobifonetrainingopensignal:1.0.0')

define stream inStream (meta_USERPHONE int, meta_TIME long, correlation_lat float,

correlation_lon float, GSM_BIT_ERROR_RATE float, GSM_SIGNAL_STRENGTH float,

LOC_ACCURACY float, LOC_SPEED float);

@Export('OutputSignal:1.0.0')

define stream OutputSignal (avgSignalStrength double, avgBitRateError double);

from inStream#window.lengthBatch(5)

select avg(GSM_SIGNAL_STRENGTH) as avgSignalStrength, avg(GSM_BIT_ERROR_RATE) as

avgBitRateError

insert into OutputSignal;

Page 78: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Put things together

A data pipeline of stream receivers event processor event publishers

78DST 2017 78

Page 79: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Service

Example with WSO2 Carbon CEP

79

Source Sink

Language + UI specifications

Can also execute the topology as Storm task (see Storm in the next lecture)

DST 2017 79

Page 80: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Get a high-level view

DST 2017 80

Check:

http://de.slideshare.net/alessandro_margara/processing-flows-of-information-debs-2011

Page 81: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

BEYOND BASIC MESSAGE

PROCESSING

Partially covered in Lecture 5

DST 2017 81

Page 82: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Cloud services and big data analytics

Data sources

(sensors, files, database,

queues, log services)

Messaging systems

(e.g., Kafka, AMQP,

MQTT)

Storage and Database

(S3, InfluxDB, HDFS, Cassandra,

MongoDB, Elastic Search etc.)Batch data processing

systems

(e.g., Hadoop, Airflow, Spark)

Stream processing

systems

(e.g. Apex, Storm, Flink,

WSO2, Google Dataflow)

Elastic Cloud Infrastructures

(VMs, dockers, OpenStack elastic resource management tools, storage)

Warehouse

Analytics

Operation/Management/

Business Services

DST 2017 4

Page 83: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Data Processing Framework

Batch processing

Mapreduce/Hadoop

Scientific workflows

(Near) realtime streaming processing

Flink, Apex, Storm

Hybrid data processing

Summingbird, Apache Kylin

Impala, Storm-YARN

Apache Spark

DST 2017 83

Take a short read: http://www.infoq.com/articles/stream-processing-hadoop

Page 84: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Analytics (Application Level)

Conceptual View

DST 2017 84

Data Processing Frameworks

Streaming/Online

Data Processing

Batch Data

Processing

Hybrid Data

Processing

Static data(Near)

realtime data

Decision Data Analysis

Analytics,

Tools,

Processes &

Models

Page 85: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

Further materials

https://access.redhat.com/site/documentation/en-

US/Red_Hat_Enterprise_MRG/1.1/html/Messaging_User_Guide/sect-Messaging_User_Guide-

Introduction_to_RHM-The_AMQP_0_10_Model.html

Java Message Service: http://www.oracle.com/technetwork/java/index-jsp-142945.html

Java Message Service specification, version 2.0, available from:

http://jcp.org/en/jsr/detail?id=343

http://kafka.apache.org

https://camel.apache.org/enterprise-integration-patterns.html

http://www.eaipatterns.com

http://docs.oracle.com/javaee/7/tutorial/doc/home.htm

http://docs.oracle.com/cd/E13157_01/wlevs/docs30/epl_guide/index.html

http://www.espertech.com/esper/documentation.php

Miyuru Dayarathna and Toyotaro Suzumura. 2013. A performance analysis of system s, s4, and

esper via two level benchmarking. In Proceedings of the 10th international conference on

Quantitative Evaluation of Systems (QEST'13), Kaustubh Joshi, Markus Siegle, Mariëlle

Stoelinga, and Pedro R. D'Argenio (Eds.). Springer-Verlag, Berlin, Heidelberg, 225-240.

DOI=10.1007/978-3-642-40196-1_19 http://dx.doi.org/10.1007/978-3-642-40196-1_19

DST 2017 85

Page 86: Messaging: Basic Exchange, Processing and Transformation … · 2020. 7. 26. · Overview of streaming message-oriented data programming ... events, system monitoring events, notifications)

86

Thanks for your attention

Hong-Linh Truong

Distributed Systems Group, TU Wien

[email protected]

http://dsg.tuwien.ac.at/staff/truong

DST 2017


Recommended