Giter VIP home page Giter VIP logo

rabbitmq-pika-celery-demo's Introduction

RabbitMQ demo

This is a simple demo, by using php, python pika and celery.

Due to the difference of login methods or the permission access control implemented, which are still not clear enough, I did these demo at didderent levels.

  1. php demo: all good, simple and no access or login issues.
  2. python demo with Celery: advanced but buggy. On windows, the celery installation thru pip ever worked, but most of them failed. Such as "ronous.timer import Entry ModuleNotFoundError: No module named 'kombu.asynchronous.timer'".
  3. python demo with Pika: Fully tested. Details as follows.

Issue from remote rmq

php demo works but python pika not, mainly I guess is the permission setting caused, or the RESOURCES php generates or uses comply the permission setting well.

RabbitMQ permissions

Server Configuration

rabbitmqctl set_permissions -p cross caiex "^hello." "." ".*"

rabbitmqctl set_permissions -p cross caiex "^(hello|amq.default)." "." ".*"

Here, cross is the vhost, caiex is the user, the following three are the RESOURCES and write/read priviledges.

RESOURCE

Resource is the Exchange and the Queue will be used by the user.

If we set the permmisions as: "." "." ".*", we will get no issues such as 'access refused' or 'connection failed'.

If we set the permmisions as: "^hello." "." ".*", we have to make all the exchange and queue start with the 'hello'. See the Reference 3.

If we set the permmisions as: "^(hello|amq.default)." "." ".*", as the default exchange, '', is equivalent to 'amq.default', we can restrict users only by the queue's acl by using the default exchange. i.e. no need to create exchange for every users, etc. See the Reference 4.

So I listed and demostrated the exchange customized in the Pika demo to suit the configuration on the server side.

RabbitMQ Docker

Usage of the official RabbitMQ docker, https://hub.docker.com/_/rabbitmq/

version: '2'

services:
  rabbitmq:
    image: rabbitmq:3.6
    container_name: some-rabbit
    #hostname: rabbitmq
    restart: always
    network_mode: host
    environment:
      - TZ=Asia/Shanghai

Reference

  1. RabbitMQ Customized Exchange: https://www.rabbitmq.com/tutorials/tutorial-three-python.html
  2. RabbitMQ Docs for Exchange: https://www.rabbitmq.com/amqp-0-9-1-quickref.html
  3. RabbitMQ Ctl Docs: https://www.rabbitmq.com/rabbitmqctl.8.html
  4. RabbitMQ ACL Docs: https://www.rabbitmq.com/access-control.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.