Created
November 23, 2012 15:53
-
-
Save colwilson/4136224 to your computer and use it in GitHub Desktop.
Simple Camel Configuration of a Twitter Endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A Camel Java DSL Router | |
*/ | |
public class MyRouteBuilder extends RouteBuilder { | |
private static final ResourceBundle SECRETS = ResourceBundle | |
.getBundle("myproject.secrets"); | |
/** | |
* Let's configure the Camel routing rules using Java code... | |
* | |
* @throws UnsupportedEncodingException | |
*/ | |
public void configure() throws UnsupportedEncodingException { | |
configureAccess(); | |
String twitter = "twitter://streaming/filter?type=event&keywords=" | |
+ URLEncoder.encode("london", "utf8"); | |
from(twitter).filter(body().isInstanceOf(Status.class)).addAllSortsOfStuffHere(). | |
} | |
private void configureAccess() { | |
// setup Twitter component | |
TwitterComponent tc = getContext().getComponent("twitter", | |
TwitterComponent.class); | |
tc.setAccessToken(SECRETS.getString("ACCESS_TOKEN")); | |
tc.setAccessTokenSecret(SECRETS.getString("ACCESS_TOKEN_SECRET")); | |
tc.setConsumerKey(SECRETS.getString("CONSUMER_KEY")); | |
tc.setConsumerSecret(SECRETS.getString("CONSUMER_SECRET")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment