SlideShare a Scribd company logo
1 of 26
Oslo messaging
Oslo messaging RPC API
Main Components
● Transport
● Executors
● Target
● RPC Server
● RPC Client
Doc http://docs.openstack.org/developer/oslo.messaging/
Transport
from oslo.config import cfg
import oslo.messaging as om
cfg.CONF.set_override('rabbit_host', '192.168.56.101')
cfg.CONF.set_override('rabbit_port', 5672)
cfg.CONF.set_override('rabbit_userid', 'guest')
cfg.CONF.set_override('rabbit_password', 'cloud')
cfg.CONF.set_override('rabbit_login_method', 'AMQPLAIN')
cfg.CONF.set_override('rabbit_virtual_host', '/')
cfg.CONF.set_override('rpc_backend', 'rabbit')
transport = om.get_transport(cfg.CONF)
* This method will construct a Transport object from transport configuration
collected from the user’s configuration
OpenStack Training Videos
Play Training Videos
https://www.youtube.com/user/sajuptpm/videos
Executors
Executors are providing the way an incoming message will be
dispatched so that the message can be used for meaningful
work. Different types of executors are supported, each with its
own set of restrictions and capabilities.
Target
* A Target encapsulates all the information to identify where a message should
be sent or what messages a server is listening for.
from oslo.config import cfg
import oslo.messaging as om
a)
Target Setup for creating a server:
* topic and server is required; exchange is optional
target = om.Target(topic='testme', server='192.168.56.102')
b)
Endpoint’s Target
* namespace and version is optional
c)
Target Setup for the client to sending a message:
* topic is required, all other attributes optional
target = om.Target(topic='testme')
RPC Server
An RPC server exposes a number of endpoints, each of which contain a set of
methods which may be invoked remotely by clients over a given transport.
To create an RPC server, you supply a transport, target and a list of endpoints.
from oslo.config import cfg
import oslo.messaging as om
##Create transport and target
transport = om.get_transport(cfg.CONF)
target = om.Target(topic='testme', server='192.168.56.102')
##Create EndPoints
class TestEndpoint(object):
def test_method1(self, ctx, arg):
return arg
endpoints = [TestEndpoint(),]
##Create RPC Server
server = om.get_rpc_server(transport, target, endpoints,
executor='blocking')
RPC Client
The RPCClient class is responsible for sending method invocations to remote
servers via a messaging transport.
A method invocation consists of a request context dictionary, a method name
and a dictionary of arguments. A cast() invocation just sends the request and
returns immediately. A call() invocation waits for the server to send a return
value.
##Create Messaging Transport and Target
transport = om.get_transport(cfg.CONF)
target = om.Target(topic='testme')
##Create RPC Client
client = om.RPCClient(transport, target)
##Invoke remote method and wait for a reply. (call)
arg = "Saju"
ctxt = {}
client.call(ctxt, 'test_method1', arg=arg)
##Invoke remote method and return immediately. (cast)
client.cast(ctxt, 'test_method1', arg=arg)
Demo
https://www.youtube.com/watch?v=Bf4gkeoBzvA
Demo Setup
● RabbitMQ Server (192.168.56.101)
● RPC Server–1 (192.168.56.102)
● RPC Server–2 (192.168.56.103)
● RPC Client (192.168.56.104)
RabbitMQ Server (192.168.56.101)
*How ro restart rabbitmq-server
#sudo /etc/init.d/rabbitmq-server restart
* How to list all queues
#sudo rabbitmqctl list_queues
* How to list all queues and grep
#sudo rabbitmqctl list_queues | grep testme
RPC Server–1 (192.168.56.102)
from pprint import pprint
from oslo.config import cfg
import oslo.messaging as om
##Invoke "get_transport". This call will set default Configurations required to
Create Messaging Transport
transport = om.get_transport(cfg.CONF)
##Set/Override Configurations required to Create Messaging Transport
cfg.CONF.set_override('rabbit_host', '192.168.56.101')
cfg.CONF.set_override('rabbit_port', 5672)
cfg.CONF.set_override('rabbit_userid', 'guest')
cfg.CONF.set_override('rabbit_password', 'cloud')
cfg.CONF.set_override('rabbit_login_method', 'AMQPLAIN')
cfg.CONF.set_override('rabbit_virtual_host', '/')
cfg.CONF.set_override('rpc_backend', 'rabbit')
##Check the Configurations
res = [{k:v} for k, v in cfg.CONF.iteritems()]
pprint(res)
RPC Server–1 (192.168.56.102) Conti....
##Create Messaging Transport
transport = om.get_transport(cfg.CONF)
##Create Target (Exchange, Topic and Server to listen on)
target = om.Target(topic='testme', server='192.168.56.102')
##Create EndPoint
class TestEndpoint(object):
def test_method1(self, ctx, arg):
res = "Result from test_method1 " + str(arg)
print res
return res
def test_method2(self, ctx, arg):
res = "Result from test_method2 " + str(arg)
print res
return res
##Create EndPoint List
endpoints = [TestEndpoint(),]
RPC Server–1 (192.168.56.102) Conti....
##Create RPC Server
server = om.get_rpc_server(transport, target, endpoints, executor='blocking')
##Start RPC Server
server.start()
RPC Server–2 (192.168.56.103)
* Use the same code which used in RPC Server-1 and change server of the
Target to 192.168.56.103
##Create Target (Exchange, Topic and Server to listen on)
target = om.Target(topic='testme', server='192.168.56.103')
RPC Client (192.168.56.104)
from pprint import pprint
from oslo.config import cfg
import oslo.messaging as om
##Invoke "get_transport". This call will set default Configurations required to
Create Messaging Transport
transport = om.get_transport(cfg.CONF)
##Set Configurations required to Create Messaging Transport
cfg.CONF.set_override('rabbit_host', '192.168.56.101')
cfg.CONF.set_override('rabbit_port', 5672)
cfg.CONF.set_override('rabbit_userid', 'guest')
cfg.CONF.set_override('rabbit_password', 'cloud')
cfg.CONF.set_override('rabbit_login_method', 'AMQPLAIN')
cfg.CONF.set_override('rabbit_virtual_host', '/')
cfg.CONF.set_override('rpc_backend', 'rabbit')
##Check Configurations
res = [{k:v} for k, v in cfg.CONF.iteritems()]
pprint(res)
RPC Client (192.168.56.104) Conti...
##Create Messaging Transport
transport = om.get_transport(cfg.CONF)
##Create Target
target = om.Target(topic='testme')
##Create RPC Client
client = om.RPCClient(transport, target)
##Invoke remote method and wait for a reply. (call)
arg = "Saju"
ctxt = {}
client.call(ctxt, 'test_method1', arg=arg)
##Invoke remote method and return immediately. (cast)
client.cast(ctxt, 'test_method1', arg=arg)
RPC Client – Call, Cast and Fanout
● RPC Call
● RPC Cast
● Client send request to Specific Server
● Client send request to one of the servers in a
round-robin fashion
● Client send request to all the servers. (fanout)
RPC Call and Cast
##Create Target
target = om.Target(topic='testme')
##Create RPC Client
client = om.RPCClient(transport, target)
##RPC Call
ctxt = {}
for x in range(10):
client.call(ctxt, 'test_method1', arg=x)
##RPC Cast
ctxt ={}
for x in range(10):
client.cast(ctxt, 'test_method1', arg=x)
Client send request to Specific Server
##Create Target and specify the server where you want to send the request
target = om.Target(topic='testme', server='192.168.56.102')
##Create RPC Client
client = om.RPCClient(transport, target)
##RPC call
ctxt = {}
for x in range(10):
client.call(ctxt, 'test_method1', arg=x)
##RPC cast
ctxt = {}
for x in range(10):
client.cast(ctxt, 'test_method1', arg=x)
Client send request to one of the servers in a
round-robin fashion
##Create Target without any specific server
target = om.Target(topic='testme')
##Create RPC Client
client = om.RPCClient(transport, target)
##RPC Call
ctxt = {}
for x in range(10):
client.call(ctxt, 'test_method1', arg=x)
##RPC Cast
ctxt = {}
for x in range(10):
client.cast(ctxt, 'test_method1', arg=x)
Client send request to all the servers.
(fanout)
##Create Target and set fanout = True
target = om.Target(topic='testme', fanout=True)
##Create RPC Client
client = om.RPCClient(transport, target)
##RPC Call (Will not Support)
ctxt = {}
for x in range(10):
client.call(ctxt, 'test_method1', arg=x)
##RPC Cast. Fanout works with only RPC Cast.
ctxt = {}
for x in range(10):
client.cast(ctxt, 'test_method1', arg=x)
Oslo Config
An OpenStack library for parsing configuration
options from the command line and configuration
files.
http://docs.openstack.org/developer/oslo.config/
How to print all configurations
from pprint import pprint
from oslo.config import cfg
res = [{k:v} for k, v in cfg.CONF.iteritems()]
pprint(res)
How to register/unregister/override an option
in configuration
from pprint import pprint
from oslo.config import cfg
##Register
opts = [cfg.StrOpt('api_server_ip', default='127.0.0.1', help=""),]
cfg.CONF.register_opts(opts)
OR
cfg.CONF.register_opt(cfg.StrOpt('api_server_ip', default='127.0.0.1', help=""))
##Unregister
opts = [cfg.StrOpt('api_server_ip', default='127.0.0.1', help=""),]
cfg.CONF.unregister_opts(opts)
OR
cfg.CONF.unregister_opt(cfg.StrOpt('api_server_ip', default='127.0.0.1',
help=""))
##Override
cfg.CONF.set_override('transport_url', None)
Thanks
● Email: sajuptpm@gmail.com
● Training Videos: https://www.youtube.com/user/sajuptpm/videos
● WebSite: http://fosshelp.blogspot.in
● IRC: saju_m
● Skype: sajuptpm

More Related Content

What's hot

Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
Introduction to Nginx
Introduction to NginxIntroduction to Nginx
Introduction to NginxKnoldus Inc.
 
Troubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationTroubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationAlexey Lesovsky
 
Linux-HA with Pacemaker
Linux-HA with PacemakerLinux-HA with Pacemaker
Linux-HA with PacemakerKris Buytaert
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기NeoClova
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance TuningPuneet Behl
 
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법Open Source Consulting
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
Ceph and RocksDB
Ceph and RocksDBCeph and RocksDB
Ceph and RocksDBSage Weil
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINXNGINX, Inc.
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PGConf APAC
 
Introduction to Prometheus
Introduction to PrometheusIntroduction to Prometheus
Introduction to PrometheusJulien Pivotto
 
Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Ji-Woong Choi
 
Fluentd and Kafka
Fluentd and KafkaFluentd and Kafka
Fluentd and KafkaN Masahiro
 
ProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewRené Cannaò
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQLJoel Brewer
 

What's hot (20)

Nginx
NginxNginx
Nginx
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Introduction to Nginx
Introduction to NginxIntroduction to Nginx
Introduction to Nginx
 
InnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick FiguresInnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick Figures
 
Troubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationTroubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming Replication
 
Linux-HA with Pacemaker
Linux-HA with PacemakerLinux-HA with Pacemaker
Linux-HA with Pacemaker
 
Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기Maria db 이중화구성_고민하기
Maria db 이중화구성_고민하기
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교  및 구축 방법
[오픈소스컨설팅] 쿠버네티스와 쿠버네티스 on 오픈스택 비교 및 구축 방법
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
Ceph and RocksDB
Ceph and RocksDBCeph and RocksDB
Ceph and RocksDB
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINX
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
 
Introduction to Prometheus
Introduction to PrometheusIntroduction to Prometheus
Introduction to Prometheus
 
Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드
 
Fluentd and Kafka
Fluentd and KafkaFluentd and Kafka
Fluentd and Kafka
 
ProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management Overview
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQL
 
Airflow for Beginners
Airflow for BeginnersAirflow for Beginners
Airflow for Beginners
 

Viewers also liked

JTF2016 The strategy and Sun Tzu
JTF2016 The strategy and Sun TzuJTF2016 The strategy and Sun Tzu
JTF2016 The strategy and Sun Tzuirix_jp
 
Hot の書き方(Template Version 2015-04-30) 前編
Hot の書き方(Template Version 2015-04-30) 前編Hot の書き方(Template Version 2015-04-30) 前編
Hot の書き方(Template Version 2015-04-30) 前編irix_jp
 
JOSUG Meetup 28th Heat 101
JOSUG Meetup 28th Heat 101JOSUG Meetup 28th Heat 101
JOSUG Meetup 28th Heat 101irix_jp
 
How to Troubleshoot OpenStack Without Losing Sleep
How to Troubleshoot OpenStack Without Losing SleepHow to Troubleshoot OpenStack Without Losing Sleep
How to Troubleshoot OpenStack Without Losing SleepSadique Puthen
 
2014 OpenStack Summit - Neutron OVS to LinuxBridge Migration
2014 OpenStack Summit - Neutron OVS to LinuxBridge Migration2014 OpenStack Summit - Neutron OVS to LinuxBridge Migration
2014 OpenStack Summit - Neutron OVS to LinuxBridge MigrationJames Denton
 

Viewers also liked (7)

DevStack
DevStackDevStack
DevStack
 
JTF2016 The strategy and Sun Tzu
JTF2016 The strategy and Sun TzuJTF2016 The strategy and Sun Tzu
JTF2016 The strategy and Sun Tzu
 
RabbitMQ Operations
RabbitMQ OperationsRabbitMQ Operations
RabbitMQ Operations
 
Hot の書き方(Template Version 2015-04-30) 前編
Hot の書き方(Template Version 2015-04-30) 前編Hot の書き方(Template Version 2015-04-30) 前編
Hot の書き方(Template Version 2015-04-30) 前編
 
JOSUG Meetup 28th Heat 101
JOSUG Meetup 28th Heat 101JOSUG Meetup 28th Heat 101
JOSUG Meetup 28th Heat 101
 
How to Troubleshoot OpenStack Without Losing Sleep
How to Troubleshoot OpenStack Without Losing SleepHow to Troubleshoot OpenStack Without Losing Sleep
How to Troubleshoot OpenStack Without Losing Sleep
 
2014 OpenStack Summit - Neutron OVS to LinuxBridge Migration
2014 OpenStack Summit - Neutron OVS to LinuxBridge Migration2014 OpenStack Summit - Neutron OVS to LinuxBridge Migration
2014 OpenStack Summit - Neutron OVS to LinuxBridge Migration
 

Similar to OpenStack Oslo Messaging RPC API Tutorial Demo Call, Cast and Fanout

Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesWSO2
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCTim Burks
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
Finagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvmFinagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvmPrasannaKumar Sathyanarayanan
 
Flux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixFlux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixInfluxData
 
Distributes objects and Rmi
Distributes objects and RmiDistributes objects and Rmi
Distributes objects and RmiMayank Jain
 
Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Fwdays
 
Router Queue Simulation in C++ in MMNN and MM1 conditions
Router Queue Simulation in C++ in MMNN and MM1 conditionsRouter Queue Simulation in C++ in MMNN and MM1 conditions
Router Queue Simulation in C++ in MMNN and MM1 conditionsMorteza Mahdilar
 
Writing Redis in Python with asyncio
Writing Redis in Python with asyncioWriting Redis in Python with asyncio
Writing Redis in Python with asyncioJames Saryerwinnie
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The LandingHaci Murat Yaman
 
The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184Mahmoud Samir Fayed
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
InfluxData Platform Future and Vision
InfluxData Platform Future and VisionInfluxData Platform Future and Vision
InfluxData Platform Future and VisionInfluxData
 

Similar to OpenStack Oslo Messaging RPC API Tutorial Demo Call, Cast and Fanout (20)

Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPC
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
Finagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvmFinagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvm
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
EN-04 (1).pptx
EN-04 (1).pptxEN-04 (1).pptx
EN-04 (1).pptx
 
Switch to Backend 2023 | Day 1 Part 2
Switch to Backend 2023 | Day 1 Part 2Switch to Backend 2023 | Day 1 Part 2
Switch to Backend 2023 | Day 1 Part 2
 
Pycon - Python for ethical hackers
Pycon - Python for ethical hackers Pycon - Python for ethical hackers
Pycon - Python for ethical hackers
 
Flux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul DixFlux and InfluxDB 2.0 by Paul Dix
Flux and InfluxDB 2.0 by Paul Dix
 
Distributes objects and Rmi
Distributes objects and RmiDistributes objects and Rmi
Distributes objects and Rmi
 
Rpc mechanism
Rpc mechanismRpc mechanism
Rpc mechanism
 
Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"Anton Moldovan "Load testing which you always wanted"
Anton Moldovan "Load testing which you always wanted"
 
Router Queue Simulation in C++ in MMNN and MM1 conditions
Router Queue Simulation in C++ in MMNN and MM1 conditionsRouter Queue Simulation in C++ in MMNN and MM1 conditions
Router Queue Simulation in C++ in MMNN and MM1 conditions
 
Writing Redis in Python with asyncio
Writing Redis in Python with asyncioWriting Redis in Python with asyncio
Writing Redis in Python with asyncio
 
Npc08
Npc08Npc08
Npc08
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The Landing
 
The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184The Ring programming language version 1.5.3 book - Part 91 of 184
The Ring programming language version 1.5.3 book - Part 91 of 184
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
InfluxData Platform Future and Vision
InfluxData Platform Future and VisionInfluxData Platform Future and Vision
InfluxData Platform Future and Vision
 

Recently uploaded

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 

Recently uploaded (20)

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 

OpenStack Oslo Messaging RPC API Tutorial Demo Call, Cast and Fanout

  • 2. Main Components ● Transport ● Executors ● Target ● RPC Server ● RPC Client Doc http://docs.openstack.org/developer/oslo.messaging/
  • 3. Transport from oslo.config import cfg import oslo.messaging as om cfg.CONF.set_override('rabbit_host', '192.168.56.101') cfg.CONF.set_override('rabbit_port', 5672) cfg.CONF.set_override('rabbit_userid', 'guest') cfg.CONF.set_override('rabbit_password', 'cloud') cfg.CONF.set_override('rabbit_login_method', 'AMQPLAIN') cfg.CONF.set_override('rabbit_virtual_host', '/') cfg.CONF.set_override('rpc_backend', 'rabbit') transport = om.get_transport(cfg.CONF) * This method will construct a Transport object from transport configuration collected from the user’s configuration
  • 4. OpenStack Training Videos Play Training Videos https://www.youtube.com/user/sajuptpm/videos
  • 5. Executors Executors are providing the way an incoming message will be dispatched so that the message can be used for meaningful work. Different types of executors are supported, each with its own set of restrictions and capabilities.
  • 6. Target * A Target encapsulates all the information to identify where a message should be sent or what messages a server is listening for. from oslo.config import cfg import oslo.messaging as om a) Target Setup for creating a server: * topic and server is required; exchange is optional target = om.Target(topic='testme', server='192.168.56.102') b) Endpoint’s Target * namespace and version is optional c) Target Setup for the client to sending a message: * topic is required, all other attributes optional target = om.Target(topic='testme')
  • 7. RPC Server An RPC server exposes a number of endpoints, each of which contain a set of methods which may be invoked remotely by clients over a given transport. To create an RPC server, you supply a transport, target and a list of endpoints. from oslo.config import cfg import oslo.messaging as om ##Create transport and target transport = om.get_transport(cfg.CONF) target = om.Target(topic='testme', server='192.168.56.102') ##Create EndPoints class TestEndpoint(object): def test_method1(self, ctx, arg): return arg endpoints = [TestEndpoint(),] ##Create RPC Server server = om.get_rpc_server(transport, target, endpoints, executor='blocking')
  • 8. RPC Client The RPCClient class is responsible for sending method invocations to remote servers via a messaging transport. A method invocation consists of a request context dictionary, a method name and a dictionary of arguments. A cast() invocation just sends the request and returns immediately. A call() invocation waits for the server to send a return value. ##Create Messaging Transport and Target transport = om.get_transport(cfg.CONF) target = om.Target(topic='testme') ##Create RPC Client client = om.RPCClient(transport, target) ##Invoke remote method and wait for a reply. (call) arg = "Saju" ctxt = {} client.call(ctxt, 'test_method1', arg=arg) ##Invoke remote method and return immediately. (cast) client.cast(ctxt, 'test_method1', arg=arg)
  • 10. Demo Setup ● RabbitMQ Server (192.168.56.101) ● RPC Server–1 (192.168.56.102) ● RPC Server–2 (192.168.56.103) ● RPC Client (192.168.56.104)
  • 11. RabbitMQ Server (192.168.56.101) *How ro restart rabbitmq-server #sudo /etc/init.d/rabbitmq-server restart * How to list all queues #sudo rabbitmqctl list_queues * How to list all queues and grep #sudo rabbitmqctl list_queues | grep testme
  • 12. RPC Server–1 (192.168.56.102) from pprint import pprint from oslo.config import cfg import oslo.messaging as om ##Invoke "get_transport". This call will set default Configurations required to Create Messaging Transport transport = om.get_transport(cfg.CONF) ##Set/Override Configurations required to Create Messaging Transport cfg.CONF.set_override('rabbit_host', '192.168.56.101') cfg.CONF.set_override('rabbit_port', 5672) cfg.CONF.set_override('rabbit_userid', 'guest') cfg.CONF.set_override('rabbit_password', 'cloud') cfg.CONF.set_override('rabbit_login_method', 'AMQPLAIN') cfg.CONF.set_override('rabbit_virtual_host', '/') cfg.CONF.set_override('rpc_backend', 'rabbit') ##Check the Configurations res = [{k:v} for k, v in cfg.CONF.iteritems()] pprint(res)
  • 13. RPC Server–1 (192.168.56.102) Conti.... ##Create Messaging Transport transport = om.get_transport(cfg.CONF) ##Create Target (Exchange, Topic and Server to listen on) target = om.Target(topic='testme', server='192.168.56.102') ##Create EndPoint class TestEndpoint(object): def test_method1(self, ctx, arg): res = "Result from test_method1 " + str(arg) print res return res def test_method2(self, ctx, arg): res = "Result from test_method2 " + str(arg) print res return res ##Create EndPoint List endpoints = [TestEndpoint(),]
  • 14. RPC Server–1 (192.168.56.102) Conti.... ##Create RPC Server server = om.get_rpc_server(transport, target, endpoints, executor='blocking') ##Start RPC Server server.start()
  • 15. RPC Server–2 (192.168.56.103) * Use the same code which used in RPC Server-1 and change server of the Target to 192.168.56.103 ##Create Target (Exchange, Topic and Server to listen on) target = om.Target(topic='testme', server='192.168.56.103')
  • 16. RPC Client (192.168.56.104) from pprint import pprint from oslo.config import cfg import oslo.messaging as om ##Invoke "get_transport". This call will set default Configurations required to Create Messaging Transport transport = om.get_transport(cfg.CONF) ##Set Configurations required to Create Messaging Transport cfg.CONF.set_override('rabbit_host', '192.168.56.101') cfg.CONF.set_override('rabbit_port', 5672) cfg.CONF.set_override('rabbit_userid', 'guest') cfg.CONF.set_override('rabbit_password', 'cloud') cfg.CONF.set_override('rabbit_login_method', 'AMQPLAIN') cfg.CONF.set_override('rabbit_virtual_host', '/') cfg.CONF.set_override('rpc_backend', 'rabbit') ##Check Configurations res = [{k:v} for k, v in cfg.CONF.iteritems()] pprint(res)
  • 17. RPC Client (192.168.56.104) Conti... ##Create Messaging Transport transport = om.get_transport(cfg.CONF) ##Create Target target = om.Target(topic='testme') ##Create RPC Client client = om.RPCClient(transport, target) ##Invoke remote method and wait for a reply. (call) arg = "Saju" ctxt = {} client.call(ctxt, 'test_method1', arg=arg) ##Invoke remote method and return immediately. (cast) client.cast(ctxt, 'test_method1', arg=arg)
  • 18. RPC Client – Call, Cast and Fanout ● RPC Call ● RPC Cast ● Client send request to Specific Server ● Client send request to one of the servers in a round-robin fashion ● Client send request to all the servers. (fanout)
  • 19. RPC Call and Cast ##Create Target target = om.Target(topic='testme') ##Create RPC Client client = om.RPCClient(transport, target) ##RPC Call ctxt = {} for x in range(10): client.call(ctxt, 'test_method1', arg=x) ##RPC Cast ctxt ={} for x in range(10): client.cast(ctxt, 'test_method1', arg=x)
  • 20. Client send request to Specific Server ##Create Target and specify the server where you want to send the request target = om.Target(topic='testme', server='192.168.56.102') ##Create RPC Client client = om.RPCClient(transport, target) ##RPC call ctxt = {} for x in range(10): client.call(ctxt, 'test_method1', arg=x) ##RPC cast ctxt = {} for x in range(10): client.cast(ctxt, 'test_method1', arg=x)
  • 21. Client send request to one of the servers in a round-robin fashion ##Create Target without any specific server target = om.Target(topic='testme') ##Create RPC Client client = om.RPCClient(transport, target) ##RPC Call ctxt = {} for x in range(10): client.call(ctxt, 'test_method1', arg=x) ##RPC Cast ctxt = {} for x in range(10): client.cast(ctxt, 'test_method1', arg=x)
  • 22. Client send request to all the servers. (fanout) ##Create Target and set fanout = True target = om.Target(topic='testme', fanout=True) ##Create RPC Client client = om.RPCClient(transport, target) ##RPC Call (Will not Support) ctxt = {} for x in range(10): client.call(ctxt, 'test_method1', arg=x) ##RPC Cast. Fanout works with only RPC Cast. ctxt = {} for x in range(10): client.cast(ctxt, 'test_method1', arg=x)
  • 23. Oslo Config An OpenStack library for parsing configuration options from the command line and configuration files. http://docs.openstack.org/developer/oslo.config/
  • 24. How to print all configurations from pprint import pprint from oslo.config import cfg res = [{k:v} for k, v in cfg.CONF.iteritems()] pprint(res)
  • 25. How to register/unregister/override an option in configuration from pprint import pprint from oslo.config import cfg ##Register opts = [cfg.StrOpt('api_server_ip', default='127.0.0.1', help=""),] cfg.CONF.register_opts(opts) OR cfg.CONF.register_opt(cfg.StrOpt('api_server_ip', default='127.0.0.1', help="")) ##Unregister opts = [cfg.StrOpt('api_server_ip', default='127.0.0.1', help=""),] cfg.CONF.unregister_opts(opts) OR cfg.CONF.unregister_opt(cfg.StrOpt('api_server_ip', default='127.0.0.1', help="")) ##Override cfg.CONF.set_override('transport_url', None)
  • 26. Thanks ● Email: sajuptpm@gmail.com ● Training Videos: https://www.youtube.com/user/sajuptpm/videos ● WebSite: http://fosshelp.blogspot.in ● IRC: saju_m ● Skype: sajuptpm