-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add posibility to attach ReceiverLink delayed in code & createReceiverLink promise will resolve immediatelly #311
base: master
Are you sure you want to change the base?
Conversation
…rLink promise will resolve immediatelly * it is feature when you want to accept all messages even that it already waiting in queue. Otherwise the immediatelly attach will invoke receiving messages yarlier then event emmitter on('messasge'... can be registered. * it has result that first messages are overlooked & never be consumed
@misak113 can you explain in more detail what this is attempting to accomplish? The reason the attachPromise is pushed to |
I found the problem, when starts consuming from queue (RabbitMQ) where already exists some messages waiting for consumption. I try to show it in code: export async function bindOne<TPayload extends IEventPayload>(
client: Client, eventType: string,
onEvent: (event: IEvent<TPayload>) => Promise<void>
) {
const queueName = QUEUE_NAME_PREFIX + eventType;
// THIS part is problematic, because after resolving this line are messages
// already consumed (emitted to receiverLink EventEmitter)
const receiver = await client.createReceiver(queueName);
// So this line would consume only new messages appeared in queue.
// All consumed messages are kept as not acked messages in queue & will be
// released after receiver is destroyed.
receiver.on('message', async (message: Message) => {
try {
const event = message.body;
await onEvent(event);
receiver.accept(message);
} catch (error) {
receiver.reject(message);
throw error;
}
});
receiver.on('errorReceived', (error: Error) => console.error(error));
// this line is necessary to be added if I apply this fixing commit & use receiver
// policy with manually attach
receiver.attach();
} |
Hi! What about this change? I face the same issue and would like it to be resolved.... |
Hi! I know... I'm waiting for your Pull Request on Azure SDK for Service Bus using AMQP... Meanwhile, I try to find some solutions to temporarily patch my problems... This was one of them. I ended up forking the repo and copy/pasted the changes. |
This change is