SEMP : Can I get messages from a Queue or a topic with curl?

Qais
Qais Member Posts: 9
edited February 2022 in PubSub+ Event Broker #1

How do I get the actual messages from a Queue or a topic with the SEMP API?
I used the SEMP (Action) documentation https://docs.solace.com/API-Developer-Online-Ref-Documentation/swagger-ui/action/index.html#/queue/getMsgVpnQueueMsgs
and used this GET command to get messages from a queue.
curl -X GET -u user:password {url:943/SEMP/v2/config/msgVpns/{msgVpnName}/queues/{queueName}​/msgs
to get a list of Queue Message objects, but it didn't work.
The error message says:

msgs               
{
    "meta":{
        "error":{
            "code":535,
            "description":"No paths found for /msgVpns/my_msg_vpn/queues/testQueue/msgs",
            "status":"INVALID_PATH"
        },.............
Tagged:

Comments

  • TomF
    TomF Member, Employee Posts: 409 Solace Employee

    @Qais, you're calling the config API but you need to call the monitor API:
    Not:
    SEMP/v2/config/msgVpns/{msgVpnName}/queues/{queueName}​/msgs
    But:
    SEMP/v2/monitor/msgVpns/{msgVpnName}/queues/{queueName}​/msgs

    This should give you something like:
    "data":[
    {
    "attachmentSize":331,
    "contentSize":0,
    ...

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 955 admin
    edited September 2020 #3

    Hi @Qais,
    Also note that SEMP is our RESTful management API for things like configuration and monitoring. If you are trying to actually consume the messages you'll want to use one of our messaging APIs of which there are several options that can be explored here. You can not consume messages using a HTTP GET at this time.

  • himanshu
    himanshu Member, Employee Posts: 67 Solace Employee

    Here is a tutorial on how to use REST API to publish/subscribe to messages:
    https://solace.com/samples/solace-samples-rest-messaging/publish-subscribe/

  • Qais
    Qais Member Posts: 9

    @TomF you are right. I had to change the config to action.
    @marc That would be a nice feature to be able to consume messages in the future with REST API
    @himanshu Thanks!

  • TomF
    TomF Member, Employee Posts: 409 Solace Employee

    Hi @Qais , there is one thing to note with SEMP. It is explicitly a management API. It has different credentials to messaging APIs, including the REST API that @himanshu pointed you to. As a matter of policy we don't allow admin users to view messages (i,e, by issuing SEMP calls to get messages from a queue) because that breaks the role based access controls we have in place to ensure only those authorised can view messages. Long story short:

    • can I use SEMP to get messages? No
    • can I use REST to get messages? Yes!
  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 594 admin

    Just for completeness... you can use REST to get messages off a queue. Just not with GET. But you can configure the broker to POST or PUT messages in a queue to any URL... a webhook. So you can't use curl for that (as curl is a client), but any web server or service that can accept incoming REST POSTs and PUTs could drain messages from a Solace queue.