majek / puka

Puka - the opinionated RabbitMQ client
https://github.com/majek/puka
Other
182 stars 34 forks source link

Publishing to a 2nd channel - does not work. #56

Closed kjlockhart closed 10 years ago

kjlockhart commented 10 years ago

Related to 'serious memory leak - if using one channel to consume & publish'.

An application reading from one queue, filtering the messages, and publishing to a second queue - works if a single channel is used, but the publish fails silently if a 2nd channel is used for the publishing. My understanding is AMQP channels should be uni-directional & a single channel should not used for both consumming and publishing. Thus the app opens two channels. Channel 1 to consume from queue A; and channel 2 to publish to queue B.

[Is my understanding correct?] If so why is consuming & publishing on the same channel not prevented?

majek commented 10 years ago

but the publish fails silently if a 2nd channel is used for the publishing.

In Puka publishing is synchronous. Puka uses pub-acks to ensure that the publish really did go through.

So the correct way is: receive message, publish it to another queue, send ack.

In the worst case (connection lost before ACK) you will have duplicate messages (the old and the new).

kjlockhart commented 10 years ago

Yes – I like puka because it hides the channels. However due to the memory leak I encountered, I tried using to connections to rabbitmq. This is when I discovered the 2nd connection does not work.

My approach is:

Open Connection1 for consuming. Open Connection2 for publishing Forever: Receive msg. Ack message. Build new notification msg Publish notification

My program only seems to publish if a single connection to rabbitmq is opened. As soon as the 2nd connection is introduced – the publishing stops.

From: Marek [mailto:notifications@github.com] Sent: Monday, September 01, 2014 7:28 AM To: majek/puka Cc: Ken Lockhart Subject: Re: [puka] Publishing to a 2nd channel - does not work. (#56)

but the publish fails silently if a 2nd channel is used for the publishing.

In Puka publishing is synchronous. Puka uses pub-acks to ensure that the publish really did go through.

So the correct way is: receive message, publish it to another queue, send ack.

In the worst case (connection lost before ACK) you will have duplicate messages (the old and the new).

— Reply to this email directly or view it on GitHubhttps://github.com/majek/puka/issues/56#issuecomment-54065783.