0

When working with message queues we define a topic. The request or a schema argument is required. But what if I don't need any parameters to be passed in? I can't really pass a null or a void in there; it must be something. But I don't really want to pass anything dummy. What are my alternatives?

For instance, let's say one wants to flush the cache programatically. The consumer can execute this code without any arguments needed to be passed.

Thanks in advance

1 Answer 1

1

Actually, you might flush certain cache types (block, config) or certain cache tags, e.g. only those pages where product with id 42 is displayed.

Alternatively you could use RPC, but this is not supported by Magento.

Back to your question, it is not possible in the native Magento.

What are your concerns? Sending an empty string/array message vs null has negligible impact on the performance.

4
  • The example about clearing cache is hypothetical. My concern is a clean code. We pass parameters to a function (as arguments) when that function needs them; if a function doesn't need them, then its signature states that there are no function arguments. However with MQ stuff I am unable to create that very signature. My concern is a clean code
    – pro100tom
    Feb 24, 2022 at 14:04
  • You should use an empty argument list, because otherwise you would have to override the framework. Which from my perspective is less clean - where clean means that your code is easy to understand and is not breaking Magento API.
    – MTP
    Feb 27, 2022 at 13:41
  • Can you tell me more about this empty argument list please? I haven't heard of it. Is it a specific type that is defined in Magento? If so, where can I find it?
    – pro100tom
    Mar 1, 2022 at 21:53
  • Take a look at this example: \Magento\Catalog\Model\Attribute\Backend\ConsumerWebsiteAssign::process where products to update are held in 'product_ids' key
    – MTP
    Mar 4, 2022 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.