AMQProxy not reuse tcp connection

Viewed 192

I am starting to use AMQProxy library in order to reuse client tcp connection per client request to client request. But faced with problem that rabbitmq log display the same behaviour like before without AMQProry. Anyone one faced with this problem before?

In docker-compose.yml amqproxy block.

rabbitmq:
    image: rabbitmq:3.6-management-alpine
amqproxy:
    image: cloudamqp/amqproxy
    expose:
        - "5672"
    ports:
        - "5673:5673"
    command: amqp://rabbitmq

In my php file

use PhpAmqpLib\Message\AMQPMessage;
use PhpAmqpLib\Connection\AMQPStreamConnection;
        $connection = new AMQPStreamConnection('amqproxy', 5673, 'guest', 'guest');
        $channel = $connection->channel();
        $channel->queue_declare(
            'email_queue',    #queue - Queue names may be up to 255 bytes of UTF-8 characters
            false,              #passive - can use this to check whether an exchange exists without modifying the server state
            true,               #durable, make sure that RabbitMQ will never lose our queue if a crash occurs - the queue will survive a broker restart
            false,              #exclusive - used by only one connection and the queue will be deleted when that connection closes
            false               #auto delete - queue is deleted when last consumer unsubscribes
        );

        $msg = new AMQPMessage(
            2,
             array('delivery_mode' => 2) # make message persistent, so it is not lost if server crashes or quits
        );

        $channel->basic_publish(
            $msg,               #message
            '',                 #exchange
            'email_queue'     #routing key (queue)
        );
        $channel->basic_publish(
            $msg,               #message
            '',                 #exchange
            'queue'     #routing key (queue)
        );

       $channel->close();
       $connection->close();
0 Answers
Related