Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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?...")
    .to("websocket:camel-tweet?sendToAll=true")

...

Info
titleHow to use my own twitter account

To use twitter, you need a twitter account which have setup an application to be used.
For twitter users, you may be familiar that twitter requires you to grant applications access to your twitter account, such as twitter for iphone etc.
The same applies for this example. You can read details about how to setup a new twitter application at the Camel Twitter documentation.

In your Twitter settings under the Apps menu, it will list your approved applications. For example I created an application named "Camel-Example"
which is now listed as approved with read-only access.

When you have created an application, you get a number of details back from twitter
which you need to use the twitter component. Enter these details in the source code at:
src/main/java/org/apache/camel/example/websocket/CamelTwitterWebSocketMain.java

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

...