PHPackages                             mumuxi1224/3y\_rabbitmq - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. mumuxi1224/3y\_rabbitmq

ActiveLibrary[Queues &amp; Workers](/categories/queues)

mumuxi1224/3y\_rabbitmq
=======================

a package about rabbitmq

v1.0.12(4y ago)058MITPHPPHP &gt;=7

Since May 27Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mumuxi1224/3y_rabbitmq)[ Packagist](https://packagist.org/packages/mumuxi1224/3y_rabbitmq)[ RSS](/packages/mumuxi1224-3y-rabbitmq/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (13)Used By (0)

3y\_rabbitmq
============

[](#3y_rabbitmq)

一个子类需要继承\\Mmx\\Quene\\BaseQueneRoute，再注册到服务中，消息是持久化保存

发送消息使用的php-rabbitmq扩展，接受消息使用的是stomp协议，workman/stomp异步组件支持，所以需要在rabbitmq端开启对stomp的支持，需要在rabbitmq服务端执行以下命令

```
rabbitmq-plugins enable rabbitmq_stomp

```

consume()方法：消费队列时的回调，传入的是字符串格式的消息，手动调用ack()或不调用，会在consume()方法执行完毕后执行ack，调用nack(),会在consume()方法执行完毕后执行nack

onSuccess()方法：消费成功后的回调，传入的是字符串格式的消息

消费时传入rabbitMq的参数实例：

```
$rabbitMq = [
    'host'              => '192.168.4.92',
    'port'              => '5673',
    'username'          => 'admin',
    'password'          => 'admin',
    'vhost'             => '/',
    'stomp'             => '192.168.4.92:61615', //stomp监听的地址
    'debug'             => false, //是否开启debug，开启后每次stomp的行为都有相应输出
    'maxSendBufferSize' => 10, //最大缓冲区的大小，单位M
    'prefetch_count'    => 10, //stomp每次最多预读值的大小，与rabbimt中channel设置qos的行为一样
];

```

安装：

```
composer require mumuxi1224/3y_rabbitmq

```

模型示例：

```
