Publishing Text Events via Email¶
This application demonstrates how to use siddhi-io-email for publishing events to files.
- Replace the Sink configuration values for following options.
- you need to enable access to "less secure apps" in the sender's Gmail account via "https://myaccount.google.com/lesssecureapps" link
- Save this sample
Executing the Sample:¶
- Start the Siddhi application by clicking on 'Run'
- If the Siddhi application starts successfully, the following messages would be shown on the console
- PublishEmailInTextFormat.siddhi - Started Successfully!.
Testing the Sample:¶
- Click on 'Event Simulator' (double arrows on left tab)
- Click 'Single Simulation' (this will be already selected)
- Select PublishEmailInTextFormat as 'Siddhi App Name'
- Select SweetProductionStream as 'StreamName'
- Provide attribute values
- name: chocolate cake
- amount: 10.10
- Click on the start button (Arrow symbol) next to the newly created simulator
Viewing the Results:¶
Check the receiver Gmail inbox (The Gmail referred to in 'to' Sink configuration) to see the alert similar to the following.
Subject: Test Siddhi-io-email-
@App:name("PublishEmailInTextFormat") @APP:description("Demonstrates how to use siddhi-io-email for publishing events to files.") define stream SweetProductionStream (name string, amount double); @sink(type='email', @map(type='text') , username ='<senders email user name>', address ='<senders email address>', password= '<senders email password>', subject='Test Siddhi-io-email-', to='<receivers email address>', port = '465', host = 'smtp.gmail.com', ssl.enable = 'true', auth = 'true') define stream LowProductionAlertStream(name string, hourlyTotal double, currentHour double); @sink(type='log') define stream EmailLogStream(name string, hourlyTotal double, currentHour double); from SweetProductionStream#window.time(1 min) select name, sum(amount) as hourlyTotal, convert(time:extract('HOUR', time:currentTimestamp(), 'yyyy-MM-dd hh:mm:ss'), 'double') as currentHour insert into LowProductionAlertStream; from LowProductionAlertStream insert into EmailLogStream;