Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Questions about how this library works #1277

Unanswered
samijnih asked this question in Q&A
Discussion options

Hey,

First of all, I'd like to thank you for that great work on this library. It seems very promising. I'm currently testing it because I'm fed up of Symfony Messenger. I've been using messaging libraries for a while now:

  • tactician
  • simplebus
  • prooph
  • event sauce
  • messenger
  • php-amqplib/RabbitMqBundle
  • ...

I really want to use your lib for my next professional projects.

To be honest, it's pretty hard to understand how it works out of the box by reading the documentation :/

I'll list some feedbacks about my misunderstanding! :)

1/ For Symfony, what is the difference between an enqueue.processor and enqueue.transport.processor? In which case should I use one instead of the other?

  • If I tag a service with enqueue.processor and run enqueue:transport:consume then, I'll get an error because it's incompatible
  • If I tag a service with enqueue.transport.processor and run enqueue:consume then, I'll get an error because it's incompatible
  • https://php-enqueue.github.io/bundle/message_processor/ does not explain cases when we should use a transport or not

My thought is that enqueue:transport:consume enables to handle a message from a given queue with a given processor even if the processor is not configured on that queue. enqueue:consume will select the appropriate queue binded processor to handle that message

2/ I want to dispatch commands or events using async. For commands, while reading the documentation, I thought the only way to do it, was to use enqueue/async-command library. But it is not. I'm able to async send commands and consume those later using enqueue:consume with an SQS client.

I think, you should make a clear distinction between Producer sending commands/events and cases when we need to use async-command

3/ Configuration

I'm using the symfony bridge. I want to declare a queue named "place-order" for my transport named "sqs"

enqueue:
 sqs:
 transport: '%env(ENQUEUE_SQS_DSN)%'
 client:
 traceable_producer: '%kernel.debug%'
 prefix: 'dev'
 app_name: ''
 separator: '-'
 router_queue: 'place-order'
 redelivered_delay_time: 0

When I run enqueue:setup-broker then it perfectly creates a queue named "dev-place-order" into SQS.

Now, let's say I want to manually register a processor on that queue by tagging it. If I rerun enqueue:setup-broker, then it will create another queue named dev-default:

Configuration:

 Domain\Order\Saga\PlaceOrderSaga:
 tags:
 - {
 name: 'enqueue.processor',
 command: Domain\Order\Features\Place\PlaceOrder
 }

Command output:

/app # bin/console enqueue:setup-broker -vvv
[debug] [SqsDriver] Declare router queue: dev-place-order
[debug] [SqsDriver] Declare processor queue: dev-default
Broker set up

As your you can see, It creates a queue named dev-default only because I've tagged my processor. I don't want that. So following the documentation, I have to specify a queue name tag, e.g:

 Domain\Order\Saga\PlaceOrderSaga:
 tags:
 - {
 name: 'enqueue.processor',
 command: Domain\Order\Features\Place\PlaceOrder,
 queue: place-order
 }

That will work. But I've debugged the source code and it will actually make a HTTP request to AWS SQS for creating this queue which already exist:

/app # bin/console enqueue:setup-broker -vvv
[debug] [SqsDriver] Declare router queue: dev-place-order
[debug] [SqsDriver] Declare processor queue: dev-place-order
Broker set up

So... I must define the client key in a transport, otherwise an exception will be raised. If I don't want any default queue to be created, I have to define router_queue in client with my queue name.
If I wanna manually register a processor and if I don't want a default queue to be created, I have to define the queue tag.

How can I avoid that double queue creation?

4/ Multiple queues on a same transport

Let's say I want only one transport (SQS) with N queues (queue1, queue2, queue3). Should I do that?

enqueue:
 queue1:
 transport: '%env(ENQUEUE_SQS_DSN)%'
 client:
 router_queue: 'queue1'
 queue2:
 transport: '%env(ENQUEUE_SQS_DSN)%'
 client:
 router_queue: 'queue2'
 queue3:
 transport: '%env(ENQUEUE_SQS_DSN)%'
 client:
 router_queue: 'queue3'

If so, I found it pretty confusing to get 3 different clients for the same transport to achieve this.

I'm more expecting something like:

enqueue:
 transports:
 monolith:
 dsn: '%env(ENQUEUE_SQS_DSN)%'
 default_queue: foo
 queues:
 one:
 name: queue1
 two:
 name: queue2
 three:
 name: queue3
 order:
 dsn: '%env(ENQUEUE_SQS_DSN)%'
 default_queue: foo
 queues:
 one:
 name: place-order
 two:
 name: order-placed
 three:
 name: order-payment
 monolith-topic:
 dsn: '%env(ENQUEUE_SNS_DSN)%'
 default_topic: bar
 topics:
 one:
 name: topic1

Thanks!

You must be logged in to vote

Replies: 1 comment

Comment options

There is something weird I've noticed.

If you have a processor queue and a queue with the same name

  • when you send a message, 2 SQS calls will be made
  • when you run enqueue:consume, 3 calls will be made but the message will be consumed only once

image

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /