iot service bus - high availability with internet of things (iot)/ api rest/ message broker

101
Palestrante: Alexandre Brandão Lustosa IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker http://www.compsulmt.com .br/

Upload: alexandre-brandao-lustosa

Post on 13-Apr-2017

203 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Palestrante: Alexandre Brandão Lustosa

IoT Service Bus - High availability with Internet of Things (IoT)/ API

Rest/ Message Broker

http://www.compsulmt.com.br/

Page 2: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

IoT Service Bus - High availability with Internet of Things (IoT)/ API

Rest/ Message Broker

[email protected]

"A única maneira de fazer um excelente trabalho é amar o que você faz." (Steve Jobs)

Page 3: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Bacana!! :)

Page 4: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Clientes MundiPagg - 40% MarketShare

LOJAS DEPARTAMENTO MODA ENTRETENIMENTO ALIMENTOS

Temos mais de 1500 lojas em nosso portfólio, algumas delas são as maiores marcas brasileiras e internacionais.

ÓLEO TV

Page 5: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Vamos dominar o mundo!!

Page 6: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Quer jogar?

Page 7: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Relaxa!! D boa, você vai achar a solução!

Page 8: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

{ Seja criativo!! :) =)

Page 9: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Quer um café?

Page 10: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker
Page 11: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

C# .Net

jQuery

PHP

Magento

Angular.js

Node.js

Gulp

Java

Ruby

SQL Server

MongoDB

Kibana

Log StashRedis

RabbitMQCassandra

Scala Akka.Net

Python

TFS

Git

ApacheJira

SentryMonitis

Python

New RelicAzure

Nosso Stack

MVC

REST

Web APIGo

Page 12: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Vamos dominar o mundo!!!!

Page 13: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Faça parte do nosso time!

[email protected]

[email protected]

"A única maneira de fazer um excelente trabalho é amar o que você faz." (Steve Jobs)

Page 14: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Faça parte do nosso time!

[email protected]

{ TEMOS VAGAS }

"A única maneira de fazer um excelente trabalho é amar o que você faz." (Steve Jobs)

Page 15: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Alexandre Brandão

{ Microsoft C# .Net Solution Developer, C++ Linux Developer, C/C++ Embedded Programmer }

<contatos> <twitter>

@abrandaolustosa </twitter> <skype>

[email protected] </skype></contatos>

Gerente de TIArquiteto de Sistemas

Analista Desenvolvedor Sênior

curl -data “experiencia=16_anos&motivacao=inovacao%20e%20pesquisa” http://www.stone.com.br

Page 16: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Internet Of Things{ IoT }

Page 17: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

“Definição” : “É uma revolução tecnológica a fim de conectar dispositivos eletrônicos utilizados no dia-a-dia (como aparelhos eletrodomésticos, eletroportáteis, máquinas industriais, meios de transporte, etc) à Internet, cujo desenvolvimento depende da inovação técnica dinâmica em campos tão importantes como os sensores wireless, a inteligência artificial e a nanotecnologia.”

{

}

Page 18: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker
Page 19: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker
Page 20: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

https://www.youtube.com/watch?v=Q3ur8wzzhBU

Intel IoTWhat Does The Internet of Things Mean?

Page 21: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker
Page 22: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker
Page 23: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker
Page 24: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

IoT

MedicinaMilitar

At HomeProdução

FabrilDesenvolvimento

Transporte

MobilidadePesquisa

Educação

AcessibilidadeAgro

Page 25: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

IoT

Share Data Integration Systems

Cloud ServiceReal Time

FabrilBI

Artificial Intelligence

Dataware HousePesquisa

Media Big Data

Page 26: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Sensores• Temperatura• Luminosidade• Humidade• Reconhecimento de voz• Sensor de proximidade• Radar• Ultrasom• Infrared• Relay

Page 27: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Sensores Industriais

Page 28: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

{ Microsoft Kinect }

Page 29: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

{

Microsoft Kinect

}

Page 30: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Microsoft IoT RoadShow

Redmond – Washington/USA - Out/2016

Page 31: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Microsoft IoT RoadShow

Redmond – Washington/USA - Out/2016

Page 32: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Microsoft IoT RoadShow

Redmond – Washington/USA - Out/2016

Page 33: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Microsoft IoT RoadShow

Redmond – Washington/USA - Out/2016

Page 34: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Microsoft IoT RoadShow

Redmond – Washington/USA - Out/2016

Page 35: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Intel Edison – Arduino Platform

• 1 GB DDR3 RAM, 4 GB eMMC flash• 40 multiplexed GPIO interfaces• Bluetooth* 4.0, Wi-Fi*• Yocto Project*, Brillo*• Arduino* compatible• Open-source software development

environment• C/C++, Python*, Node.js*, HTML5, JavaScript*

Page 36: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Intel Edison – Arduino Platform

Page 37: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Intel Edison – Arduino Platform

Page 38: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Intel Edison Groove Kit

Page 39: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Raspberry Pi 3

Page 40: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker
Page 41: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Beaglebone

Page 42: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Beaglebone

Page 43: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Arduino Kit - Ebay

Fonte: ebay.com – 16/nov/2016

Page 44: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Arduino Kit - Ebay

Fonte: ebay.com – 16/nov/2016

Page 45: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Arduino Kit - Ebay

Fonte: ebay.com – 16/nov/2016

Page 46: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Intel XDK IDE

https://software.intel.com/pt-br/intel-xdk

Page 47: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Microchip PIC18 / PIC24 / PIC32 / DsPIC

Page 48: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Node.js is a JavaScript Runtime Built...

Page 49: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

IoT - High Availability

IoT API RestService Bus

Message Broker

PersistenceLayer Databases

Devices

Devices

Devices

Devices

Devices

Sensors

Sensors

Sensors

Sensors

Sensors

Cloud Service / On Premise Cluster Service

Page 50: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

IoT with Slack API

Page 51: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

IoT with Slack API

https://github.com/alexandrebl

Page 52: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Método principal

//Main functionfunction main(){

//Setup configurations config();

//Set loop process each 4 seconds setInterval(function () {

//Set led process indicator on

ledProcessOn(); //Read Sensor var data = readTempSensor();//Post data on Slack postOnSlack(data); //Set led process indicator on

ledProcessOff();

}, 4000);}

Page 53: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Define o pino como saída para o LED

//Setup configurationfunction config(){

//Set pin direction

ledProcess.dir(mraa.DIR_OUT);}

//Set led process indicator onfunction ledProcessOn(){

//Write signal to up ledProcess.write(1);}

//Set led process indicator offfunction ledProcessOff(){

//Write signal to down ledProcess.write(0);

}

Envia o sinal altoAcende o LED

Envia o sinal baixoApaga o LED

Page 54: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

function postOnSlack(data){ //Set options and message var options = {

//Webhook uri, replace by your uri Slack web hook integration

uri: https://hooks.slack.com/services/T0FES4821jluMzasy',

method: 'POST', //Request type json: data //Data

}; //Do post request request(options, function (error, response, body) {

//Verify response if (!error && response.statusCode == 200)

console.log("Success"); }else

console.log(error); }

});}

Exemplo de integração com API Rest

Page 55: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Repositório de códigos

https://github.com/alexandrebl

Page 56: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Message Broker

Page 57: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

“Definição” : “An enterprise service bus (ESB) is a software architecture model used for designing and implementing communication between mutually interacting software applications in a service-oriented architecture (SOA)”

{

}

Page 58: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Integraçãode

Sistemas

Page 59: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Recursos

Page 60: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

<wrong>Não utilize workflows centralizados e dependentes do banco de dados</wrong>

“Repense sua arquitetura”

Page 61: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Pipeline – Service Bus

Page 62: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

{ Soluções – Service Bus }

- RabbitMQ- CloudAMQP (RabbitMQ)- Azure ServiceBus- IBM MQ Series- Amazon SQS- SQL Server Service Broker- Microsoft Message Queue- OpenShift- Kafka

Page 63: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

https://www.rabbitmq.com/

• Robust messaging for applications• Easy to use• Runs on all major operating systems• Supports a huge number of developer

platforms• Open source and commercially supported• Multiplatform for Windows, Linux and Mac OS• Erlang

Page 64: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

RabbitMQ - SDKs

C# .Net PHP

JavaRuby

ErlangPerl

Javascript

GoPython

Scala

Haskell

Page 65: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for message-oriented middleware. The defining features of AMQP are message orientation, queuing, routing (including point-to-point and publish-and-subscribe), reliability and security.

AMQP

Page 66: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

To become the standard protocol for interoperability between all messaging

middleware

AMQP

Page 67: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

PluginsManagement

• Gerenciamento• Configuração• Monitoramento

STOMP/ MQTT• Integrações utilizando outros protocolos de comunicação

Federation / Shovel• Configuração de cluster em redes não confiáveis

Page 68: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Características do RabbitMQ• Queue• Consumer

• Public/Subscriber• Exchange• Channel• Persitent

• Durável / Transiente• Atomicidade• Round-Robin• Acknolodge

• Ack/Nack• TTL (Time to Live)

Page 69: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Tipos de fila do RabbitMQ

• Basic• Work• Topic• Route• Fanout• RPC

Page 70: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Basic - RabbitMQ

P – ProducerC – ConsumerQueue in Red

The simplest thing that does something

Page 71: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Work - RabbitMQ

Distributing tasks among workers

Automatic - Round-Robin

Page 72: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Publish/Subscribe (FanOut)- RabbitMQ

Sending messages to many consumers at once

Exchange Types: direct, topic, headers and fanoutchannel.exchange_declare(exchange='direct_logs', type=‘fanout')

Page 73: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Routing - RabbitMQ

Receiving messages selectivelychannel.exchange_declare(exchange='direct_logs', type='direct')channel.basic_publish(exchange='direct_logs', routing_key=severity, body=message)

Page 74: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Topics - RabbitMQ

Receiving messages based on a patternchannel.exchange_declare(exchange='direct_logs',

type=‘topic')

Page 75: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

RPC Async WorkFlow - RabbitMQ

Remote procedure call implementationDefine properties: CorrelationId and ReplyTo (QueueName to reply

message)

Page 76: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Install Client - RabbitMQ{ "require": { "php-amqplib/php-amqplib": "2.5.*" }}

$composer install or update

Tutorial: https://www.rabbitmq.com/tutorials/

Page 77: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

API de Autorização { Stack }

Repositório de código: • https://github.com/alexandrebl• https://

github.com/alexandrebl/IMastersPHPExp2016

Page 78: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

• NoSQL• Cache de dados• Dicionário (Chave/Valor)• Dados em memória• Persistência como opção• Stand Alone• Cluster• Replicação• Redis-cli• Redis Manager

• NoSQL• Json Format Data• Dados em disco• Stand Alone• Shard• Replica• Mongo Shell• RoboMongo• MongoChef

• PHP Framework• MVC• Open-source• REST API• Event/handle• Console• Composer

Page 79: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Fluxo da API de Autorização

Page 80: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Sending message with PHP

require_once __DIR__ . '/vendor/autoload.php';use PhpAmqpLib\Connection\AMQPStreamConnection;use PhpAmqpLib\Message\AMQPMessage;

$connection = new AMQPStreamConnection('localhost', 5672, 'guest',

'guest');$channel = $connection->channel();

Page 81: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Sending message with PHP

$channel->queue_declare('hello', false, false, false, false);

$msg = new AMQPMessage('Hello World!');$channel->basic_publish($msg, '', 'hello');

$channel->close();$connection->close();

Page 82: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Receiving message with PHP$callback = function($msg) { echo " [x] Received ", $msg->body, "\n"; };

$channel->basic_consume('hello', '', false, true, false, false, $callback);

while(count($channel->callbacks)) { $channel->wait();}

Page 83: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Sending message with C# .Netusing RabbitMQ.Client;

var factory = new ConnectionFactory() { HostName = "localhost"

};

using(var connection = factory.CreateConnection())using(var channel = connection.CreateModel()){ }

Page 84: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Sending message with C# .Netchannel.QueueDeclare(

queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);

Page 85: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Sending message with C# .Netvar body = Encoding.UTF8.GetBytes(message);

channel.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: body);

Page 86: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

RabbitMQ - Tutoriaishttps://www.rabbitmq.com/getstarted.html

Page 87: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

RabbitMQ – Curso on-linehttps://www.pluralsight.com/courses/rabbitmq-dotnet-developers

Page 88: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

RabbitMQ Manager• Free• Gestão de objetos

• Queue• Exchange• Channels• Routing

• Taxa de tranferência• Simulação• Recursos de hardware

Page 89: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Cloud AMPQ based on RabbitMQ

https://www.cloudamqp.com/

Page 90: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Instalação do RabbitMQ Manager

rabbitmq-plugins enable rabbitmq_management

http://server-name:15672/

Page 91: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Azure Service Bus

Page 92: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Azure Service Bus Documentation

Page 93: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Azure Service Bus

•Queue•Notification Services

•Service Bus Pipeline

• IoT Hub Messaging•Dashboard Admin

Page 94: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Microsoft Azure Service Bus Manager

Page 95: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

{Seja hoje uma pessoa

melhor do que você foi ontem

}

Page 96: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Pesquise...

Page 97: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Pesquise...Estude...

Page 98: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Pesquise...Estude...

Domine...

Page 99: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Pesquise...Estude...

Influencie...

Domine...

Page 100: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Alexandre Brandão

Twitter: @abrandaolustosaE-mail: [email protected]: +55 (21) 97367-6161

https://br.linkedin.com/in/abrandaolObrigado :)

Linkedin: abrandaol

https://github.com/alexandrebl

Page 101: IoT Service Bus - High availability with Internet of Things (IoT)/ API Rest/ Message Broker

Alexandre Brandão

Twitter: @abrandaolustosaE-mail: [email protected]: +55 (21) 97367-6161

https://github.com/alexandrebl

Perguntas?

Linkedin: abrandaol

https://br.linkedin.com/in/abrandaol