bschmitt / laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages
MIT License
268 stars 86 forks source link

Send direct message into queue, when you defined exchange_type=topic #71

Open MattBearson opened 4 years ago

MattBearson commented 4 years ago

Hello guys,

I got a problem, but maybe you know the solution. If I set up exhange_type = topic in amqp.php(settings), can I send direct message into particular queue, not to topic. I tried a things like that:

$amqpObj->publish('', json_encode($data), [
            'queue' => $queueName
        ]);

but it binds my queue to the default topic and send message into default topic. So, if I have for example 10 REST api with different queues, all of them will be binded to one topic and all will get messages, which is incorrect. So, do you have a way - how I can use 2 ways: one function sent message into topic and another one send just directly into one queue(and do not bind queue to the default topic)? Thanks

weblogics commented 4 years ago

@MattBearson I think we are having the same issue.

We currently have our default setup as topic in setting's with a default Queue.

We seem to have messages being published to both the default Queue setup in our settings file and when trying to publish to another Queue it pushes messages to both the default queue and the provided queue in the publish method.

However, if we include a routing key this behaviour seems to stop, however, this is causing other issues and meaning we're having to now restart services in a certain order otherwise the messages are ignored.

Is there any way around this as we are using the default AMQP library in another project without any issues so this seems to be a potential bug with this library. @stevenklar any suggestions?

stevenklar commented 4 years ago

Sorry for the late answer.

@weblogics This sound like an issue by it's own. You could open one and provide more information with examples so I can reproduce the problem. Otherwise I don't know if it's a bug in this lib or not.

@MattBearson I don't really get the problem. If you use '' while doing a topic exchange that legitimate binds to all, because that's how topic exchange works. Read the tutorial (you don't need to know python to understand the concept): https://www.rabbitmq.com/tutorials/tutorial-five-python.html

In case you still think it's a problem please provide a proper example so we can try to reproduce what you mean.

What are you actually trying to accomplish?