PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

49
PHP with ServiceBus Desacoplamento de Workflows com serviços de barramento utilizando RabbitMQ

Transcript of PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Page 1: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

PHP with ServiceBus

Desacoplamento de Workflows com serviços de barramento utilizando RabbitMQ

Page 2: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016
Page 3: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016
Page 4: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

40% Market Share

Plataforma de Pagamento

Page 5: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Nosso ecossistema

Ecossistema DLP

ONLINE

ADQUIRENTE

GATEWAY DE PAGAMENTOS

TEF / GATEWAY OFFLINE

PROCESSADORA

Pagar.me

Page 6: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Nossos clientes

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 7: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

www.mundipagg.com

Page 8: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 9: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Quer jogar?

Page 10: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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

Page 11: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

{ Seja criativo!! :) =)

Page 12: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Quer um café?

Page 13: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016
Page 14: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 15: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Vamos dominar o mundo!!!!

Page 16: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 17: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 18: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 TIAnalista Desenvolvedor Sênior

Arquiteto de Sistemas

/* Linkedin: abrandaol*/

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

Page 19: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Service BUS

Page 20: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

“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 21: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Integraçãode

Sistemas

Page 22: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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

“Repense sua arquitetura”

Page 23: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Recursos

Page 24: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Pipeline – Service Bus

Page 25: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

{ Soluções – Service Bus }

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

Page 26: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 27: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

RabbitMQ - SDKs

C# .Net PHP

JavaRuby

ErlangPerl

Javascript

GoPython

Scala

Haskell

Page 28: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 29: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

To become the standard protocol for interoperability between all messaging

middleware

AMQP

Page 30: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 31: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 32: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Tipos de fila do RabbitMQ

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

Page 33: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Basic - RabbitMQ

P – ProducerC – ConsumerQueue in Red

The simplest thing that does something

Page 34: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Work - RabbitMQ

Distributing tasks among workers

Automatic - Round-Robin

Page 35: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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 36: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Routing - RabbitMQ

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

Page 37: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Topics - RabbitMQ

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

type=‘topic')

Page 38: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

RPC Async WorkFlow - RabbitMQ

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

message)

Page 39: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

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

$composer install or update

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

Page 40: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

API de Autorização{ Stack }

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

Page 41: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

• 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 42: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Fluxo da API de Autorização

Page 43: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

{Seja hoje uma pessoa

melhor do que você foi ontem

}

Page 44: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Pesquise...

Page 45: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Pesquise...Estude...

Page 46: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Pesquise...Estude...

Domine...

Page 47: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Pesquise...Estude...

Influencie...

Domine...

Page 48: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Alexandre Brandão

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

https://github.com/alexandrebl

Obrigado :)

Linkedin: abrandaol

Page 49: PHP with Service BUS (RabbitMQ/Redis/MongoDB) - IMasters PHP Experience 2016

Alexandre Brandão

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

https://github.com/alexandrebl

Perguntas?

Linkedin: abrandaol