- Newest
- Most votes
- Most comments
Hi @Bombardi, Your approach is great, but won't work specifically with managed Kafka Connect. When you submit a JAR as a plugin, it doesn't get added to the classpath of kafka connect worker. It goes into a plugin dir. Each plugin has it's own classloader for isolation of the dependencies, etc. This is how Kafka Connect workers are using plugins. So, this means that the MirrorSource Connector won't see the libraries and classes for a custom replication policy.
Alternatively, if you are just trying to achieve same topic name replication, there is an IdentityReplicationPolicy available in Kafka 3. To use it, define your MM2 connector to run in MSK Connect using version 3.7
EDIT (addresses complete change of a topic name):
You can use SMT to change a topic name. Since the question explicitly provides one specific name to another specific name, the regex is concrete. Add this to the mirrorsource connector:
# other properties...
"transforms":"changeABCtoXYZ",
"transforms.changeABCtoXYZ.type": "org.apache.kafka.connect.transforms.RegexRouter",
"transforms.changeABCtoXYZ.regex": "ABC",
"transforms.changeABCtoXYZ.replacement": "XYZ",
# other properties...
The error you're encountering suggests that the custom replication policy class is not being found in the classpath of the MSK Connector. Here are some steps to troubleshoot and resolve this issue:
-
Ensure your custom JAR file is properly packaged:
- The JAR file should contain your compiled class files in the correct package structure.
- The manifest file in the JAR should correctly specify the main class if necessary.
-
Verify the contents of your connector.zip:
- The CustomReplicationPolicy-3.7.1.jar should be directly in the root of the zip file, not just in the lib/ directory.
- Remove any __MACOSX directories and hidden files, as they are not needed and may cause issues.
-
Double-check your connector configuration:
- Make sure the replication.policy.class property is correctly set to the full class name, including the package.
- Verify there are no typos in the class name or package name.
-
Consider using a custom plugin:
- Instead of including your custom class directly in the connector configuration, you might need to create a custom plugin for MSK Connect.
- This involves creating a manifest file that specifies your custom classes and packaging it with your JAR file.
-
Verify compatibility:
- Ensure your custom class is compatible with the version of Kafka and MirrorMaker 2 used by MSK Connect.
-
Check MSK Connect logs:
- If possible, review the MSK Connect logs for any additional error messages or stack traces that might provide more information about why the class isn't being found.
If you've verified all these points and are still encountering issues, you may need to contact AWS support for further assistance, as there might be limitations or specific requirements for custom classes in MSK Connect that are not immediately apparent.
Sources
MSK connector failed to find class in MSK cluster with KRaft mode | AWS re:Post
Connect to AWS MSK cluster from Local mac | AWS re:Post
All the suggestion doesn't resolve the problem.
Relevant content
- asked a year ago
- asked 7 months ago
Oh got it, I can replace that, but which property can I use to change the target topic name?
Also, maybe I didn't clarify it very well. But I'd need a complete different name from the source, not keep the same (with or without prefixes). You can assume that source is "ABC" and I'd like to know how to set the target to be "XYZ".