I'm working a couple of Kafka connectors and I don't see any errors in their creation/deployment in the console output, however I am not getting the result that I'm looking for (no results whatsoever for that matter, desired or otherwise). I made these connectors based on Kafka's example FileStream connectors, so my debug technique was based off the use of the SLF4J Logger that is used in the example. I've searched for the log messages that I thought would be produced in the console output, but to no avail. Am I looking in the wrong place for these messages? Or perhaps is there a better way of going about debugging these connectors?
Example uses of the SLF4J Logger that I referenced for my implementation:
I will try to reply to your question in a broad way. A simple way to do Connector development could be as follows:
Make your connector package available to Kafka Connect in one of the following ways:
plugin.path
property in the Connect worker properties. For instance, if your connector jars are stored in/opt/connectors/my-first-connector
, you will setplugin.path=/opt/connectors
in your worker's properties (see below).${CONFLUENT_HOME}/share/java
. For example:${CONFLUENT_HOME}/share/java/kafka-connect-my-first-connector
. (Needs to start withkafka-connect-
prefix to be picked up by the startup scripts). $CONFLUENT_HOME is where you've installed Confluent Platform.Optionally, increase your logging by changing the log level for Connect in
${CONFLUENT_HOME}/etc/kafka/connect-log4j.properties
toDEBUG
or evenTRACE
.Use Confluent CLI to start all the services, including Kafka Connect. Details here: http://docs.confluent.io/current/connect/quickstart.html
Briefly:
confluent start
Once you have Connect worker running, start your connector by running:
confluent load <connector_name> -d <connector_config.properties>
or
confluent load <connector_name> -d <connector_config.json>
The connector configuration can be either in java properties or JSON format.
Run
confluent log connect
to open the Connect worker's log file, or navigate directly to where your logs and data are stored by runningcd "$( confluent current )"
Finally, to interactively debug your connector a possible way is to apply the following before starting Connect with Confluent CLI :
confluent stop connect
export CONNECT_DEBUG=y; export DEBUG_SUSPEND_FLAG=y;
confluent start connect
and then connect with your debugger (for instance remotely to the Connect worker (default port: 5005). To stop running connect in debug mode, just run:
unset CONNECT_DEBUG; unset DEBUG_SUSPEND_FLAG;
when you are done.I hope the above will make your connector development easier and ... more fun!
i love the accepted answer. one thing - the environment variables didn't work for me... i'm using confluent community edition 5.3.1...
here's what i did that worked...
i installed the confluent cli from here: https://docs.confluent.io/current/cli/installing.html#tarball-installation
i ran confluent using the command
confluent local start
i got the connect app details using the command
ps -ef | grep connect
i copied the resulting command to an editor and added the arg (right after java):
then i stopped connect using the command
confluent local stop connect
then i ran the connect command with the arg
brief intermission ---
intermission over ---
next i launched vs code and opened the debezium oracle connector folder (cloned from here) https://github.com/debezium/debezium-incubator
then i chose
Debug - Open Configurations
and entered the highlighted debugging configuration
and then run the debugger - it will hit your breakpoints !!
the connect command should look something like this: