SlideShare a Scribd company logo
Message Brokers and
      Python
Python Ireland Meetup - Jun/2012



                            Fernando Ciciliati
                          ciciliati@gmail.com
Contents
    What sort of problems are we trying to solve?
    Messaging concepts
    A solution based on ActiveMQ
    ActiveMQ + Python: STOMP and Stomp.py
    ActiveMQ Queues and Topics
    Other ActiveMQ concepts
    Alternatives to ActiveMQ
        AMQP
        RabbitMQ
        ZeroMQ
        Others
Problems
   Time decoupling
   Scalability / Architecture flexibility
   Technology mix
Concepts
   Producer
   Consumer
   Message
     Control x Data x Hybrid
     Small x Large
     Durability

   Queue
   Message Broker
Apache ActiveMQ
               Disclaimer: Each broker has its own view of the world!

    Apache Project
    Written in Java
    Designed for high performance
    Flexible storage layer
    Multiple communication protocols
    Clustering capabilities
    Very active community -> constant evolution ->
    ... bugs
Apache ActiveMQ
   Web console on port 8161
      let's have a look at it...

   STOMP is not enabled by default
   Configuration: activemq.xml
   Running? Check it with netstat -ltn
ActiveMQ and Python
   Easiest way (IMHO): STOMP
   Libraries
      stomp.py
      stompy
      twisted + stomper/stompest
   Our choice
      stomp.py
STOMP
   Simple (or Streaming) Text Orientated Messaging Protocol.
   in-band (like HTTP or SMTP)
   Headers + body
   Text, not binary
   Simple
       Let's telnet...
stomp.py
   Created by Jason Briggs
   Currently at version 3.x
   Supports Python 2 and Python 3
   Has a CLI !
    let's have a look at it...
More ActiveMQ
   Persistence
   Producer: Receipt
   Consumer: Ack/NoAck
   Exclusive Consumers
   Selectors
   Queues X Topics
   Prefetch
A simple Python producer
   def sendJMS(message, host, queue, port=61613, user='', password='', persistent=True):
       # Size of a buffer for storing MQServer STOMP answers to commands.
       bufsize = 200

      # Establish a TCP connection
      t = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      t.connect ((host, port))

      # Establish a STOMP connection
      frame = 'CONNECTnnx00'
      t.sendall(frame)
      resp = t.recv(bufsize)
      if resp[0:9] != 'CONNECTED':
          print ('sendJMS: Failed to connect to MQ server')
          return 1

      # Send the message
      if persistent:
          persist="true"
      else:
          persist="false"
      frame = 'SENDndestination:%snpersistent:%snn%sx00' % (queue,persist,message)
      t.sendall(frame)

      # Disconnect STOMP
      frame = 'DISCONNECTnnx00'
      t.sendall(frame)

      # Disconnect TCP
      t.close()
      del(t)
      return 0
A simple stomp.py producer
   import time
   import sys

   import stomp

   USAGE = """

      producer.py <destination> <message>

         <destination> should start by /queue or /topic
         <message> is the text to be sent as message body (blank spaces accepted).

   """

   if len(sys.argv) < 3:
       print USAGE
   else:
       conn = stomp.Connection() # with default parameters
       conn.start()
       conn.connect()
       conn.send(' '.join(sys.argv[2:]), destination=sys.argv[1])
       time.sleep(2)
       conn.disconnect()
A simple stomp.py consumer
   import sys
   import time
   import stomp

   class MyListener(object):
       def on_error(self, headers, message):
           print '*** received an error:n%sn***' % message

      def on_message(self, headers, message):
          print '*** received a message:n%sn***' % message


   conn = stomp.Connection()
   conn.set_listener('', MyListener())
   conn.start()
   conn.connect()

   conn.subscribe(destination=sys.argv[1], ack='auto')

   try:
       while True:
            time.sleep(1)
   except KeyboardInterrupt:
       pass
   finally:
       print "nDisconnecting..."
       conn.disconnect()
AMQP
   """
   OUR VISION:

         To become the standard protocol for
         interoperability between all messaging
         middleware
   """

   OASIS working group
RabbitMQ
   Message broker written in Erlang
   Supports AMQP
   Concepts:
     Producers
       Messages
          Exchanges
             Queues
               Consumers
ZeroMQ
  A "brokerless" approach to messaging

  "The Intelligent Transport Layer"
  ØMQ zeromq:
   Ø  The socket library that acts as a concurrency framework.
   Ø  Faster than TCP, for clustered products and supercomputing.
   Ø  Carries messages across inproc, IPC, TCP, and multicast.
   Ø  Connect N-to-N via fanout, pubsub, pipeline, request-reply.
   Ø  Asynch I/O for scalable multicore message-passing apps.
   Ø  Large and active open source community.
   Ø  30+ languages including C, C++, Java, .NET, Python.
   Ø  Most OSes including Linux, Windows, OS X.
   Ø  LGPL free software with full commercial support from iMatix.
  (text from http://www.zeromq.org)
Even more questions?
   :)

   Thanks!
Ad

Recommended

Lindsay distributed geventzmq
Lindsay distributed geventzmq
Robin Xiao
 
Zmq in context of openstack
Zmq in context of openstack
Yatin Kumbhare
 
Overview of ZeroMQ
Overview of ZeroMQ
pieterh
 
ZeroMQ - Sockets on steroids!
ZeroMQ - Sockets on steroids!
Pedro Januário
 
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQ
Robin Xiao
 
Europycon2011: Implementing distributed application using ZeroMQ
Europycon2011: Implementing distributed application using ZeroMQ
fcrippa
 
ZeroMQ in PHP
ZeroMQ in PHP
José Lorenzo Rodríguez Urdaneta
 
FOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQ
pieterh
 
zeromq
zeromq
Rajan Bhatt
 
ZeroMQ
ZeroMQ
Stoyan Zhekov
 
ZeroMQ: Super Sockets - by J2 Labs
ZeroMQ: Super Sockets - by J2 Labs
James Dennis
 
Zeromq anatomy & jeromq
Zeromq anatomy & jeromq
Dongmin Yu
 
sshuttle VPN (2011-04)
sshuttle VPN (2011-04)
apenwarr
 
Introduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalk
Mahmoud Said
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...
Jaap ter Woerds
 
GopherFest 2017 - Adding Context to NATS
GopherFest 2017 - Adding Context to NATS
wallyqs
 
#2 (UDP)
#2 (UDP)
Ghadeer AlHasan
 
Stackless Python In Eve
Stackless Python In Eve
guest91855c
 
Building Netty Servers
Building Netty Servers
Dani Solà Lagares
 
OSMC 2018 | Handling messages and notifications from software and gadgets wit...
OSMC 2018 | Handling messages and notifications from software and gadgets wit...
NETWAYS
 
Netty: asynchronous data transfer
Netty: asynchronous data transfer
Victor Cherkassky
 
Python session.11 By Shanmugam
Python session.11 By Shanmugam
Navaneethan Naveen
 
Kickstart Kotlin
Kickstart Kotlin
Zahidur Rahman Faisal
 
libpcap
libpcap
mohan43u
 
Asynchronous, Event-driven Network Application Development with Netty
Asynchronous, Event-driven Network Application Development with Netty
Ersin Er
 
Apachecon Eu 2008 Mina
Apachecon Eu 2008 Mina
Niklas Gustavsson
 
Java Course Day 11
Java Course Day 11
Oleg Yushchenko
 
OSMC 2014: MQTT for monitoring (and for the lo t) | Jan-Piet Mens
OSMC 2014: MQTT for monitoring (and for the lo t) | Jan-Piet Mens
NETWAYS
 
Message queueing
Message queueing
Richard Jones
 
Message Queueing - by an MQ noob
Message Queueing - by an MQ noob
Richard Jones
 

More Related Content

What's hot (20)

zeromq
zeromq
Rajan Bhatt
 
ZeroMQ
ZeroMQ
Stoyan Zhekov
 
ZeroMQ: Super Sockets - by J2 Labs
ZeroMQ: Super Sockets - by J2 Labs
James Dennis
 
Zeromq anatomy & jeromq
Zeromq anatomy & jeromq
Dongmin Yu
 
sshuttle VPN (2011-04)
sshuttle VPN (2011-04)
apenwarr
 
Introduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalk
Mahmoud Said
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...
Jaap ter Woerds
 
GopherFest 2017 - Adding Context to NATS
GopherFest 2017 - Adding Context to NATS
wallyqs
 
#2 (UDP)
#2 (UDP)
Ghadeer AlHasan
 
Stackless Python In Eve
Stackless Python In Eve
guest91855c
 
Building Netty Servers
Building Netty Servers
Dani Solà Lagares
 
OSMC 2018 | Handling messages and notifications from software and gadgets wit...
OSMC 2018 | Handling messages and notifications from software and gadgets wit...
NETWAYS
 
Netty: asynchronous data transfer
Netty: asynchronous data transfer
Victor Cherkassky
 
Python session.11 By Shanmugam
Python session.11 By Shanmugam
Navaneethan Naveen
 
Kickstart Kotlin
Kickstart Kotlin
Zahidur Rahman Faisal
 
libpcap
libpcap
mohan43u
 
Asynchronous, Event-driven Network Application Development with Netty
Asynchronous, Event-driven Network Application Development with Netty
Ersin Er
 
Apachecon Eu 2008 Mina
Apachecon Eu 2008 Mina
Niklas Gustavsson
 
Java Course Day 11
Java Course Day 11
Oleg Yushchenko
 
OSMC 2014: MQTT for monitoring (and for the lo t) | Jan-Piet Mens
OSMC 2014: MQTT for monitoring (and for the lo t) | Jan-Piet Mens
NETWAYS
 
ZeroMQ: Super Sockets - by J2 Labs
ZeroMQ: Super Sockets - by J2 Labs
James Dennis
 
Zeromq anatomy & jeromq
Zeromq anatomy & jeromq
Dongmin Yu
 
sshuttle VPN (2011-04)
sshuttle VPN (2011-04)
apenwarr
 
Introduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalk
Mahmoud Said
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...
Jaap ter Woerds
 
GopherFest 2017 - Adding Context to NATS
GopherFest 2017 - Adding Context to NATS
wallyqs
 
Stackless Python In Eve
Stackless Python In Eve
guest91855c
 
OSMC 2018 | Handling messages and notifications from software and gadgets wit...
OSMC 2018 | Handling messages and notifications from software and gadgets wit...
NETWAYS
 
Netty: asynchronous data transfer
Netty: asynchronous data transfer
Victor Cherkassky
 
Python session.11 By Shanmugam
Python session.11 By Shanmugam
Navaneethan Naveen
 
Asynchronous, Event-driven Network Application Development with Netty
Asynchronous, Event-driven Network Application Development with Netty
Ersin Er
 
OSMC 2014: MQTT for monitoring (and for the lo t) | Jan-Piet Mens
OSMC 2014: MQTT for monitoring (and for the lo t) | Jan-Piet Mens
NETWAYS
 

Similar to Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati (20)

Message queueing
Message queueing
Richard Jones
 
Message Queueing - by an MQ noob
Message Queueing - by an MQ noob
Richard Jones
 
RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009
Paolo Negri
 
Life in a Queue - Using Message Queue with django
Life in a Queue - Using Message Queue with django
Tareque Hossain
 
High scale flavour
High scale flavour
Tomas Doran
 
The Art of Message Queues - TEKX
The Art of Message Queues - TEKX
Mike Willbanks
 
Inter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message Queues
wamcvey
 
Plone, rabbit mq and messaging that just works
Plone, rabbit mq and messaging that just works
Asko Soukka
 
Zeromq - Pycon India 2013
Zeromq - Pycon India 2013
Srinivasan R
 
Rabbit MQ introduction
Rabbit MQ introduction
Sitg Yao
 
20120521 - zeroMQ
20120521 - zeroMQ
Jamie (Taka) Wang
 
Enterprise Messaging with RabbitMQ.pdf
Enterprise Messaging with RabbitMQ.pdf
Ortus Solutions, Corp
 
The Future of Messaging: RabbitMQ and AMQP
The Future of Messaging: RabbitMQ and AMQP
Eberhard Wolff
 
Message Queues : A Primer - International PHP Conference Fall 2012
Message Queues : A Primer - International PHP Conference Fall 2012
Mike Willbanks
 
Message Queues a basic overview
Message Queues a basic overview
Geshan Manandhar
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
Queue Everything and Please Everyone
Queue Everything and Please Everyone
Vaidik Kapoor
 
Polyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQ
Christian Posta
 
Massaging the Pony: Message Queues and You
Massaging the Pony: Message Queues and You
Shawn Rider
 
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
JAX London
 
Message Queueing - by an MQ noob
Message Queueing - by an MQ noob
Richard Jones
 
RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009
Paolo Negri
 
Life in a Queue - Using Message Queue with django
Life in a Queue - Using Message Queue with django
Tareque Hossain
 
High scale flavour
High scale flavour
Tomas Doran
 
The Art of Message Queues - TEKX
The Art of Message Queues - TEKX
Mike Willbanks
 
Inter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message Queues
wamcvey
 
Plone, rabbit mq and messaging that just works
Plone, rabbit mq and messaging that just works
Asko Soukka
 
Zeromq - Pycon India 2013
Zeromq - Pycon India 2013
Srinivasan R
 
Rabbit MQ introduction
Rabbit MQ introduction
Sitg Yao
 
Enterprise Messaging with RabbitMQ.pdf
Enterprise Messaging with RabbitMQ.pdf
Ortus Solutions, Corp
 
The Future of Messaging: RabbitMQ and AMQP
The Future of Messaging: RabbitMQ and AMQP
Eberhard Wolff
 
Message Queues : A Primer - International PHP Conference Fall 2012
Message Queues : A Primer - International PHP Conference Fall 2012
Mike Willbanks
 
Message Queues a basic overview
Message Queues a basic overview
Geshan Manandhar
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
Queue Everything and Please Everyone
Queue Everything and Please Everyone
Vaidik Kapoor
 
Polyglot Messaging with Apache ActiveMQ
Polyglot Messaging with Apache ActiveMQ
Christian Posta
 
Massaging the Pony: Message Queues and You
Massaging the Pony: Message Queues and You
Shawn Rider
 
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
JAX London
 
Ad

More from Python Ireland (20)

Async I/O in Python
Async I/O in Python
Python Ireland
 
Python Ireland - Who, how, what
Python Ireland - Who, how, what
Python Ireland
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in Python
Python Ireland
 
What's the Scoop with Python 3?
What's the Scoop with Python 3?
Python Ireland
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)
Python Ireland
 
Introduction to Erlang for Python Programmers
Introduction to Erlang for Python Programmers
Python Ireland
 
Web-service based Mobile Geospatial Application Development using Python
Web-service based Mobile Geospatial Application Development using Python
Python Ireland
 
Utopia Kingdoms scaling case. From 4 users to 50.000+
Utopia Kingdoms scaling case. From 4 users to 50.000+
Python Ireland
 
The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environment
Python Ireland
 
Python vs JLizard.... a python logging experience
Python vs JLizard.... a python logging experience
Python Ireland
 
Vim and Python
Vim and Python
Python Ireland
 
Python Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - Appengine
Python Ireland
 
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
Python Ireland
 
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland
 
Python Ireland Nov 2010 - RESTing with Django
Python Ireland Nov 2010 - RESTing with Django
Python Ireland
 
Python Ireland Feb '11 Talks: Introduction to Python
Python Ireland Feb '11 Talks: Introduction to Python
Python Ireland
 
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
Python Ireland
 
Lambada
Lambada
Python Ireland
 
Python for cloud computing
Python for cloud computing
Python Ireland
 
IPython: The awesome python shell
IPython: The awesome python shell
Python Ireland
 
Python Ireland - Who, how, what
Python Ireland - Who, how, what
Python Ireland
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in Python
Python Ireland
 
What's the Scoop with Python 3?
What's the Scoop with Python 3?
Python Ireland
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)
Python Ireland
 
Introduction to Erlang for Python Programmers
Introduction to Erlang for Python Programmers
Python Ireland
 
Web-service based Mobile Geospatial Application Development using Python
Web-service based Mobile Geospatial Application Development using Python
Python Ireland
 
Utopia Kingdoms scaling case. From 4 users to 50.000+
Utopia Kingdoms scaling case. From 4 users to 50.000+
Python Ireland
 
The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environment
Python Ireland
 
Python vs JLizard.... a python logging experience
Python vs JLizard.... a python logging experience
Python Ireland
 
Python Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - Appengine
Python Ireland
 
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
Python Ireland
 
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland
 
Python Ireland Nov 2010 - RESTing with Django
Python Ireland Nov 2010 - RESTing with Django
Python Ireland
 
Python Ireland Feb '11 Talks: Introduction to Python
Python Ireland Feb '11 Talks: Introduction to Python
Python Ireland
 
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
Python Ireland
 
Python for cloud computing
Python for cloud computing
Python Ireland
 
IPython: The awesome python shell
IPython: The awesome python shell
Python Ireland
 
Ad

Recently uploaded (20)

A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 

Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati

  • 1. Message Brokers and Python Python Ireland Meetup - Jun/2012 Fernando Ciciliati [email protected]
  • 2. Contents What sort of problems are we trying to solve? Messaging concepts A solution based on ActiveMQ ActiveMQ + Python: STOMP and Stomp.py ActiveMQ Queues and Topics Other ActiveMQ concepts Alternatives to ActiveMQ AMQP RabbitMQ ZeroMQ Others
  • 3. Problems Time decoupling Scalability / Architecture flexibility Technology mix
  • 4. Concepts Producer Consumer Message Control x Data x Hybrid Small x Large Durability Queue Message Broker
  • 5. Apache ActiveMQ Disclaimer: Each broker has its own view of the world! Apache Project Written in Java Designed for high performance Flexible storage layer Multiple communication protocols Clustering capabilities Very active community -> constant evolution -> ... bugs
  • 6. Apache ActiveMQ Web console on port 8161 let's have a look at it... STOMP is not enabled by default Configuration: activemq.xml Running? Check it with netstat -ltn
  • 7. ActiveMQ and Python Easiest way (IMHO): STOMP Libraries stomp.py stompy twisted + stomper/stompest Our choice stomp.py
  • 8. STOMP Simple (or Streaming) Text Orientated Messaging Protocol. in-band (like HTTP or SMTP) Headers + body Text, not binary Simple Let's telnet...
  • 9. stomp.py Created by Jason Briggs Currently at version 3.x Supports Python 2 and Python 3 Has a CLI ! let's have a look at it...
  • 10. More ActiveMQ Persistence Producer: Receipt Consumer: Ack/NoAck Exclusive Consumers Selectors Queues X Topics Prefetch
  • 11. A simple Python producer def sendJMS(message, host, queue, port=61613, user='', password='', persistent=True): # Size of a buffer for storing MQServer STOMP answers to commands. bufsize = 200 # Establish a TCP connection t = socket.socket(socket.AF_INET, socket.SOCK_STREAM) t.connect ((host, port)) # Establish a STOMP connection frame = 'CONNECTnnx00' t.sendall(frame) resp = t.recv(bufsize) if resp[0:9] != 'CONNECTED': print ('sendJMS: Failed to connect to MQ server') return 1 # Send the message if persistent: persist="true" else: persist="false" frame = 'SENDndestination:%snpersistent:%snn%sx00' % (queue,persist,message) t.sendall(frame) # Disconnect STOMP frame = 'DISCONNECTnnx00' t.sendall(frame) # Disconnect TCP t.close() del(t) return 0
  • 12. A simple stomp.py producer import time import sys import stomp USAGE = """ producer.py <destination> <message> <destination> should start by /queue or /topic <message> is the text to be sent as message body (blank spaces accepted). """ if len(sys.argv) < 3: print USAGE else: conn = stomp.Connection() # with default parameters conn.start() conn.connect() conn.send(' '.join(sys.argv[2:]), destination=sys.argv[1]) time.sleep(2) conn.disconnect()
  • 13. A simple stomp.py consumer import sys import time import stomp class MyListener(object): def on_error(self, headers, message): print '*** received an error:n%sn***' % message def on_message(self, headers, message): print '*** received a message:n%sn***' % message conn = stomp.Connection() conn.set_listener('', MyListener()) conn.start() conn.connect() conn.subscribe(destination=sys.argv[1], ack='auto') try: while True: time.sleep(1) except KeyboardInterrupt: pass finally: print "nDisconnecting..." conn.disconnect()
  • 14. AMQP """ OUR VISION: To become the standard protocol for interoperability between all messaging middleware """ OASIS working group
  • 15. RabbitMQ Message broker written in Erlang Supports AMQP Concepts: Producers Messages Exchanges Queues Consumers
  • 16. ZeroMQ A "brokerless" approach to messaging "The Intelligent Transport Layer" ØMQ zeromq:  Ø  The socket library that acts as a concurrency framework.  Ø  Faster than TCP, for clustered products and supercomputing.  Ø  Carries messages across inproc, IPC, TCP, and multicast.  Ø  Connect N-to-N via fanout, pubsub, pipeline, request-reply.  Ø  Asynch I/O for scalable multicore message-passing apps.  Ø  Large and active open source community.  Ø  30+ languages including C, C++, Java, .NET, Python.  Ø  Most OSes including Linux, Windows, OS X.  Ø  LGPL free software with full commercial support from iMatix. (text from http://www.zeromq.org)
  • 17. Even more questions? :) Thanks!