Contents
This topic describes how to run the Spotfire Streaming Adapter for Apache Pulsar sample application, which illustrates how to use the adapter to access a Pulsar broker and exchange messages.
For more information on this operator, see Apache Pulsar Adapter.
This sample includes a pair of Pulsar operators, which by default connect to a Pulsar
broker named Test Broker
, and which is assumed to
already be running on localhost. Once connected, use the sample to publish and
receive Pulsar messages using the Producer and Consumer operators respectively.
In StreamBase Studio, import this sample with the following steps:
-
From the top-level menu, select
> . -
Enter
pulsar
to narrow the list of options. -
Select Apache Pulsar Adapter from the Messaging category.
-
Click
.
StreamBase Studio creates a single project for the Pulsar Adapter sample.
-
Ensure your Pulsar broker is already running on localhost:6650. If your broker is hosted elsewhere, edit the project's
src/main/configurations/Pulsar.conf
file'sbroker-uri
entry to match. -
In the Project Explorer view, open the sample you just loaded.
If you see red marks on a project folder, wait a moment for the project to load its features.
If the red marks do not resolve themselves after a minute, select the project, right-click, and select
> from the context menu. -
Open the
src/main/eventflow/
folder.packageName
-
Open the
pulsar.sbapp
file and click the Run button. This opens the SB Test/Debug perspective and starts the module. -
In the Manual Input view, select the
ConsumerIn
input stream. -
Enter the following values:
-
command
:subscribe
-
topic
:topic1
Click
(which causes the adapter to contact the broker and perform the requested subscription operation). -
-
The Output Streams view will report that the ConsumerStatus output port has received a status tuple indicating the success of the subscription operation.
-
Still in the Manual Input view, select the
ProducerIn
stream, enter the following values and click to publish a message:-
topic
:topic1
-
key
:key1
-
message.myInt
:42
-
message.myStr
:forty-two
-
-
The message will be published by the Producer to topic
topic1
and the Consumer operator will receive the message and emit it on its ConsumerResults stream, as evidenced in the Output Streams view. -
Unsubscribe your consumer from the topic by selecting the Manual Input view's ConsumerIn stream, entering the following values and clicking :
-
command
:unsubscribe
-
-
When done, press F9 or click the Terminate EventFlow Fragment button.
This sample contains the following files:
- pulsar.sbapp
-
Sample EventFlow application.
- Pulsar.conf
-
Used to configure the connection to the Pulsar broker.
When you load the sample into StreamBase® Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Important
Load this sample in StreamBase® Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:
studio-workspace
/sample/adapter/embedded/pulsar
See Default Installation
Directories for the default location of studio-workspace
on your system.