Hello,

Nobody has experience with Kafka Connect tasks with external dependencies?

 

Thanks,

Petr

 

From: Petr Novak [mailto:oss.mli...@gmail.com] 
Sent: 23. února 2017 14:48
To: users@kafka.apache.org
Subject: Pattern to create Task with dependencies (DI)

 

Hello,

it seems that KConnect take control over creating task instance and requires
no-arg constructor. What is the recommended pattern when I need to create a
task which has dependency e.g. on some db client and I want to be able to
pass in mock in tests, preferable through constructor?

In Java I probably have to divide actual task implementation into separate
class and use method forwarding from task factory class. I assume that this
factory, whose class would be passed to KConnect, requires to extend
abstract class whose “this” I have to pass to implementing class as another
dependency. I can’t figure out anything less ugly.

 

In Scala it can be done elegantly through mixin composition which is
invisible to KConnect. 

 

Why KConnect does take control from me how tasks are created? Why KConnect
doesn’t accept factory class on which it would call no-arg create method
which would return instance of my task so that I can control how it is
created and which dependencies are created. Or instead of getTaskClass() to
have createTask() on Connector which returns task instance.

 

Many thanks for advice,

Petr

Reply via email to