Skip to content

Instantly share code, notes, and snippets.

@chanakaudaya
Created September 2, 2020 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanakaudaya/efe8dfed2558811f0316a7839dbfef57 to your computer and use it in GitHub Desktop.
Save chanakaudaya/efe8dfed2558811f0316a7839dbfef57 to your computer and use it in GitHub Desktop.
Sample siddhi application to read from a Kafka topic and publish through a WebSocket server
@App:name("KafkaToWebSocket")
@App:description('Consume events from a Kafka Topic and log the messages on the console.')
@source(type='kafka',
topic.list='productions',
threading.option='single.thread',
group.id="group1",
bootstrap.servers='localhost:9092',
@map(type='json'))
define stream SweetProductionStream (name string, amount double);
@sink(type='websocket-server', host='localhost', port='8025',
@map(type='json'))
define stream LowProductionAlertStream (name string, amount double);
@sink(type='log')
define stream OutputStream (name string, amount double);
from SweetProductionStream
select str:upper(name) as name, amount
insert into OutputStream;
from SweetProductionStream[amount < 500]
select str:upper(name) as name, amount
insert into LowProductionAlertStream;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment