Set up Flink connector

Updated at:

Write data to RecallEngine

Activate Realtime Compute for Apache Flink and create a workspace to write data to RecallEngine in real time by using Flink jobs.

Prerequisites

  • You have activated Realtime Compute for Apache Flink and created a workspace.

  • You have created a RecallEngine instance and obtained its endpoint, instance ID, username, and password.

Procedure

1. Select a connector version

The following table lists RecallEngine connector versions and their compatible Flink versions.

Connector version

Flink version

Description

1.0.8 (Download)

vvr-11.x/flink-1.20

Supports asynchronous batch writes.

1.0.7 (Download)

vvr-11.x/flink-1.20

1.0.7 (Download)

vvr-8.x/flink-1.17

2. Register the connector

  1. Log on to the Realtime Compute console.

  2. On the Connectors page, select Custom Connector and click Create Custom Connector.

  3. Upload the downloaded RecallEngine connector JAR file.

  4. Click Next, optionally configure the connector properties, and then click Finish.

The properties of the recallengine connector include endpoint, instance, username, password, table, and connector (all required), and retry_time (with a default value of 3). You can modify these properties as needed and then click Finish.

3. Edit the job

Use the RecallEngine connector in your Flink SQL job to write data to RecallEngine.

Flink SQL example

1. Create a target table

Create a target table in RecallEngine and define its schema before you run the job.

2. Write data

The following example uses Flink SQL to write data to RecallEngine.

Define a source table:

CREATE TEMPORARY TABLE source_table (
    user_id BIGINT,
    item_id BIGINT,
    score FLOAT,
    tag STRING
) WITH (
    'connector' = 'datagen',
    'rows-per-second' = '10'
);

Define a RecallEngine sink table:

CREATE TEMPORARY TABLE recallengine_sink (
    user_id BIGINT,
    item_id BIGINT,
    score FLOAT,
    tag STRING
) WITH (
    'connector' = 'recallengine',
    'endpoint' = 'http://<your-endpoint>',
    'instance_id' = '<your-instance-id>',
    'table' = '<your-table-name>',
    'username' = '<your-username>',
    'password' = '<your-password>'
);

Execute the write operation:

INSERT INTO recallengine_sink
SELECT user_id, item_id, score, tag
FROM source_table;

Supported data types

The RecallEngine Flink connector supports these Flink SQL data types:

Type

Description

INT

32-bit integer

BIGINT

64-bit integer

FLOAT

Single-precision floating-point number

DOUBLE

Double-precision floating-point number

VARCHAR / STRING

String

BOOLEAN

Boolean value

TIMESTAMP

Timestamp. Converted to a string when written.

TIMESTAMP_LTZ

Timestamp with local time zone. Converted to a string when written.

DATE

Date. Converted to a string in yyyy-MM-dd format when written.

ARRAY<INT>

Array of integers

ARRAY<BIGINT>

Array of 64-bit integers

ARRAY<FLOAT>

Array of single-precision floating-point numbers

ARRAY<DOUBLE>

Array of double-precision floating-point numbers

ARRAY<VARCHAR>

Array of strings

Connector properties

Parameter

Type

Required

Default

Description

connector

string

Yes

N/A

Set to recallengine.

endpoint

string

Yes

N/A

The RecallEngine service endpoint. Find it in the service domain list on the Basic Information page of Recall Management.

instance_id

string

Yes

N/A

The ID of the RecallEngine instance.

table

string

Yes

N/A

The name of the target table.

username

string

Yes

N/A

The username for authentication.

password

string

Yes

N/A

The password for authentication.

retry_times

int

No

3

The number of times to retry a failed write operation.

authorization

string

No

N/A

The Authorization request header value. Use this for custom authentication.

Usage notes

  • The RecallEngine connector only supports the sink (write) operation. It does not support source (read) or lookup join operations.

  • The connector processes INSERT and UPDATE_AFTER changes. Other change types, such as DELETE and UPDATE_BEFORE, are ignored.

  • Each record is sent individually. For high-throughput requirements, configure an appropriate degree of parallelism for the Flink job.