-
Notifications
You must be signed in to change notification settings - Fork 12
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
How to create separate consumer for every Table #11
Comments
Yes, this pattern is supported - e.g. the Could you show your |
This is my reader config. factory := newFactory(logger, stream) // return *factory
logger := log.New(os.Stderr, "", log.Ldate|log.Lmicroseconds|log.Lshortfile)
progressManager, err := scyllacdc.NewTableBackedProgressManager(sess.Session, "cdc_progress", "scylla_sync")
...
cfg := &scyllacdc.ReaderConfig{
Session: sess.Session,
TableNames: []string{c.CQL_KEYSPACE + "." + consumer.FRIEND_RELATIONS_TABLE, c.CQL_KEYSPACE + "." + consumer.PARTY_FAVORITES_TABLE},
ProgressManager: progressManager,
ChangeConsumerFactory: factory,
Logger: logger,
Advanced: scyllacdc.AdvancedReaderConfig{
PostEmptyQueryDelay: time.Second * 1,
PostNonEmptyQueryDelay: time.Second * 1,
PostFailedQueryDelay: time.Second * 1,
ConfidenceWindowSize: time.Second * 1,
QueryTimeWindowSize: time.Second * 10,
ChangeAgeLimit: time.Second * 10,
},
} type factory struct {
logger scyllacdc.Logger
stream stream.Stream // Nats connection
nextID int
}
func newFactory(logger scyllacdc.Logger, stream stream.Stream) *factory {
return &factory{
logger: logger,
stream: stream,
}
} These are my logs
I already had a look at the replicator Example but I couldn't find the lines in the |
The replicator example creates a separate consumer for each stream - see If by "different consumers" you meant consumers of different type, then it should be supported as well - the library doesn't assume anywhere that all consumers must have the same type.
Judging by the logs, this is most likely caused by the bug described in #8. If you start your application for the first time but it won't consume any rows (or too little of them), then the progress for individual streams won't be saved and, on restart, the library will default to the time of the most recent generation (which usually happens during a topology change) before the application was started - in your case, it looks like it was around In order to fix this situation, you can drop/truncate the progress table, then ensure that enough data is written to the CDC log - the library will start reading from Alternatively, you can disable the progress saving feature. |
I have disabled saving progress for now, and it works. I can receive changes with both Consumer types. |
Issue was resolved, closing it. |
I have created my own
factory
struct to dinamically create consumers based on the input Tablenames.Both the
FriendRelationConsumer
andPartyFavoritesConsumer
implement theChangeConsumer
interface, but they both don't receive changes to the table.Is this pattern supported or is their another way to handle separate Consumers for every table?
Or should I just create a global consumer that gets all changes from everyt table?
The text was updated successfully, but these errors were encountered: