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

#46 - Implement KafkaSerializer for JSON serialization instead using … #49

Closed
wants to merge 6 commits into from

Conversation

ttimot24
Copy link
Contributor

No description provided.

@ttimot24
Copy link
Contributor Author

Event and AdminEvent does not have a common parent class. Because of this Object is needed.

}

@Override
public byte[] serialize(String topic, Object data) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference to org.apache.kafka.common.serialization.BytesSerializer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It throws exception on Events and AdminEvents

Map<String, Object> optionalProperties) {
Properties props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer);
props.put(ProducerConfig.CLIENT_ID_CONFIG, clientId);
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, JsonSerializer.class.getName());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a breaking change for all system that uses plain json strings. I think it would be much better to make this configurable and rely and on the default serializer from the org.apache.kafka.common.serialization package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right, it was a mistake to change the KEY_SERIALIZER. I fixed it.
In my next PR both will be configurable. Thank you!

@ttimot24
Copy link
Contributor Author

ttimot24 commented Sep 20, 2024

@SnuK87 So I managed to solve the issues but it required huge modifications on the code. Please feel free to decide if you want to merge it or not. All of your unit tests passes.

I think with this AVRO improvement this SPI could be used in large scale projects with confidence.

Thank you!

@SnuK87
Copy link
Owner

SnuK87 commented Sep 21, 2024

This change would destroy the whole purpose of this library. It should be as generic as possible, can be easily used with standard kafka and keycloak setups and is easy to customize for your specific use case (which is your case I guess).

Here are some things that would make this library useless for other people:

  • What if you want protobuf instead of avro?
  • Producing custom events instead of the original from keycloak makes integration more difficult
  • Will this even work with plain JSON?
  • Size of fat jar is more than 4x size

@SnuK87 SnuK87 closed this Sep 21, 2024
@ttimot24
Copy link
Contributor Author

It's ok if you don't merge this one. I understand.

  1. Currently can not be used any of them in this repo nor JSON Schema
  2. Event and AdminEvent the two thing that Keycloak produces
  3. Yes
  4. Yepp

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

Successfully merging this pull request may close these issues.

2 participants