robertmrk / aiosfstream

Salesforce Streaming API client for asyncio
MIT License
47 stars 31 forks source link

Gracefully terminating client message consumer #13

Open aleksarias opened 4 years ago

aleksarias commented 4 years ago

I've noticed when I KeyboardInterrupt I can't get the client to gracefully exit when using this setup:

await client.open()

# subscribe to topics
await client.subscribe("/topic/my-topic")

# listen for incoming messages
async for message in client:
    # code to execute on receiving message
    ...

Is there anyway to cancel the client but allow it to continue processing the messages it has pref-etched?

whitespaceninja commented 4 years ago

Is there a reason you can't resume where you left off next time using replay storage? There could be a bunch of messages queued up, and an arbitrary amount of time to process each one that depends on your program execution. Adding all that time up means you are delaying a system call to shut down for an undetermined amount of time.

welcomemat-services commented 2 years ago

@whitespaceninja,

I am having issues with reply storage with pulling the replay id and using it in the subsequent invocations.

Can you please take a look at this issue and see what I am doing wrong there? Thanks for any help on this.

https://github.com/robertmrk/aiosfstream/issues/19#issue-1126620196