...
This example is located in the Camel distribution at examples/camel-example-twitter-websocket
.
Tip |
---|
There is a Twitter Websocket Blueprint Example for OSGi Blueprint users. |
The example is demonstrating how to poll a constant feed of twitter searches and publish results in real time using web socket to a web page.
As usual the code in Camel is very simple. All it takes is roughly
Code Block |
---|
from("twitter://search?...") .setHeader("websocket.sendToAll", "true") .to("websocket:camel-tweet?sendToAll=true") |
This example is already configured using a testing purpose twitter account named 'cameltweet'. And therefore the example is ready to run out of the box.
...
Info | ||
---|---|---|
| ||
To use twitter, you need a twitter account which have setup an application to be used. In your Twitter settings under the Apps menu, it will list your approved applications. For example I created an application named "Camel-Example" When you have created an application, you get a number of details back from twitter |
You will need to compile this example first:
Code Block |
---|
mvn compile
|
To run the example type
Code Block |
---|
mvn exec:java
|
Then open a browser to see live twitter updates in the webpage
Code Block |
---|
http://localhost:9090/index.html |
To stop the example hit ctrl + c
When the application runs, the webpage should automatic update with new tweets. A screenshot below illustrates what you would see: