Open rmakantDangi123 opened 5 years ago
I don't really understand what you are trying to do. Setting the message event handler does not trigger receiving, it just lets you handle the received message.Your count variable looks to be local to the sender. Is this some sort ofrequest-response? i.e. the messages receive is in some way triggered by the message sent and you want to wait for it before considering the handling of the data to be completed?
Thank you so much @grs for your quick response, This is api which sends some json data to the aws mq queue and sends a response back once data received from the queue. If I got it correctly, once data put into the queue by the sender, the receiver should get the data from the queue as this is always listening to the queue. And Every message should be received as it was pushed by the sender. What you think about my receiver code, do i need to improve it to pull events from the queue? As per my understanding, message receive should not be trigger by the message sent. Once data pushed to the queue by the sender, it should trigger automatically as it is a subscriber. if needed please correct me. what you suggest on above?
Hi @grs , I have followed the given subscriber example for the receiver code. can you please share any receiver example for retrieving messages from awsmq queues?
Your help is much appreciated.
I think you need to correlate the incoming messages with the requests made. You can look at the client.js/server.js for an example of that.
Hi @grs, My code works fine if messages sent sequentially. I mean the receiver de-queue messages perfectly without duplicating. So my question is, why this is duplicating for concurrent messages, not for sequential?
I don't believe it is duplicating messages. I think you are not correlating responses with requests. When running sequentially this won't matter. With concurrent requests it will.
Hi Team, @grs I am using AWS MQ queue to send and receive messages. The code work as expected for a small number of messages, however, if messages pushed in large numbers concurrently in the queue. The received messages are duplicates of the first message when received from the queue. This issue happened when messages push concurrently to the queue. The code for sending and receiving the messages is below:
});
conn_attentionSpan.open_receiver({ source: { address: CONFIG.attention_span_queuename, durable:2, expiry_policy:'never' } });
}); console.debug('sender connection id : '+connection.options.container_id); var sender = connection.open_sender(
${queueName}
); sender.once('sendable', function (context) { context.sender.send({message_id:count, body:vidyardEventBody}) count++; connection.close(); }); conn_attentionSpan.once('message', (context) => { if (context.message.body === 'detach') { // detaching leaves the subscription active, so messages sent // while detached are kept until we attach again context.receiver.detach(); context.connection.close(); } else if (context.message.body === 'close') { // closing cancels the subscription context.receiver.close(); context.connection.close(); } else { console.debug("message received : ", context.message.body); }});
}); }; Can you please help me regarding this issue. I am a beginner to "rhea", and for node too. Your help will be highly appreciated.