Get all messages from a queue
Dear Team,
I have a requirement to retrieve all the messages from a queue at a given point of time. I believe On-demand JMS or Consume operations can only read one message per request. Do we have any parameter to configure in JMS or Consume operation in Mulesoft Soalce connector.
Can we achieve this via SEMP apis? I would like to hear any other better or feasible approaches for this requirement.
Design:
Mule API with Get All messages(Rest endpoint)-> Solace connectivity via JMS or solace connector or SEMP-> Connect to Queue and read all the messages.
Thanks,
Vempati
Answers
-
Hello,
There is no way to get more than 1 message at a time in any Solace API and within the context of the Solace MuleSoft connector (Solace has no ability to change the JMS connector as it's provided by MuleSoft) there is not a concept of batches of messages in our consume operation.The use case is somewhat problematic too in that "at a given point in time" implies that you would have a dynamic batch size (assuming we added batches) that is changed at runtime per batch. There is nothing built into the connector that would provide queue depth.
As far as SEMP being used... SEMP is a management API and has NO access to message payloads so it would not be appropriate for this use case.
1 -
I am not aware of a solution. I suppose you could use a sub flow to consume messages in a loop and store them in some cache. If there is a break in the publishing such that the queue has a static number of messages for "a while" (at least the time it takes to process the current messages), then the loop could be run until there are no more messages which breaks the loop.
Then in your main flow, operate off the cache?Does Mulesoft support this use case with Anypoint MQ? It sounds like a database use case not ideally suited to a message queue.
0 -
Yes, I could think of same approach but then the below Issues might encounter.
- On each call from consume operation, does it do bind and unbind? or the session persists for some time? Will it be a problem from soalce Infra , If the consume operations called multiple times in a loop?
- It could fail , If there is a time out from front end application while we are processing in mulesoft.
- Error handling would be much difficult. Depending on the load.
I don't think it is even possible with AMQ, I totally agree Ideal case should be from a db but here we need process this data from downstream applications and put in to queue
0 -
- There is a new jcsmp flow created for each time Consume is called. However, the connection itself is reused. Connections are much more expensive than flows.
0 -
Vempati: I have the same project requirement. Did u find any solution on "to retrieve all the messages from a queue at a given point of time". Kindly let me know if you got something otherwise, I would have to develop Java code and integrate with Mule flow.0