Skip to content
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

Passing a dictionary to the replay param? #16

Closed
joshua-nicholson opened this issue Jan 27, 2021 · 3 comments
Closed

Passing a dictionary to the replay param? #16

joshua-nicholson opened this issue Jan 27, 2021 · 3 comments

Comments

@joshua-nicholson
Copy link

The docs say you can use a dictionary to pass the replay param of the client.

replay (Union[ReplayOption, ReplayMarkerStorage, Mutablemapping[str, ReplayMarker]]) – A ReplayOption or an object capable of storing replay ids if you want to take advantage of Salesforce’s replay extension. You can use one of the ReplayOptions, or an object that supports the MutableMapping protocol like dict, defaultdict, Shelf etc. or a custom ReplayMarkerStorage implementation.

I'm not exactly clear on what this dictionary needs to contain though. I see it needs a string and a ReplayMarker so I tried this

replay={"replay": ReplayMarker("2021-01-27T18:33:19.087Z", 272625)}

But I don't seem to pull in any previous events. These are hardcoded for now for testing purposes, I'll dynamically retrieve them from the last successful event once I get this working.

@ghost
Copy link

ghost commented Jan 18, 2022

I was experiencing the same issue, I know this is a year old but still!

I got it working doing this, unsure if it's the intended way:

from aiosfstream import SalesforceStreamingClient, ReplayOption, DefaultMappingStorage

replay = DefaultMappingStorage({}, self.max_stored_replay_id)
logging.info(f'Retrieving Messages since replay_id: {self.max_stored_replay_id}')

client = SalesforceStreamingClient(consumer_key=self.consumer_key,
                                                            consumer_secret=self.consumer_secret,
                                                            username=self.username,
                                                            password=self.password,
                                                            sandbox=self.sandbox,
                                                            replay=replay,
                                                            replay_fallback=ReplayOption.NEW_EVENTS
                                           )

I'm storing the replay_id and checking it on client creation.

@welcomemat-services
Copy link

@charlie-peak-ai I am using my own ReplayMarkerStorage and having issues with retrieving events by passing a replay id stored in pgsql. I believe, I have followed all required steps yet if pull the last stored replay id and pass it, it is throwing an exception. I have created a new issue here, please let me know if you see any thing unusual in my code.

#19 (comment)

@joshua-nicholson
Copy link
Author

Thank you @charlie-peak-ai! I just had to revisit this now almost two years later from my original question and I was able to get it to work using the code you provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants