Pil0tXia commented on code in PR #4837:
URL: https://github.com/apache/eventmesh/pull/4837#discussion_r1568230387


##########
eventmesh-connectors/eventmesh-connector-http/src/main/java/org/apache/eventmesh/connector/http/sink/handle/WebhookHttpSinkHandler.java:
##########
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.connector.http.sink.handle;
+
+import org.apache.eventmesh.common.exception.EventMeshException;
+import org.apache.eventmesh.connector.http.sink.config.HttpWebhookConfig;
+import org.apache.eventmesh.connector.http.sink.config.SinkConnectorConfig;
+import org.apache.eventmesh.openconnect.offsetmgmt.api.data.ConnectRecord;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpHeaders;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.core.http.HttpServerOptions;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.handler.LoggerHandler;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * HttpSinkHandler with webhook functionality
+ */
+@Slf4j
+public class WebhookHttpSinkHandler extends CommonHttpSinkHandler {
+
+    private final HttpWebhookConfig webhookConfig;
+
+    // store the callback data
+    private final BlockingQueue<JSONObject> callbackQueue;
+
+    // receive/export callback data
+    private HttpServer callbackServer;
+
+    public WebhookHttpSinkHandler(SinkConnectorConfig sinkConnectorConfig) {
+        super(sinkConnectorConfig);
+        this.webhookConfig = sinkConnectorConfig.getWebhookConfig();
+        this.callbackQueue = new LinkedBlockingQueue<>();
+    }
+
+    @Override
+    public void start() {
+        super.start();
+        // Create callback server
+        doInitCallbackServer();
+        // Start callback server
+        Throwable t = this.callbackServer.listen().cause();
+        if (t != null) {
+            throw new EventMeshException("Failed to start Vertx server. ", t);
+        }
+    }
+
+    private void doInitCallbackServer() {
+        final Vertx vertx = Vertx.vertx();
+        final Router router = Router.router(vertx);
+        // add logger handler
+        router.route().handler(LoggerHandler.create());
+
+        // add callback handler
+        router.route()
+            .path(this.webhookConfig.getCallbackPath())
+            .method(HttpMethod.POST)
+            .produces("application/json")

Review Comment:
   For `/callbackUrl` param, sink connector should be a client and send 
requests to callbackUrl (which is a server, and Event Target). I don't 
understand why `callback handler` is a vertx server here, shouldn't it be 
referencing WebClient?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@eventmesh.apache.org
For additional commands, e-mail: issues-h...@eventmesh.apache.org

Reply via email to