A simple example of using RabbitMQ with PHP to send and receive messages.
- Build the PHP Docker image:
make build
- Start the server:
make start
- Stop the server:
make stop
- Test connection http://127.0.0.1:8000/
The application uses a Producer to send messages and a Consumer to receive them. The communication happens through RabbitMQ, without direct communication between the two.
- The Producer publishes messages to an Exchange.
- The Exchange routes the messages to the appropriate Queue based on the message's Routing Key.
- The Consumer retrieves messages from the Queue and processes them.
- Exchange: Routes messages from the producer to the correct queue.
- Queue: Holds messages until the consumer picks them up.
- Routing Key: Determines which Queue the message will be sent to.
- Fix the
Uncaught PhpAmqpLib\Exception\AMQPIOException: stream_socket_client()
error that occurs when the PHP application tries to connect to the RabbitMQ server. This may be due to network configuration issues or the RabbitMQ server not being accessible from the PHP application's container.