stomp-js / stompjs

Javascript and Typescript Stomp client for Web browsers and node.js apps
Apache License 2.0
773 stars 82 forks source link

STOMP redelivery policy on SUBSCRIBE doesn't work #635

Open akaNightmare opened 3 months ago

akaNightmare commented 3 months ago

Hello, trying to implement redelivery policy on SUBSCRIBE and have no luck.

Is there any way to reach that?

Example:

const { WebSocket } = require('ws');

const { Client } = require('@stomp/stompjs');

Object.assign(global, { WebSocket });

const client = new Client({
    brokerURL: 'ws://0.0.0.0:61624',
    reconnectDelay: 5000,
    heartbeatIncoming: 4000,
    heartbeatOutgoing: 4000,
    onConnect: () => {
        client.publish({
            destination: '/queue/Test.Queue',
            body: JSON.stringify({ field1: 'value1', field2: 'value2' }),
            headers: { 'correlation-id': '6666fe222570b857770849fe', persistent: 'true' },
            skipContentLengthHeader: true,
        });

        client.subscribe(
            '/queue/Test.Queue',
            message => {
                console.log('tick');
                message.nack();
            },
            {
                ack: 'client-individual',
                'activemq.maximumRedeliveries': '5',
                'activemq.redeliveryDelay': '1000',
                'activemq.useExponentialBackOff': 'true',
                'activemq.backOffMultiplier': '2',
                'activemq.initialRedeliveryDelay': '500',
                'activemq.maximumRedeliveryDelay': '60000',
            },
        );
    },
});

client.activate();
OlivierVerhaegen commented 1 week ago

Hi,

I'm looking for the same solution as you. I would like automatic redelivery of messages if they aren't acknowledged.

Reading the following post it seems that the only way to achieve this using ActiveMQ + STOMP is by reconnecting.

https://stackoverflow.com/questions/63825040/how-to-redeliver-a-stomp-message-to-the-consumer-in-case-of-any-processing-failu