@@ -28,7 +28,6 @@ public final class QuestDBSinkTask extends SinkTask {
28
28
private static final char STRUCT_FIELD_SEPARATOR = '_' ;
29
29
private static final String PRIMITIVE_KEY_FALLBACK_NAME = "key" ;
30
30
private static final String PRIMITIVE_VALUE_FALLBACK_NAME = "value" ;
31
- private static final long FLUSH_INTERVAL_NANOS = TimeUnit .SECONDS .toNanos (1 );
32
31
33
32
private static final Logger log = LoggerFactory .getLogger (QuestDBSinkTask .class );
34
33
private Sender sender ;
@@ -46,8 +45,7 @@ public final class QuestDBSinkTask extends SinkTask {
46
45
private int allowedLag ;
47
46
private long nextFlushNanos ;
48
47
private int pendingRows ;
49
- private final int maxPendingRows = 75_000 ;
50
- private FlushConfig flushConfig = new FlushConfig ();
48
+ private final FlushConfig flushConfig = new FlushConfig ();
51
49
52
50
@ Override
53
51
public String version () {
@@ -84,7 +82,7 @@ public void start(Map<String, String> map) {
84
82
this .kafkaTimestampsEnabled = config .isDesignatedTimestampKafkaNative ();
85
83
this .timestampUnits = config .getTimestampUnitsOrNull ();
86
84
this .allowedLag = config .getAllowedLag ();
87
- this .nextFlushNanos = System .nanoTime () + FLUSH_INTERVAL_NANOS ;
85
+ this .nextFlushNanos = System .nanoTime () + flushConfig . autoFlushNanos ;
88
86
}
89
87
90
88
private Sender createRawSender () {
@@ -98,9 +96,12 @@ private Sender createRawSender() {
98
96
log .debug ("Using client configuration string" );
99
97
StringSink sink = new StringSink ();
100
98
httpTransport = ClientConfUtils .patchConfStr (confStr , sink , flushConfig );
99
+ if (!httpTransport ) {
100
+ log .info ("Using TCP transport, consider using HTTP transport for improved fault tolerance and error handling" );
101
+ }
101
102
return Sender .fromConfig (sink );
102
103
}
103
- log .debug ( "Using legacy client configuration" );
104
+ log .warn ( "Configuration options 'host', 'tsl', 'token' and 'username' are deprecated and will be removed in the future. Use ' client.conf.string' instead. See: https://questdb.io/docs/third-party-tools/kafka/questdb-kafka/# configuration-options " );
104
105
Sender .LineSenderBuilder builder = Sender .builder (Sender .Transport .TCP ).address (config .getHost ());
105
106
if (config .isTls ()) {
106
107
builder .enableTls ();
@@ -159,9 +160,9 @@ public void put(Collection<SinkRecord> collection) {
159
160
}
160
161
161
162
if (httpTransport ) {
162
- if (pendingRows >= maxPendingRows ) {
163
+ if (pendingRows >= flushConfig . autoFlushRows ) {
163
164
log .debug ("Flushing data to QuestDB due to auto_flush_rows limit [pending-rows={}, max-pending-rows={}]" ,
164
- pendingRows , maxPendingRows );
165
+ pendingRows , flushConfig . autoFlushRows );
165
166
flushAndResetCounters ();
166
167
} else {
167
168
long remainingNanos = nextFlushNanos - System .nanoTime ();
@@ -205,7 +206,7 @@ private void flushAndResetCounters() {
205
206
log .debug ("Flushing data to QuestDB" );
206
207
try {
207
208
sender .flush ();
208
- nextFlushNanos = System .nanoTime () + FLUSH_INTERVAL_NANOS ;
209
+ nextFlushNanos = System .nanoTime () + flushConfig . autoFlushNanos ;
209
210
pendingRows = 0 ;
210
211
} catch (LineSenderException | HttpClientException e ) {
211
212
onSenderException (e );
@@ -215,7 +216,7 @@ private void flushAndResetCounters() {
215
216
private void onSenderException (Exception e ) {
216
217
if (httpTransport ) {
217
218
closeSenderSilently ();
218
- nextFlushNanos = System .nanoTime () + FLUSH_INTERVAL_NANOS ;
219
+ nextFlushNanos = System .nanoTime () + flushConfig . autoFlushNanos ;
219
220
pendingRows = 0 ;
220
221
throw new ConnectException ("Failed to send data to QuestDB" , e );
221
222
}
0 commit comments