So the Kafka Mirror Maker source code has a decent readme.md.
How you configure it is different depending on if you're running MM2 directly or in Kafka Connect. You said directly, which is in the linked readme.md.
Basically:
By default, replicated topics are renamed based on "source cluster
aliases":
topic-1 --> source.topic-1
This can be customized by overriding the replication.policy.separator
property (default is a period). If you need more control over how
remote topics are defined, you can implement a custom
ReplicationPolicy and override replication.policy.class (default is
DefaultReplicationPolicy).
This unfortunately means that you cannot rename the topic through configuration code alone. (The DefaultReplicationPolicy class only allows you to specify the separator and nothing else). This is probably because when you specify the topics to mirror you use a regular expression, and not a single topic name (even if your source cluster topic config property is just the name of the topic - it's still treated like a regular expression).
So, back to the docs: ReplicationPolicy
is a Java interface in the Kafka connect source code, so you would need to implement a custom Java class that implements ReplicationPolicy
and then ensure it is on the classpath when you run MM2.
Let's imagine you do write such a class and you call it com.moffatt.kafka.connect.mirror.FooReplicationPolicy
. A good template for your class is the default (and apparently only) replication policy class that comes with Kafka Connect: DefaultReplicationPolicy
. You can see that building your own would not be too difficult. You could easily add a Map - either hard-coded or configured - that looks for specific configured topic names and maps it to the target topic name.
You use your new class by specifying it in the config as:
replication.policy.class = com.moffatt.kafka.connect.mirror.FooReplicationPolicy