-
Notifications
You must be signed in to change notification settings - Fork 115
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
Using KafkaActor Producer to push Messages #131
Comments
Try moving the definition of the MyDummy case class above the test case definition, to avoid this problem. |
Cool! That got rid of the problem. But is there an explanation as to how this solves the problem? Curious to know? |
Not exactly sure. The TypeTag feature relies on reflection and implicits, which are prone to this kind of weirdness... |
How could I understand the TypeTaggedTrait? The code looks super simple and awesome but I can't reason out what this trait is actually doing! Could you please give me a short explanation? |
The TypeTaggedTrait is there to add the type tag derived from the extending class as a value. This allows preserving the type information in the runtime that would be otherwise lost due to type erasure. This is especially nice when combined with Akka actors where each message loses its type information. The problem that TypeTaggedTrait has is that it doesn't deal very well with inheritance: the cast operation matches on exact type rather than being aware of the type hierarchy. Here's some additional reading on the subject, if you're interested: https://www.cakesolutions.net/teamblogs/ways-to-pattern-match-generic-types-in-scala |
I do understand the TypeTag in Scala and why it is needed. I wanted to understand what roles does the TypeTaggedTrait play in the application. For example., the ProducerRecord usage is like this:
How does each of the methods implemented in the TypeTaggedTrait relate to the ProducerRecords? |
It's there so that the actors that receive those records (in this case the producer actor), can pattern match on only The pattern match for the producer actor is effectively a function from |
I can see some documentation on how to use the KafkaActor Consumer, but there is very little information on how to use the KafkaActor Producer. I want to push a message that is contained as a case class into a Topic. For this purpose (Just to see how it might work), I just copied one of the tests and tried to run it:
So as it can be seen that I want to push the MyDummy into the Kafka topic, but I get the following errors:
I'm just not sure how to get past the compiler. Any help?
The text was updated successfully, but these errors were encountered: