omearac / reactive-kafka-microservice-template Goto Github PK
View Code? Open in Web Editor NEWAn example of a microservice template which uses akka/reactive-kafka to stream JSON messages
License: Apache License 2.0
An example of a microservice template which uses akka/reactive-kafka to stream JSON messages
License: Apache License 2.0
The way I'm currently passing the actor system around to the various actors and traits may not be the cleanest.
See how I've used the implicits in AkkaStream, ConsumerStream, ProducerStream and EventSourcing Traits and how there likely is a better way to do this.
Hi,
Followed steps described in Link : https://github.com/omearac/reactive-kafka-microservice-template/blob/master/README.md to make kafka Up.
Getting below issue while running Main.scala
ERROR] a.a.RepointableActorRef: Error in stage [akka.kafka.internal.ProducerStage@9de0abb]: Invalid partition given with record: 4 is not in the range [0...0].
java.lang.IllegalArgumentException: Invalid partition given with record: 4 is not in the range [0...0].
at org.apache.kafka.clients.producer.KafkaProducer.partition(KafkaProducer.java:717) ~[kafka-clients-0.10.0.1.jar:na]
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:459) ~[kafka-clients-0.10.0.1.jar:na]
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:430) ~[kafka-clients-0.10.0.1.jar:na]
at akka.kafka.internal.ProducerStage$$anon$1$$anon$3.onPush(ProducerStage.scala:67) ~[akka-stream-kafka_2.11-0.13.jar:0.13]
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:747) ~[akka-stream_2.11-2.4.16.jar:na]
at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:710) ~[akka-stream_2.11-2.4.16.jar:na]
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:616) ~[akka-stream_2.11-2.4.16.jar:na]
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:471) ~[akka-stream_2.11-2.4.16.jar:na]
at akka.stream.impl.fusing.GraphInterpreterShell.receive(ActorGraphInterpreter.scala:410) ~[akka-stream_2.11-2.4.16.jar:na]
at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:603) ~[akka-stream_2.11-2.4.16.jar:na]
at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:618) ~[akka-stream_2.11-2.4.16.jar:na]
at akka.actor.Actor$class.aroundReceive(Actor.scala:496) ~[akka-actor_2.11-2.4.16.jar:na]
at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:529) ~[akka-stream_2.11-2.4.16.jar:na]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526) ~[akka-actor_2.11-2.4.16.jar:na]
at akka.actor.ActorCell.invoke(ActorCell.scala:495) ~[akka-actor_2.11-2.4.16.jar:na]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) ~[akka-actor_2.11-2.4.16.jar:na]
at akka.dispatch.Mailbox.run(Mailbox.scala:224) ~[akka-actor_2.11-2.4.16.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_131]
I have a question. I am confused with the comment in EventProducer.scala
- This actor receives local app events called "ExampleAppEvent"s which are initially published to the
- "internal" Akka Event Bus and which he is subscribed to. He then publishes the event messages to the Kafka
- topic called AppEventChannel. The idea would be that another microservice is subscribed to
- the AppEventChannel topic and can then react to events this microservice emits.
Does this mean a microservice communicates with another through both local event bus and Kafka?
If so, why do I need both?
Hello, I open this issue after seeing the details of the rest of the implementation. The previous issue is kind of related to this issue. The code should be refactored a bit. As this project is a template for future projects the high level of the structure should reflect that. I propose a structure like:
kafka
cordinators (or managers)
to separate the messaging layer from the light business logic. After that, inside Kafka there should be a high-level API for Consumer, Producer. Inside these objects should be placed the detailed API like Consumer.actor, Consumer.source, Producer.actor, Producer.sink, Flow, FlowACK. etc. All the deatils of the implementation should be placed in those classes and methods to abstract everything an give the user the ability to write simple code like:
val actorConsumer = Consumer.actor[String, String](topic: Topic, destination: ActorRef)
val source = Consumer.source[String, String](topic: Topic)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.