You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.I send a message to my queue,I called this message “A”,In my code ,"A" is not unacked, and then I requeue "A",handle "A" takes a lot time.
2.in the same time,another Message "B" comes, and acked.
3.then I receive the requeue meassge ,but "B" appear in my console.not "A"
I was so confused,
my code goes here:
const createContext = require('rabbit.js').createContext;
var context = createContext(config.QUEUE_LOCATION);
context.on('ready', () => {
var sub = context.socket('WORKER', { prefetch: 1 });
sub.setEncoding('utf8');
sub.on('data', (message) => {
handle(sub,message)
});
const cpus = require('os').cpus();
async.forEachOf(cpus, (value, i, cb) => {
sub.connect(config.QUEUE_NAME, function () {
console.log(i, 'connected');
cb();
});
}, (err) => {
if (err)
console.log(new Error(err), 'rabbitmq sub.connect error');
});
});
async function handle(sub,message){
console.log('received:', message);
var msg = {};
const TAG = "handle-msg";
console.time(TAG);
message=JSON.parse(message)
if (message.test) {
console.log("ack")
sub.ack();
return;
}
console.log('requeue');
await sleep(10000);
sub.requeue();
return;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
The text was updated successfully, but these errors were encountered:
1.I send a message to my queue,I called this message “A”,In my code ,"A" is not unacked, and then I requeue "A",handle "A" takes a lot time.
2.in the same time,another Message "B" comes, and acked.
3.then I receive the requeue meassge ,but "B" appear in my console.not "A"
I was so confused,
my code goes here:
The text was updated successfully, but these errors were encountered: