Giter Club home page Giter Club logo

Comments (16)

dzen avatar dzen commented on May 14, 2024

Hello @thijsterlouw,

Thank you for reporting your use case. This issue really shows that we didn't solve the problem correctly. For instance we should probably pass the channel instance to ack this specific message.
Problem is: this channel is currently overflooded by incomming message and won't send any message to the server :/

from aioamqp.

thijsterlouw avatar thijsterlouw commented on May 14, 2024

Hi @dzen , thanks for your quick reply. I've created a little bit of Python code to test the idea, and it seems wrapping my code in Objects would be a good way to go forward. That way I can pass my context around in the objects and have the object just create a reply channel to ack the messages (like #39 suggested)

import asyncio


def tester():
    print('tester')
    x = MyClass(1)
    y = MyClass(2)
    print('created classes')
    print(asyncio.iscoroutinefunction(x.f))
    val_x = yield from x.f()
    val_y = yield from y.f()
    print('x: {0}, y: {1}'.format(val_x, val_y))


class MyClass:
    def __init__(self, i):
        self.i = i

    @asyncio.coroutine
    def f(self):
        return 'hello world {0}'.format(self.i)


if __name__ == '__main__':
    print('main')
    loop = asyncio.get_event_loop()
    loop.run_until_complete(tester())
    loop.run_forever()
    loop.stop()

from aioamqp.

thijsterlouw avatar thijsterlouw commented on May 14, 2024

I have everything setup nicely. One instance of a class for each server, which wraps the callback and provides the necessary context. Acking now works great (even when using the same channel). So for me: problem solved :)

Initially I had a small application bug where I didn't ack invalid events, but that was easily fixed.

from aioamqp.

dzen avatar dzen commented on May 14, 2024

Hi @thijsterlouw,

I tried a little thing: the callback is converted as a Task, and the channel instance is passed to the callback. This way it's possible to ack the message from the coroutine called when a message is received. The only problem is that we will create a Task for each received message. The eventloop could be very BIG if your coroutine is slow.

I've got a publisher which publish at 20k msg/s. My computer goes very slow :(

from aioamqp.

dzen avatar dzen commented on May 14, 2024

screenshot from 2015-09-29 18 15 49

from aioamqp.

dzen avatar dzen commented on May 14, 2024

@mpaolini hello. Any thought on this PR / Issue ?

from aioamqp.

mpaolini avatar mpaolini commented on May 14, 2024

@dzen will have a look later this weekend

from aioamqp.

dzen avatar dzen commented on May 14, 2024

Hello @thijsterlouw,

Did you tried this branch against your code ?

beware, the definition of your callback should be like:

@asyncio.coroutine
def callback(channel, body, envelope, properties):
    # stuff
    yield from channel.basic_client_ack(envelope.delivery_tag)

from aioamqp.

ObjReponse avatar ObjReponse commented on May 14, 2024

Hi
I tried out that branch and I have a question. How to perform BASIC_ACK, because basic_client_ack and basic_server_ack both did not work?

from aioamqp.

dzen avatar dzen commented on May 14, 2024

do you have any problem using basic_client_ack ? what's the error generated ?

from aioamqp.

ObjReponse avatar ObjReponse commented on May 14, 2024

Yes I have, it does not work. No error, no ack, task still in queue.

from aioamqp.

dzen avatar dzen commented on May 14, 2024

Can you paste some code ?

from aioamqp.

ObjReponse avatar ObjReponse commented on May 14, 2024

@dzen sorry for missleading you, I forgot about yield from and when use yield from ch.basic_client_ask... it is working now. sorry again.

from aioamqp.

dzen avatar dzen commented on May 14, 2024

No problem. For now I didn't wrote enough documentation. It's planned

from aioamqp.

dzen avatar dzen commented on May 14, 2024

hello @thijsterlouw . Did you try the latest release ? (0.5.1, since we got a packaging problem) ?

from aioamqp.

dzen avatar dzen commented on May 14, 2024

@thijsterlouw you now have the channel handle to ack a message correctly.

from aioamqp.

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.