Skip to content

Instantly share code, notes, and snippets.

View suhothayan's full-sized avatar

Suho suhothayan

  • Confluent
  • Canada
  • 11:05 (UTC -07:00)
View GitHub Profile
@suhothayan
suhothayan / NotificationManagement.siddhi.sql
Last active December 12, 2018 12:28
Streaming App for Notification Management
@App:name('NotificationManagement')
@App:description('Streaming App for Notification Management')
@source(type = 'kafka',
topic.list = 'shipment-info', bootstrap.servers = 'localhost:9092',
group.id = 'test', threading.option = 'single.thread',
is.binary.message = 'true',
@map(type = 'avro'))
define stream ShipmentInfoStream (orderId string, buyerId string, shipmentType string);
@suhothayan
suhothayan / SimpleFilterSample.java
Created April 2, 2019 13:24
Sample Siddhi 5.x code on Java
package io.siddhi.sample;
import io.siddhi.core.SiddhiAppRuntime;
import io.siddhi.core.SiddhiManager;
import io.siddhi.core.event.Event;
import io.siddhi.core.stream.input.InputHandler;
import io.siddhi.core.stream.output.StreamCallback;
import io.siddhi.core.util.EventPrinter;
/**
@suhothayan
suhothayan / CountOverTime.siddhi
Last active April 19, 2019 06:54
Siddhi app that receives events via HTTP, and logs the number of events received during last 15 seconds.
@App:name('CountOverTime')
@App:description('Receive events via HTTP, and logs the number of events received during last 15 seconds')
@source(type = 'http', receiver.url = "http://0.0.0.0:8006/production",
@map(type = 'json'))
define stream ProductionStream (name string, amount double);
@sink(type = 'log')
define stream TotalCountStream (totalCount long);
@suhothayan
suhothayan / ConsumeAndStore.siddhi
Last active April 19, 2019 06:52
Consume events from HTTP and write to TEST_DB
@App:name("ConsumeAndStore")
@App:description("Consume events from HTTP and write to TEST_DB")
@source(type = 'http', receiver.url = "http://0.0.0.0:8006/production",
@map(type = 'json'))
define stream ProductionStream (name string, amount double);
@store(type='rdbms', datasource='TEST_DB')
define table ProductionTable (name string, amount double);
@suhothayan
suhothayan / TestDb.yaml
Last active April 10, 2019 20:08
Siddhi runner config yaml containing connection information on TEST_DB datasource which is based on H2 database.
wso2.datasources:
dataSources:
- name: TEST_DB
description: The datasource used for testing
definition:
type: RDBMS
configuration:
jdbcUrl: 'jdbc:h2:${sys:carbon.home}/wso2/${sys:wso2.runtime}/database/TEST_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000'
username: admin
password: admin
@suhothayan
suhothayan / TemplatedFilterAndEmail.siddhi
Last active April 19, 2019 06:52
Consumes events from HTTP, filters them based on `amount` greater than a templated threshold value, and sends filtered events via email.
@App:name("TemplatedFilterAndEmail")
@App:description("Consumes events from HTTP, filters them based on amount greater than a templated threshold value, and sends filtered events via email.")
@source(type = 'http', receiver.url = "http://0.0.0.0:8006/production",
@map(type = 'json'))
define stream ProductionStream (name string, amount double);
@sink(ref = 'email-sink', subject = 'High {{name}} production!', to = '${TO_EMAIL}', content.type = 'text/html',
@map(type = 'text',
@payload("""
@suhothayan
suhothayan / EmailConfig.yaml
Last active April 11, 2019 23:24
Siddhi email config yaml
siddhi:
refs:
-
ref:
name: 'email-sink'
type: 'email'
properties:
port: '465'
host: 'smtp.gmail.com'
ssl.enable: 'true'