Giter VIP home page Giter VIP logo

Comments (5)

weyoss avatar weyoss commented on August 17, 2024 1

A new release (v1.0.22) is out.

from redis-smq.

weyoss avatar weyoss commented on August 17, 2024

Thank you for reporting this issue!

The cause of this bug has been identified (as being related to GC) and fixed.

A new release containing this hot-fix will be published today ASAP.

from redis-smq.

mmsqe avatar mmsqe commented on August 17, 2024

Thanks for the quick response, but issue still exists with commit 64087f1

from redis-smq.

weyoss avatar weyoss commented on August 17, 2024

I believe that the issue has been fixed.

I made a little script just to make sure that everything works as expected:

'use strict';

const { Consumer, Producer } = require('redis-smq');

function getConsumer(queueName, crashOnConsume = false) {
    const InstanceClass = class extends Consumer {
        consume(message, cb) {
            if (crashOnConsume) {
                console.log(`Got message: ${JSON.stringify(message)}, queue: ${this.constructor.queueName}. Simulating crash...`);
                console.log(`Please wait for another consumer to recover from this failure. It would take some time...`);
                this.stop();
            } else {
                console.log(`Got message ${JSON.stringify(message)} from Queue ${this.constructor.queueName}. Acknowledging...`);
                cb();
            }
        }
    };
    InstanceClass.queueName = queueName;
    return new InstanceClass();
}

function getProducer(queueName) {
    return new Producer(queueName);
}


// This creates a consumer which acknowledges all received messages on queue 'queue_b'
const consumerQueueB = getConsumer('queue_b');
consumerQueueB.run();

// Produce a message on queue 'queue_b'
const producerQueueB = getProducer('queue_b');
producerQueueB.produce({ id: 'b', hello: 'world' }, (err) => {
    if (err) {
        throw err;
    }
});

// This creates a consumer which "crashes" once a message is received
const consumer1QueueA = getConsumer('queue_a', true);

/**
 * Start an other consumer instance on queue 'queue_a'
 * just after the first consumer1QueueA crashed...
 *
 * Here we just listen to the 'halt' event which get emitted once consumer1QueueA goes down.
 */
consumer1QueueA.on('halt', () => {
    const consumer2QueueA = getConsumer('queue_a');
    consumer2QueueA.run();
});

// Start waiting for new messages...
consumer1QueueA.run();

// Produce a message on queue 'queue_a'
const producer1QueueA = getProducer('queue_a');
producer1QueueA.produce({ id: 'a', hello: 'world' }, (err) => {
    if (err) {
        throw err;
    }
});

The script output should be like:

Got message {"id":"b","hello":"world"} from Queue queue_b. Acknowledging...
Got message: {"id":"a","hello":"world"}, queue: queue_a. Simulating crash...
Please wait for another consumer to recover from this failure. It would take some time...
Got message {"id":"a","hello":"world"} from Queue queue_a. Acknowledging...

As you see from the output the message {"id":"a","hello":"world"} was not re-queued on queue_b after consumer crash.

from redis-smq.

mmsqe avatar mmsqe commented on August 17, 2024

Sorry that issue has been actually fixed, I didn't delete previous appendonly.aof file mounted from docker container to my host.

from redis-smq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.