Receiving Messages from a Google Pub/Sub Topic¶
Purpose:¶
This application demonstrates how to configure ESB Streaming Integrator Tooling using googlepubsub source in Siddhi to consume events. Events which are in TEXT format are consumed from 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 folder and provide the path for the credential.path.
- Save the sample.
- If there is no syntax error, the following message is shown on the console: * -Siddhi App ReceiveGooglePubSubMesssage successfully deployed.
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,
- ReceiveGooglePubSubMesssage.siddhi - Started Successfully!
Testing the Sample:¶
- Receive events through the following, You may listen to the events coming to a topic after the subscription is made.
Viewing the Results:¶
See the output on the terminal:
INFO {io.siddhi.core.stream.output.sink.LogSink} - ReceiveEvent : BarStream : Event{timestamp=1552548124599, data=[message:"Hello"], isExpired=false} (Encoded)
Notes:¶
Make sure the the credential file is correct and user have write access to make api calls.
Stop this Siddhi application
@App:name("ReceiveGooglePubSubMesssage")
@App:description('Consume messages from a googlepubsub Topic.')
@App:name("ReceiveEvent")
@App:description("Listen for messages received for a topic in Google Pub Sub Server.")
@source(type ='googlepubsub',
project.id = 'sp-path-1547649404768',
topic.id = 'topic75',
credential.path = '/../sp.json',
subscription.id = 'sub75',
@map(type = 'text'))
define stream FooStream (message string);
@sink(type='log')
define stream BarStream(message string);
@info(name='EventsPassthroughQuery')
from FooStream
select message
insert into BarStream;
Top