🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
How to check the size of a message-queue
Hi,
I have a specific requirement.
When we start/restart the pub, we need to check the size of the last value queue. It should be zero in the start of the day, and it should be 1 during the day ( at least one message went through).
When the LVQ size is zero, we will consider it the start of the day ( no message went through).
and When the LVQ size is one, we will consider it during-day ( atleast one message went through)
What is the API or any other way to check the queue size. Please share sample code if any available?
Thanks
Comments
-
Hi @Abhishek,
I can think of two different ways of doing this:- You could use the SEMP Monitoring API to query the number of messages on the queue (SEMP is our RESTful management API that allows you to configure/monitor/take action on the event brokers). Sample request below, but more info is here. Note that SEMP requires the use of a management user, not a client-username that would be used to connect for messaging purposes.
http://{{username}}:{{password}}@{{hostname}}:8080/SEMP/v2/monitor/msgVpns/{{messageVpnName}}/queues/{{queueName}}?select=msgs.count
- If you only have a client-username for messaging purposes then you could browse a queue to see that messages are present without consuming them. More info here and a tutorial using our Java API (JCSMP) to browse queues is here
Hope that helps!
1 -
I have executed the query, I am getting below error.
{
"meta":{
"error":{
"code":11,
"description":"select query error: 'msgs.count' not a valid attribute",
"status":"INVALID_PARAMETER"
},
"request":{
"method":"GET",
"uri":"https://dev-solace.nse.co.in/SEMP/v2/monitor/msgVpns/sample_vpn/queues/last_value_queue?select=msgs.count"
},
"responseCode":400
}
}0 -
I have executed the query, I am getting below error.
{
"meta":{
"error":{
"code":11,
"description":"select query error: 'msgs.count' not a valid attribute",
"status":"INVALID_PARAMETER"
},
"request":{
"method":"GET",
"uri":"https://dev-solace.nse.co.in/SEMP/v2/monitor/msgVpns/sample_vpn/queues/last_value_queue?select=msgs.count"
},
"responseCode":400
}
}0 -
Here's the API documentation for Queue Browsers - https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Browsing-Guaranteed-Mess.htm which also includes info on how to do this in c.
You can use this SEMPv2 call to get a list of messages on a queue. It returns an array so you can simply evaluate if the array is empty or not ... in the example I selected only one data property as we are not interested in the actual data ...
https://[host]:[mgm_port]/SEMP/v2/monitor/msgVpns/xdk-devices/queues/[queue_name]/msgs?select=msgId
The endpoint Marc described currently doesn't seem to return the number of spooled messages as far as I can see in the doc ...
https://docs.solace.com/API-Developer-Online-Ref-Documentation/swagger-ui/monitor/index.html#/queue/getMsgVpnQueueMsg0 -
@Abhishek said:
I have executed the query, I am getting below error.
{
"meta":{
"error":{
"code":11,
"description":"select query error: 'msgs.count' not a valid attribute",
"status":"INVALID_PARAMETER"
},
"request":{
"method":"GET",
"uri":"https://dev-solace.nse.co.in/SEMP/v2/monitor/msgVpns/sample_vpn/queues/last_value_queue?select=msgs.count"
},
"responseCode":400
}
}That's weird! When I query I get the following response. Can you try the query without the
?select=msgs.count
on the end and see what comes back for you? Note that I'm using VMR 9.6.0.27:0 -
@swenhelge said:
@marc - I think the "collections" element of the response is a relatively recent addition. Cloud services don't yet contain it.Ah, that would make sense. Thanks @swenhelge!
0