-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSample.aplf
57 lines (45 loc) · 1.34 KB
/
Sample.aplf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Sample;start;cr
⍝ Topic created with
⍝
⍝ kafka-topics.sh \
⍝ --bootstrap-server localhost:9092 \
⍝ --create --topic "animals" \
⍝ --partitions 3
⍝ Call to Init function
Init 'path/to/dir/housing/kafka/shared/lib'
consumer←⎕NEW Consumer
consumer.configure'bootstrap.servers' 'localhost:9092' ⍝'grs3550.insight.local:9092'
consumer.configure'client.id' 'martina'⍝'bhcgrs3550'
consumer.configure'group.id' 'dyalog'
l←consumer.topic_partition
consumer.set_topic_partition l'animals'
consumer.subscribe_topic_partition l
⎕DL 5
bb←⎕NEW #.Record('animals' 'Blackbird' 'birds')
so←⎕NEW #.Record('animals' 'Sole' 'fish')
ef←⎕NEW #.Record('animals' 'Elefant' 'mamal')
producer←⎕NEW Producer
producer.configure'bootstrap.servers' 'localhost:9092'⍝'grs3550.insight.local:9092'
producer.configure'client.id' 'martina'⍝'bhc'
producer.produce_record bb
producer.produce_record so
producer.produce_record ef
⎕DL 1
producer.delivery_report 13
start←3⊃⎕AI
:While 1
cr←consumer.consume_record
:If 1=⊃cr
:AndIf 20000>(3⊃⎕AI)-start
⎕DL 0.2
:Continue
:ElseIf 0=⊃cr
(2⊃cr).(Topic Payload Key Partition)
start←0
:Else
cr
:Leave
:EndIf
:EndWhile
⎕EX'producer'
⎕EX'consumer'