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

왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요Jo Hoon
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with AnsibleAnas
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
Kolla talk at OpenStack Summit 2017 in Sydney
Kolla talk at OpenStack Summit 2017 in SydneyKolla talk at OpenStack Summit 2017 in Sydney
Kolla talk at OpenStack Summit 2017 in SydneyVikram G Hosakote
 
Docker Architecture (v1.3)
Docker Architecture (v1.3)Docker Architecture (v1.3)
Docker Architecture (v1.3)rajdeep
 
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdfOpen Source Consulting
 
Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...
Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...
Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...Vietnam Open Infrastructure User Group
 
Deep Dive into Kubernetes - Part 1
Deep Dive into Kubernetes - Part 1Deep Dive into Kubernetes - Part 1
Deep Dive into Kubernetes - Part 1Imesh Gunaratne
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking OverviewSreenivas Makam
 
Understanding Open vSwitch
Understanding Open vSwitch Understanding Open vSwitch
Understanding Open vSwitch YongKi Kim
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationSuresh Kumar
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansibleGeorge Shuklin
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to KubernetesImesh Gunaratne
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?OpenStack Korea Community
 
Introduction to docker swarm
Introduction to docker swarmIntroduction to docker swarm
Introduction to docker swarmWalid Ashraf
 

What's hot (20)

왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
왜 쿠버네티스는 systemd로 cgroup을 관리하려고 할까요
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
Network Automation with Ansible
Network Automation with AnsibleNetwork Automation with Ansible
Network Automation with Ansible
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Kolla talk at OpenStack Summit 2017 in Sydney
Kolla talk at OpenStack Summit 2017 in SydneyKolla talk at OpenStack Summit 2017 in Sydney
Kolla talk at OpenStack Summit 2017 in Sydney
 
kubernetes, pourquoi et comment
kubernetes, pourquoi et commentkubernetes, pourquoi et comment
kubernetes, pourquoi et comment
 
Docker Architecture (v1.3)
Docker Architecture (v1.3)Docker Architecture (v1.3)
Docker Architecture (v1.3)
 
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf
[오픈테크넷서밋2022] 국내 PaaS(Kubernetes) Best Practice 및 DevOps 환경 구축 사례.pdf
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...
Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...
Room 1 - 7 - Lê Quốc Đạt - Upgrading network of Openstack to SDN with Tungste...
 
Deep Dive into Kubernetes - Part 1
Deep Dive into Kubernetes - Part 1Deep Dive into Kubernetes - Part 1
Deep Dive into Kubernetes - Part 1
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking Overview
 
Understanding Open vSwitch
Understanding Open vSwitch Understanding Open vSwitch
Understanding Open vSwitch
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
 
Neutron packet logging framework
Neutron packet logging frameworkNeutron packet logging framework
Neutron packet logging framework
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Introduction to docker swarm
Introduction to docker swarmIntroduction to docker swarm
Introduction to docker swarm
 

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

Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
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.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
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
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
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
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
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
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

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