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.
- php demo: all good, simple and no access or login issues.
- 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'".
- python demo with Pika: Fully tested. Details as follows.
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.
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 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.
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
- RabbitMQ Customized Exchange: https://www.rabbitmq.com/tutorials/tutorial-three-python.html
- RabbitMQ Docs for Exchange: https://www.rabbitmq.com/amqp-0-9-1-quickref.html
- RabbitMQ Ctl Docs: https://www.rabbitmq.com/rabbitmqctl.8.html
- RabbitMQ ACL Docs: https://www.rabbitmq.com/access-control.html