Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:APIJSON APIJSON Demo DemoSQLExecutor Kafka

From Leeroopedia
Knowledge Sources
Domains Messaging, Kafka, SQL_Execution
Last Updated 2026-10-14 00:00 GMT

Overview

Concrete tool for intercepting POST operations to route inserts to Kafka as message production instead of SQL inserts.

Description

The DemoSQLExecutor class (Kafka variant) extends APIJSONSQLExecutor<String> and overrides executeUpdate to detect the Kafka datasource. When the datasource is "kafka" and the method is POST, it extracts the message column from the request values and sends it to Kafka via KafkaSimpleProducer.sendMessage. For non-Kafka datasources, it falls back to standard JDBC execution.

Usage

Use this class when the APIJSON Kafka demo needs to produce messages to Kafka topics via APIJSON POST requests.

Code Reference

Source Location

Signature

@Log4j2
public class DemoSQLExecutor extends APIJSONSQLExecutor<String> {
    @Override
    public Connection getConnection(SQLConfig config) throws Exception;
    @Override
    public int executeUpdate(@NotNull SQLConfig config, String sql) throws Exception;
}

Import

import apijson.demo.DemoSQLExecutor;

I/O Contract

Inputs

Name Type Required Description
config SQLConfig Yes SQL config with datasource="kafka"
sql String Yes Generated SQL (used for non-Kafka fallback)

Outputs

Name Type Description
executeUpdate() returns int Number of messages sent (1 on success)

Usage Examples

Send Message to Kafka via APIJSON

// APIJSON POST to Kafka datasource
{
  "kafka_topic": {
    "message": "Hello Kafka from APIJSON"
  }
}
// DemoSQLExecutor intercepts and sends to Kafka producer

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment