Cannot consume AMQP messages using the Mule Requester when triggered via HTTP requests

StackOverflow https://stackoverflow.com/questions/23621162

  •  21-07-2023
  •  | 
  •  

Question

I currently have a flow that is triggered using a specific HTTP request path, which should then make a request to a RabbitMQ server hosted locally. However, I cannot seem to see the output of the Mule Requester module; I see the HTTP request instead. Here is the gist of my current flow:

<flow name="get-queue-messages-manually" doc:name="get-queue-messages-manually" initialState="started">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="getqueue" contentType="text/plain" doc:name="HTTP"/>
    <mulerequester:request returnClass="java.io.String"  config-ref="Mule_Requester" resource="amqp://myexchange"  doc:name="Mule Requester"/>
    <logger level="INFO" doc:name="Logger"/>
    <echo-component doc:name="Echo"/>
</flow>

I am able to send messages to the exchange and have them be enqueued without a problem, but I cannot seem to extract any. As I understand it, the Mule Requester module allows one to make a request for resources at any point in a flow; I believe I also read that it causes an asynchronous operation, which may be the problem here. In that case, how would I be able to retrieve the queued message, and not the HTTP request?

I have also looked into the Mulesoft AMQP documentation, and though the URI specs mention the format amdq://{exchange}/amqp-queue.{queue}, it doesn't seem that the Mule Requester accepts this, as it only seems to take exchange names only. The console logs do contain a line which states that a private queue has been created, and from a little bit of searching, is an indication that a queue name is not specified? Not quite sure how that can be done in this component, however.

Note that the reason I have the HTTP request element first is that I do not want the flow firing off the moment a message is received, and therefore the HTTP component is used to ensure that the messages are read only when requested. Without the HTTP component, everything is swell.

Thanks in advance for any pointers on this issue - been struggling with this for some time now.

Was it helpful?

Solution

Well, now I feel silly. This can indeed be done using the Mule Requester. The format for the resource field should be: amqp://amqp-queue.{queueName}. Once I used the queue name instead of the exchange, I finally see the message in the payload. Hope this helps others! (There seems to be a restriction with accepting own answers; I'll accept this answer once that is lifted)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top