Object-oriented PHP bindings for the AMQP C library (https://github.com/alanxz/rabbitmq-c)
Some systems has php-amqp extension in their repo or available via external repositories, so it is MAY be the preferable way to install.
RPM packages are available in Fedora and EPEL (for RHEL and CentOS) official repositories, see php-pecl-amqp
Fresh php-pecl-amqp
and librabbitmq
RPMs available via remi repo.
If you want to stay on the bleeding edge and have the latest version, install php-amqp extension from PECL or compile from sources (follow PHP official docs instruction).
rabbitmq.4.dll
and rabbitmq.4.pdb
files to the PHP root folder and copy php_amqp.dll
and php_amqp.pdb
files to PHP\ext
folderextension=amqp
to the php.ini
fileView RabbitMQ official tutorials and php-amqp specific examples.
There are also available stub files with accurate PHPDoc which may be also used in your IDE for code completion, navigation and documentation in-place.
Finally, check out the tests to see typical usage and edge cases.
Max channels per connection means how many concurrent channels per connection may be opened at the same time (this limit may be increased later to max AMQP protocol number - 65532 without any problem).
Nested header arrays may contain only string values.
You can't share none of AMQP API objects (none of AMQPConnection
, AMQPChannel
, AMQPQueue
, AMQPExchange
) between threads.
You have to use separate connection and so on per thread.
Limitations:
Developers note: alternatively for built-in persistent connection support raphf pecl extension may be used.
Some of them, the list is not complete.
amqp.so
or amqp.dll
if you are on windows), it is loaded (php --ri amqp
produced some info), and there are no underlying abstraction that MAY emulate php-amqp work.There is a Vagrant environment with pre-installed software and libraries necessary to build, test and run the php-amqp extension.
To start it, just type vagrant up
and then vagrant ssh
in php-amqp directory.
Services available out of the box are:
guest
, password: guest
)Additional tools are pre-installed to make development process as simple as possible:
Valgrind is ready to help find memory-related problems if you export TEST_PHP_ARGS=-m
before running tests.
phpbrew waits to help you to test extension on various PHP versions.
phpbrew install 5.6 +debug+default+fpm
is a nice start. To switch to some version just use phpbrew switch <version>
.
To start php-fpm just run phpbrew fpm start
(don't forget to run sudo service stop php5-fpm
befor).
This development environment out of the box ready for php-fpm and cli extension usage, if need to test it when php
used as apache module, refer to Apache2 support on phpbrew wiki.
Keep in mind that +apxs2
conficts with +fpm
and it is a bit tricky to specify which libphp .so will be loaded.
tshark - Dump and analyze network traffic
... TShark is able to detect, read and write the same capture files that are supported by Wireshark.
To use it you probably have to set network privileges for dumpcap first(see Platform-Specific information about capture privileges Wireshark docs page and running wireshark “Lua: Error during loading” SO question):
sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap
To start capturing, run tshark -i lo
to see output in terminal or tshark -i lo -w capture.log
to save capture and
analyze it later (even with AMQP protocol Wireshark plugin). You may filter AMQP packages
using -Y amqp
attribute, just give a try - tshark -i lo -Y amqp
.
NOTE: -w provides raw packet data, not text. If you want text output you need to redirect stdout (e.g. using '>'), don't use the -w option for this.
If you need to tweek RabbitMQ server params use default config
rabbitmq.config.example
(raw)
from official RabbitmMQ repo, so it may looks like
sudo curl https://raw.githubusercontent.com/rabbitmq/rabbitmq-server/master/docs/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config
To reset RabbitMQ application run in CLI (as privileged user) rabbitmqctl stop_app && rabbitmqctl reset && rabbitmqctl start_app
.
It is a good practice to keep php processes (i.e workers/consumers) under control. Usually, system administrators write their own scripts which ask services about current status or performs some desired actions. Usually request is sent via UNIX signals.
Because amqp consume method is blocking, pcntl extension seems to be useless.
php-signal-handler extension uses signal syscall, so it will work even if blocking method was executed. Some use cases are presented on extension's github page and examples are available here.
Say we want to release "1.1000.0" next. We first run php tools/make-release.php 1.1000.0
. This will update the version
numbers and pre-populate the changelog with the latest git commits between the previous version and now. It will prompt
you to edit the changelog in between. Once the release is done it tells you what to do next.
Run php tools/make-dev.php 1.1000.1
to bring master back into development mode afterwards.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。