Question:
How to get pending ActiveMQ messages?

Problem:

I am working on a Socket.IO application that consumes messages from an ActiveMQ queue. I am using STOMP library for Node.js.


I can send and receive messages from the queue, but I want to get the list of pending messages that were already in the queue. Is there a way to achieve this using STOMP? If not can anyone point me to another library that can give me the pending message details.


const Stomp = require("stomp-client");

const client = new Stomp("localhost", 61613);


client.connect((sessionId) => {

  console.log(`šŸš€ receiver connected successfully.`);

  client.subscribe("/queue/PENDING", onMessageCallback);

});


const onMessageCallback = (body, headers) => {

  console.log(`šŸš€ ~ onMessageCallback ~ body:`, body);

  console.log(`šŸš€ ~ onMessageCallback ~ headers:`, headers);

};


Solution:

Check out the ActiveMQ Messages REST API.

FYI-- the STOMP protocol supports browsing, and there are ActiveMQ server-side browse implementations present, but my quick scan did not see a unit test for it specifically. You might fire up a broker and add the BROWSER option to subscribe to see if it 'just works'.


Suggested blogs:

>How to use Wildcards to ā€˜cp’ a File Group with AWS CLI

>AWS EFS vs EBS vs S3: What are the best AWS storage options

>How to create a GCP Cloud Composer V2 instance via Terraform?

>Why You Should Use Google Cloud Vision API in Android Apps

>How to delete duplicate names from Array in Typescript?

>Create data with Typescript Sequelize model without passing in an id?

>Ignore requests by interceptors based on request content in TypeScript?

>How to get the last cell with data for a given column in TypeScript?


Ritu Singh

Ritu Singh

Submit
0 Answers