Skip to content

Commit 11b8a20

Browse files
committed
integration_test.py: enable api.version.request by default to make timestamp() meaningful
1 parent 6245533 commit 11b8a20

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

examples/integration_test.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
# Topic to use
3939
topic = 'test'
4040

41+
# API version requests are only implemented in Kafka broker >=0.10
42+
# but the client handles failed API version requests gracefully for older
43+
# versions as well, except for 0.9.0.x which will stall for about 10s
44+
# on each connect with this set to True.
45+
api_version_request = True
46+
4147
# global variable to be set by stats_cb call back function
4248
good_stats_cb_result = False
4349

@@ -85,6 +91,7 @@ def verify_producer():
8591
# Producer config
8692
conf = {'bootstrap.servers': bootstrap_servers,
8793
'error_cb': error_cb,
94+
'api.version.request': api_version_request,
8895
'default.topic.config':{'produce.offset.report': True}}
8996

9097
# Create producer
@@ -121,6 +128,7 @@ def verify_producer():
121128
def verify_producer_performance(with_dr_cb=True):
122129
""" Time how long it takes to produce and delivery X messages """
123130
conf = {'bootstrap.servers': bootstrap_servers,
131+
'api.version.request': api_version_request,
124132
'error_cb': error_cb}
125133

126134
p = confluent_kafka.Producer(**conf)
@@ -214,7 +222,7 @@ def verify_consumer():
214222
'group.id': 'test.py',
215223
'session.timeout.ms': 6000,
216224
'enable.auto.commit': False,
217-
'api.version.request': True,
225+
'api.version.request': api_version_request,
218226
'on_commit': print_commit_result,
219227
'error_cb': error_cb,
220228
'default.topic.config': {
@@ -247,11 +255,10 @@ def verify_consumer():
247255
print('Consumer error: %s: ignoring' % msg.error())
248256
break
249257

250-
if False:
251-
tstype, timestamp = msg.timestamp()
252-
print('%s[%d]@%d: key=%s, value=%s, tstype=%d, timestamp=%s' % \
253-
(msg.topic(), msg.partition(), msg.offset(),
254-
msg.key(), msg.value(), tstype, timestamp))
258+
tstype, timestamp = msg.timestamp()
259+
print('%s[%d]@%d: key=%s, value=%s, tstype=%d, timestamp=%s' % \
260+
(msg.topic(), msg.partition(), msg.offset(),
261+
msg.key(), msg.value(), tstype, timestamp))
255262

256263
if (msg.offset() % 5) == 0:
257264
# Async commit

0 commit comments

Comments
 (0)