successfully create KC websocket connector (not sure if it works though...)
This commit is contained in:
parent
427b8951d3
commit
83c991842f
7 changed files with 94 additions and 13 deletions
|
|
@ -15,7 +15,8 @@ services:
|
|||
# CAMEL_KC_VERSION: ${CONNECTOR_CAMEL_KAFKA_VERSION}
|
||||
# CAMEL_CONNECTOR: ${CAMEL_FILE_CONNECTOR}
|
||||
ports:
|
||||
- "28083:28083"
|
||||
- "8083:8083"
|
||||
- "8095:8095"
|
||||
# volumes:
|
||||
# - "./connect/input:/warehouse/input"
|
||||
# - "./connect/components:/usr/share/confluent-hub-components"
|
||||
|
|
@ -28,7 +29,8 @@ services:
|
|||
CONNECT_BOOTSTRAP_SERVERS: "kafka:29092"
|
||||
CONNECT_REST_ADVERTISED_HOST_NAME: ${CONNECTOR_ID}
|
||||
# CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL: "http://${SCHEMA_REGISTRY}:8081"
|
||||
CONNECT_REST_PORT: 28083
|
||||
# CONNECT_REST_PORT: 28083
|
||||
CONNECT_REST_PORT: 8083
|
||||
CONNECT_GROUP_ID: ${CONNECTOR_ID}
|
||||
CONNECT_CONFIG_STORAGE_TOPIC: ${CONNECTOR_ID}-configs
|
||||
CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: 1
|
||||
|
|
@ -40,9 +42,10 @@ services:
|
|||
CONNECT_KEY_CONVERTER: "org.apache.kafka.connect.storage.StringConverter"
|
||||
# CONNECT_VALUE_CONVERTER: "io.confluent.connect.avro.AvroConverter"
|
||||
CONNECT_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
|
||||
CONNECT_PLUGIN_PATH: "/usr/share/java,/usr/share/confluent-hub-components"
|
||||
CONNECT_PLUGIN_PATH: "/usr/share/java,/usr/share/camel-kafka-connectors"
|
||||
CONNECT_LOG4J_ROOT_LOGLEVEL: INFO
|
||||
CONNECT_LOG4J_LOGGERS: "org.apache.zookeeper=INFO,org.I0Itec.zkclient=ERROR,org.reflections=ERROR"
|
||||
# CONNECT_LISTENERS: "http://localhost:28083"
|
||||
|
||||
networks:
|
||||
kafkatorio-nw:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ ENV CONNECT_VERSION=${KAFKA_CONNECT_VERSION}
|
|||
|
||||
USER 0:0
|
||||
|
||||
COPY ./camel-kafka-connectors /usr/share/java/
|
||||
COPY ./camel-kafka-connectors /usr/share/camel-kafka-connectors
|
||||
|
||||
#WORKDIR /usr/share/java/
|
||||
#
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package dev.adamko.kafkatorio.kafkaconnect
|
||||
|
||||
import java.io.File
|
||||
|
||||
object Resources {
|
||||
fun loadResource(name: String): File =
|
||||
File(requireNotNull(Resources::class.java.getResource(name)?.file) {
|
||||
"could not load resource '$name'"
|
||||
})
|
||||
}
|
||||
|
|
@ -3,10 +3,15 @@ package dev.adamko.kafkatorio.kafkaconnect
|
|||
import at.syntaxerror.json5.Json5Module
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import org.http4k.client.OkHttp
|
||||
import org.http4k.core.Method.GET
|
||||
import org.http4k.core.Method.PUT
|
||||
import org.http4k.core.Request
|
||||
import org.http4k.core.Uri
|
||||
|
||||
val jsonMapper = Json {
|
||||
prettyPrint = true
|
||||
|
|
@ -15,6 +20,42 @@ val jsonMapper = Json {
|
|||
|
||||
val j5 = Json5Module()
|
||||
|
||||
fun main() {
|
||||
|
||||
val connectorHostUrl = Uri.of("http://localhost:8083")
|
||||
|
||||
val configFile = Resources.loadResource("/configs/websocket-sink-lua-topics.json5")
|
||||
|
||||
val jsonObject: JsonObject = j5.decodeObject(configFile.readText())
|
||||
println("json5 connector config: $jsonObject")
|
||||
val configJson = jsonMapper.encodeToString(jsonObject)
|
||||
println("json connector config: $configJson")
|
||||
|
||||
val connectorName = jsonObject["name"]!!.jsonPrimitive.content
|
||||
|
||||
val request: Request =
|
||||
Request(PUT, connectorHostUrl.path("/connectors/$connectorName/config"))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Accept", "application/json")
|
||||
// .header("Accept-Encoding", "identity")
|
||||
.body(configJson)
|
||||
|
||||
val client = OkHttp()
|
||||
|
||||
// check the status of KC
|
||||
val statusResponse = client(Request(GET, connectorHostUrl))
|
||||
println(statusResponse.toMessage())
|
||||
|
||||
val response = client(request)
|
||||
|
||||
println(response.toMessage())
|
||||
println(
|
||||
jsonMapper.encodeToString(
|
||||
jsonMapper.decodeFromString<JsonElement>(response.body.toString())
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
//val updateConnectors by tasks.registering {
|
||||
// group = project.name
|
||||
//
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
// mandatory properties (for a complete properties list see the connector documentation):
|
||||
|
||||
// The URI to use such as http://hostname:port/path
|
||||
"camel.sink.path.httpUri": "http://localhost:/ws",
|
||||
"camel.sink.path.httpUri": "http://localhost:8095/ws",
|
||||
// If the option is true, then the Exchange.HTTP_URI header is ignored, and use the endpoint's URI for request. You may also set the throwExceptionOnFailure to be false to let the AhcProducer send all the fault response back.
|
||||
// camel.sink.endpoint.bridgeEndpoint=
|
||||
// The initial in-memory buffer size used when transferring data between Camel and AHC Client.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue