Publishing Events to a Google Pub/Sub Topic¶
Purpose:¶
This application demonstrates how to configure ESB Streaming Integrator Tooling using googlepubsub sink in Siddhi to publish events. Events which are in TEXT format are published to a googlepubsub topic.
Prerequisites:¶
- Create a Google Cloud Platform account.
- Sign in to Google Account and set up a GCP Console project and enable the API.
- Create a service account and download a private key as JSON.
- Place your JSON file in any system property.
- Save the sample.
- If there is no syntax error, the following message is shown on the console:
- Siddhi App SendGooglePubSubMessage successfully deployed.
Executing the Sample:¶
- Start the Siddhi application by clicking on 'Run'. If the Siddhi application starts successfully, the following messages are shown on the console:
- SendGooglePubSubMessage.siddhi - Started Successfully!
Testing the Sample:¶
- Send events through one or more of the following methods.
- You may send events to googlepubsub sink, via event simulator
- Open the event simulator by clicking on the second icon or pressing Ctrl+Shift+I.
- In the Single Simulation tab of the panel, specify the values as follows:
- Siddhi App Name : SendGooglePubSubMessage
- Stream Name : FooStream
- In the message field, enter the following and then click Send to send the event.
- message: Hello
- Send some more events.
- You may send events to googlepubsub sink, via event simulator
Viewing the Results:¶
- See the output on the terminal:
2019-03-14_12-50-21_966] INFO {io.siddhi.core.stream.output.sink.LogSink} - SendEvent : BarStream : Event{timestamp=1552548021825, data=[Hello], isExpired=false}
Notes:¶
Make sure the the credential file is correct and user have write access to make API calls.
Stop this Siddhi application.
@App:name("SendGooglePubSubMessage")
@App:description('Send events to a Google Pub/Sub Topic')
@sink(type='googlepubsub',
topic.id = 'topic75',
credential.path = '/../sp.json',
project.id = 'sp-path-1547649404768',
@map(type='text'))
define stream FooStream (message string);
@sink(type = 'log')
define stream BarStream(message string);
@info(name = 'query1')
from FooStream
select message
insert into BarStream;
Top