Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教如何实现topic模式,exchange对应多个队列对应各自消费者 #15

Closed
leedom-hub opened this issue Jun 25, 2023 · 1 comment
Labels
question Further information is requested

Comments

@leedom-hub
Copy link

感谢作者提供简单好用的插件!

当前使用1.0版本

我想实现的效果是:

  • 实现topic模式, 比如exchange = mqTopic ,
  • 这个交换机有两个队列mqTopic_1mqTopic_2,
  • 两个队列分别通过routing_key = task.1 (mqTopic_1)routing_key = task.2 (mqTopic_2)绑定
  • 每个队列有各自的消费者进程去消费

我的做法:

  • 通过php webman workbunny:rabbitmq-builder mqTopic 2创建了builder
  • 投递消息使用sync_publish() 目前情况是投递消息可以到达,但是无法消费
$b = MqTopicBuilder::instance();
$b->setMessage(new Message([
         'exchange_name'     => 'mqTopic',
          'exchange_type'     => Constants::TOPIC,
          'queue_name'        => 'mqTopic_'.$request->get('queue_name', 0), //对应mqTopic_1 mqTopic_2
          'routing_key'       => $request->get('routing_key',get_called_class()), //对应 task.1 task.2
          'consumer_tag'      => 'mqTopic',
          'prefetch_size'     => 0,
          'prefetch_count'    => 30,
          'is_global'         => false,
      ]));
      sync_publish($b, json_encode($data));

请问我该如何实现?如果有demo最好!

在次感谢作者无私奉献!

@chaz6chez
Copy link
Member

不好意思最近一直很忙没有看github;
关于这个问题,就是路由模式,1.X目前来说只能通过自行实现Builder来实现这个方案,也就是参照FastBuilder,自行实现一个Builder,在构造函数里进行注册队列,绑定队列等操作,比较麻烦;
还有一个方法,就是试一试2.X,不过目前2.X还是beta版,还没有时间去做CI相关内容,这段时间忙完会抽空去完善;

@chaz6chez chaz6chez added the question Further information is requested label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants