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

Retention Policy For OPC Write #1

Open
panManfredini opened this issue Nov 6, 2019 · 2 comments
Open

Retention Policy For OPC Write #1

panManfredini opened this issue Nov 6, 2019 · 2 comments

Comments

@panManfredini
Copy link
Member

In the default topic config of kafka, a broker will retain data for that topic for a certain period.

Problem Case:
A consumer dies for long period of time, and a user sends a lot of OPC writes in that period. Kafka will retain those write request and will send the non-consumed data to the consumer as soon is available again.

Expected behavior:
The user does not expect that the actions he requested will be written unexpectedly as soon as the consumer is up again. This can be very dangerous.

Solution:
The WRITE topic must have a quite short life time, if messages are not delivered within a few second they will be lost. This can be achieved by changing the topic configuration.
Use the IAdminClient to:

  • Assess config of a topic, if topic exist
  • Create write topic if does not exists
  • Change configuration of topic, in particular set the property: "retention.ms" to a certain number of seconds, something like 5 or 10s.

To Do:
Need to add this call to the AdminClient to the constructor of the kafkaConsumer.

@panManfredini
Copy link
Member Author

panManfredini commented Nov 6, 2019

Nope... The topic retention policy doesn't need to be modified.
It is enough to set AutoOffsetReset = AutoOffsetReset.Latest in the consumerConfig.

@panManfredini
Copy link
Member Author

Au contraire...
AutoOffsetReset = AutoOffsetReset.Latest in the consumerConfig is not enough, it will always start from the latest not committed record, if any is committed.

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

1 participant