Contents
In this sample, the TIBCO StreamBase® Twitter adapters .
This sample demonstrates listening to the current users twitter stream, other streams are available.
The sbd.sbconf file must be edited and four values need to be added for this sample to function
Please view the documentation on how to get OAuth credentials for twitter API described in TIBCO StreamBase® Twitter Input Adapter
-
consumerKey
-
consumerSecret
-
accessToken
-
accessTokenSecret
-
In the Package Explorer, double-click to open the
twitter.sbapp
. Make sure the application is the currently active tab in the EventFlow Editor. -
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
-
In the Manual Input view, switch the stream to
ControlInput
, enteruser
into theCommand
field and then click to send the control tuple. -
In the Application Output view, observe the
InputStatus
tuple which gives details about the connection to the User stream which this sample starts by default on application start up. -
In the Manual Input view, switch the stream to
ControlOutput
, entertweet
into theCommand
field and then a short status into theTweet\Status
field and then click to send the control tuple. -
In the Application Output view, observe tuples emitted on the
OutputStatus
andTweets
output streams. -
Select the tuple emitted from the
Tweets
stream, then use the triangles next to the data fields displayed to analyze and understand their structure. -
Experiment with other commands on the
ControlOutput
andControlInput
streams as shown by notes included in the sbapp. -
Press F9 or click the Stop Running Application button.
This section describes how to run this sample in UNIX terminal windows or Windows command prompt windows, follow the steps in this section.
On Windows, be sure to use the StreamBase Command Prompt from the Start menu as described in the Test/Debug Guide, not the default command prompt.
-
Open six terminal windows on UNIX, or three StreamBase Command Prompts on Windows. In each window, navigate to your workspace copy of the sample, as described above.
-
In window 1, type:
sbd twitter.sbapp
-
In window 2, type:
sbc dequeue Tweets
This window will display tuples dequeued from the adapter's tweets port.
-
In window 3, type:
sbc dequeue InputStatus
This window will display tuples dequeued from the adapter's primary output port.
-
In window 4, type:
sbc dequeue OutputStatus
This window will display tuples dequeued from the adapter's primary output port.
-
In window 5, type:
sbc enqueue ControlInput
-
In window 5, type:
user, null, null, null, null, null, null
and press Enter.
-
Observe in window 3 that a single tuple is emitted from the
InputStatus
stream. This tuple contains various fields that detail the status of the connection. -
In window 6, type:
sbc enqueue ControlOutput
-
In window 6, type:
tweet,"testing a tweet,null,null,null,null,null,null",null
and press Enter.
-
Observe in window 2 that a single tuple is emitted from the
Tweets
stream. This tuple contains various fields that detail the tweet received. -
In window 2, type Ctrl+C, then the following command to terminate the server and dequeuer:
sbadmin shutdown
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, select
→ . -
Select
Twitter adapter
from the StreamBase Standard Adapters category. -
Click OK.
StreamBase Studio creates a single project containing the sample files.
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 the permission problems that can occur when trying to work with the initially installed location of the sample. The default workspace location for this sample is:
studio-workspace
/sample_twitter
See Default Installation Directories for the location of studio-workspace
on your system.
In the default TIBCO StreamBase installation, this sample's files are initially installed in:
streambase-install-dir
/sample/adapter/embedded/twitter
See Default Installation Directories for the default location of studio-workspace
on your system.