c# - SQS : Getting Number of message in the SQS Queue -


i working amazon-sqs, tried retrieve approximate number of attributes queue response null

i using c# following code:

getqueueattributesrequest attreq = new getqueueattributesrequest(); attreq.queueurl = "link queue"; getqueueattributesresponse response = client.getqueueattributes(attreq); console.writeline("app. messages: "+ response.approximatenumberofmessages); 

i getting null response request, sure there messages in queue well.

you have explicitly specify attributes return getqueueattributes. didn't specify any, didn't return any.

try adding approximatenumberofmessages attributenames collection on getqueueattributesrequest:

getqueueattributesrequest attreq = new getqueueattributesrequest(); attreq.queueurl = "link queue"; attreq.attributenames.add("approximatenumberofmessages"); getqueueattributesresponse response = client.getqueueattributes(attreq); 

notes:

  • this property might called attributename without last s if you're on older version of awssdk. looks changed between versions 1.x , 2.x.
  • full list of attributes can found in api documentation

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -