ACTIVEMQ6-20 removing twitter integration https://issues.apache.org/jira/browse/ACTIVEMQ6-20
this has been identified as a dead feature. It was only useful for presentations... it had its time and we have better examples we can use... It's time for this feature to go! Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/a3afd625 Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/a3afd625 Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/a3afd625 Branch: refs/heads/master Commit: a3afd62575ba97b019a2c346a7b2cfb13974d33f Parents: cb7774c Author: Clebert Suconic <[email protected]> Authored: Tue Dec 2 12:15:25 2014 -0500 Committer: Clebert Suconic <[email protected]> Committed: Tue Dec 2 12:33:16 2014 -0500 ---------------------------------------------------------------------- .../activemq/rest/ActiveMQRestLogger.java | 3 - examples/core/twitter-connector/pom.xml | 184 ------ examples/core/twitter-connector/readme.html | 96 --- .../core/example/TwitterConnectorExample.java | 121 ---- .../server0/activemq-configuration.xml | 71 --- .../src/main/resources/server0/activemq-jms.xml | 19 - .../main/resources/server0/activemq-users.xml | 7 - .../activemq-twitter-integration/pom.xml | 44 -- .../integration/twitter/TwitterConstants.java | 99 --- .../TwitterIncomingConnectorServiceFactory.java | 52 -- .../TwitterOutgoingConnectorServiceFactory.java | 49 -- .../twitter/impl/IncomingTweetsHandler.java | 234 ------- .../twitter/impl/OutgoingTweetsHandler.java | 266 -------- .../activemq/twitter/ActiveMQTwitterBundle.java | 35 - .../activemq/twitter/ActiveMQTwitterLogger.java | 58 -- pom.xml | 14 - tests/integration-tests/pom.xml | 9 - .../tests/integration/twitter/TwitterTest.java | 637 ------------------- 18 files changed, 1998 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java ---------------------------------------------------------------------- diff --git a/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java b/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java index bd7bb5c..e14b681 100644 --- a/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java +++ b/activemq-rest/src/main/java/org/apache/activemq/rest/ActiveMQRestLogger.java @@ -45,9 +45,6 @@ import org.jboss.logging.annotations.MessageLogger; @MessageLogger(projectCode = "AMQ") public interface ActiveMQRestLogger extends BasicLogger { - /** - * The twitter logger. - */ ActiveMQRestLogger LOGGER = Logger.getMessageLogger(ActiveMQRestLogger.class, ActiveMQRestLogger.class.getPackage().getName()); @LogMessage(level = Logger.Level.INFO) http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/examples/core/twitter-connector/pom.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/pom.xml b/examples/core/twitter-connector/pom.xml deleted file mode 100644 index 8299070..0000000 --- a/examples/core/twitter-connector/pom.xml +++ /dev/null @@ -1,184 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>core-examples</artifactId> - <version>6.0.0-SNAPSHOT</version> - </parent> - - <artifactId>activemq-twitter-example</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ6 Twitter Example</name> - - <properties> - <TWITTER_CONSUMER_KEY>consumerKey</TWITTER_CONSUMER_KEY> - <TWITTER_CONSUMER_SECRET>consumerSecret</TWITTER_CONSUMER_SECRET> - <TWITTER_ACCESS_TOKEN>twitterAccess</TWITTER_ACCESS_TOKEN> - <TWITTER_ACCESS_TOKEN_SECRET>twitterToken</TWITTER_ACCESS_TOKEN_SECRET> - </properties> - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-core-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-commons</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - <version>${netty.version}</version> - </dependency> - <dependency> - <groupId>org.jboss.javaee</groupId> - <artifactId>jboss-jms-api</artifactId> - <version>1.1.0.GA</version> - </dependency> - <dependency> - <groupId>org.jboss.naming</groupId> - <artifactId>jnp-client</artifactId> - <version>5.0.5.Final</version> - </dependency> - <dependency> - <groupId>org.jboss.spec.javax.jms</groupId> - <artifactId>jboss-jms-api_2.0_spec</artifactId> - </dependency> - </dependencies> - - <profiles> - <profile> - <id>default</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-maven-plugin</artifactId> - <executions> - <execution> - <id>start</id> - <goals> - <goal>start</goal> - </goals> - <configuration> - <waitOnStart>true</waitOnStart> - <hornetqConfigurationDir>${basedir}/target/classes/server0</hornetqConfigurationDir> - <systemProperties> - <property> - <name>build.directory</name> - <value>${basedir}/target/</value> - </property> - <property> - <name>TWITTER_CONSUMER_KEY</name> - <value>${TWITTER_CONSUMER_KEY}</value> - </property> - <property> - <name>TWITTER_CONSUMER_SECRET</name> - <value>${TWITTER_CONSUMER_SECRET}</value> - </property> - <property> - <name>TWITTER_ACCESS_TOKEN</name> - <value>${TWITTER_ACCESS_TOKEN}</value> - </property> - <property> - <name>TWITTER_ACCESS_TOKEN_SECRET</name> - <value>${TWITTER_ACCESS_TOKEN_SECRET}</value> - </property> - </systemProperties> - </configuration> - </execution> - </executions> - <configuration> - <waitOnStart>false</waitOnStart> - <hornetqConfigurationDir>${basedir}/target/classes/server0</hornetqConfigurationDir> - </configuration> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.core</groupId> - <artifactId>activemq-twitter-example</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-twitter-integration</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-core-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-jms-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - <version>${netty.version}</version> - </dependency> - <dependency> - <groupId>org.jboss.javaee</groupId> - <artifactId>jboss-jms-api</artifactId> - <version>1.1.0.GA</version> - </dependency> - <dependency> - <groupId>org.jboss.naming</groupId> - <artifactId>jnpserver</artifactId> - <version>5.0.3.GA</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>example</id> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.1</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>java</goal> - </goals> - </execution> - </executions> - <configuration> - <mainClass>org.apache.activemq.core.example.TwitterConnectorExample</mainClass> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> - - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/examples/core/twitter-connector/readme.html ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/readme.html b/examples/core/twitter-connector/readme.html deleted file mode 100644 index bfd8c3f..0000000 --- a/examples/core/twitter-connector/readme.html +++ /dev/null @@ -1,96 +0,0 @@ -<html> - <head> - <title>ActiveMQ Twitter Connector Service Example</title> - <link rel="stylesheet" type="text/css" href="../../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../../common/prettify.css" /> - <script type="text/javascript" src="../../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>Twitter Connector Service Example</h1> - - <p>This example shows you how to configure ActiveMQ to use the Twitter Connector Service.</p> - - <p>ActiveMQ supports 2 types of Twitter connector, incoming and outgoing. - Incoming connector consumes from twitter and forwards to a configurable address. - Outgoing connector consumes from a configurable address and forwards to twitter. - </p> - - <p>In this example, incoming connector and outgoing connector is related to same twitter account. - So if you send a message to an outgoing address, outgoing connector forwards it to twitter, - and then incoming connector consumes it and forwards to incoming address.</p> - - <h2>Example step-by-step</h2> - <p><i>To run the server, simply type <code>mvn-Dtwitter.consumerKey=consumer -Dtwitter.consumerSecret=secret -Dtwitter.accessToken=token -Dtwitter.accessTokenSecret=secret verify</code> - from this directory but replacing the system properties with those of the twitter account you want to use. Then run the example - by using the command <code>mvn -Pexample package</code></p> - - - <ol> - <li>First we need to create a ClientSessionFactory with Netty transport configuration</li> - <pre class="prettyprint"> - <code>csf = ActiveMQClient.createClientSessionFactory(new TransportConfiguration(NettyConnectorFactory.class.getName()));</code> - </pre> - - <li>We create a core session with auto-commit mode</li> - <pre class="prettyprint"> - <code>session = csf.createSession(true,true);</code> - </pre> - - <li>We Create a core producer for queue.outgoingQueue</li> - <pre class="prettyprint"> - <code>ClientProducer cp = session.createProducer(OUTGOING_QUEUE);</code> - </pre> - - <li>We create a core consumer for queue.incomingQueue</li> - <pre class="prettyprint"> - <code>ClientConsumer cc = session.createConsumer(INCOMING_QUEUE);</code> - </pre> - - <li>We create a core message that we are going to send</li> - <pre class="prettyprint"> - <code>ClientMessage cm = session.createMessage(org.apache.activemq.api.core.Message.TEXT_TYPE,true); -String testMessage = System.currentTimeMillis() + ": twitter connector test example"; -cm.getBodyBuffer().writeString(testMessage);</code> - </pre> - - <li>We send the message to queue.outgoingQueue</li> - <pre class="prettyprint"> - <code>cp.send(cm);</code> - </pre> - - <li>We start the session</li> - <pre class="prettyprint"> - <code>session.start();</code> - </pre> - - <li>We will receive a message from queue.incomingQueue. - Outgoing connector forwards a message(we sent before) to twitter immediately. - Since incoming connector consumes from twitter and forwards to queue.incomingQueue - every 60 seconds, It will be received in 60+x seconds.</li> - <pre class="prettyprint"> - <code>ClientMessage received = cc.receive(70 * 1000); -received.acknowledge(); -String receivedText = received.getBodyBuffer().readString();</code> - </pre> - - <li>And finally, remember to close core session and ClientSessionFactory in a <code>finally</code> block.</li> - - <pre class="prettyprint"> - <code>finally -{ - if(session != null) - { - session.close(); - } - if(csf != null) - { - csf.close(); - } -}</code> - </pre> - - - - </ol> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/examples/core/twitter-connector/src/main/java/org/apache/activemq/core/example/TwitterConnectorExample.java ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/java/org/apache/activemq/core/example/TwitterConnectorExample.java b/examples/core/twitter-connector/src/main/java/org/apache/activemq/core/example/TwitterConnectorExample.java deleted file mode 100644 index cede6a0..0000000 --- a/examples/core/twitter-connector/src/main/java/org/apache/activemq/core/example/TwitterConnectorExample.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.core.example; - -import org.apache.activemq.api.core.TransportConfiguration; -import org.apache.activemq.api.core.client.ClientConsumer; -import org.apache.activemq.api.core.client.ClientMessage; -import org.apache.activemq.api.core.client.ClientProducer; -import org.apache.activemq.api.core.client.ClientSession; -import org.apache.activemq.api.core.client.ClientSessionFactory; -import org.apache.activemq.api.core.client.ActiveMQClient; -import org.apache.activemq.api.core.client.ServerLocator; -import org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory; - -/** - * A simple example of using twitter connector service. - * - * @author <a href="[email protected]">Tomohisa Igarashi</a> - */ -public class TwitterConnectorExample -{ - private static final String INCOMING_QUEUE = "queue.incomingQueue"; - private static final String OUTGOING_QUEUE = "queue.outgoingQueue"; - - public static void main(final String[] args) throws Exception - { - ServerLocator locator = null; - ClientSessionFactory csf = null; - ClientSession session = null; - try - { - String testMessage = System.currentTimeMillis() + ": " + System.getProperty("twitter.example.alternativeMessage"); - if(testMessage == null || testMessage.trim().equals("")) { - testMessage = System.currentTimeMillis() + ": ### Hello, ActiveMQ fans!! We are now experiencing so fast, so reliable and so exciting messaging never seen before ;-) ###"; - } - - // Step 1. Create a ClientSessionFactory - - - locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName())); - - csf = locator.createSessionFactory(); - - // Step 2. Create a core session. - session = csf.createSession(true,true); - - // Step 3. Create a core producer for queue.outgoingQueue. - ClientProducer cp = session.createProducer(OUTGOING_QUEUE); - - // Step 4. Create a core consumer for queue.incomingQueue. - ClientConsumer cc = session.createConsumer(INCOMING_QUEUE); - - // Step 5. Create a core message. - ClientMessage cm = session.createMessage(org.apache.activemq.api.core.Message.TEXT_TYPE,true); - cm.getBodyBuffer().writeString(testMessage); - - // Step 6. Send a message to queue.outgoingQueue. - cp.send(cm); - System.out.println("#### Sent a message to " + OUTGOING_QUEUE + ": " + testMessage); - - // Step 7. Start the session. - session.start(); - - // Step 8. Receive a message from queue.incomingQueue. - // Outgoing connector forwards a message(sent at Step 6.) to twitter immediately. - // Since incoming connector consumes from twitter and forwards to queue.incomingQueue - // every 60 seconds, It will be received in 60+x seconds. - System.out.println("#### A message will be received in 60 seconds. Please wait..."); - ClientMessage received = cc.receive(70 * 1000); - received.acknowledge(); - String receivedText = received.getBodyBuffer().readString(); - - while(!receivedText.equals(testMessage)) - { - // ignoring other tweets - received = cc.receiveImmediate(); - if(received == null) { - // no other tweets. test message has gone... - return; - } - - received.acknowledge(); - receivedText = received.getBodyBuffer().readString(); - } - - System.out.println("#### Received a message from " + INCOMING_QUEUE + ": " + receivedText); - } - finally - { - // Step 9. Be sure to close some resources. - if(session != null) - { - session.close(); - } - if(csf != null) - { - csf.close(); - } - - if (locator != null) - { - locator.close(); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/examples/core/twitter-connector/src/main/resources/server0/activemq-configuration.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/resources/server0/activemq-configuration.xml b/examples/core/twitter-connector/src/main/resources/server0/activemq-configuration.xml deleted file mode 100644 index 2db5f46..0000000 --- a/examples/core/twitter-connector/src/main/resources/server0/activemq-configuration.xml +++ /dev/null @@ -1,71 +0,0 @@ -<configuration xmlns="urn:activemq" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq /schema/activemq-configuration.xsd"> - - - <bindings-directory>target/server0/data/messaging/bindings</bindings-directory> - - <journal-directory>target/server0/data/messaging/journal</journal-directory> - - <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory> - - <paging-directory>target/server0/data/messaging/paging</paging-directory> - <!-- Connectors --> - - <connectors> - <connector name="netty-connector"> - <factory-class>org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory</factory-class> - </connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor"> - <factory-class>org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class> - </acceptor> - </acceptors> - - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="queue.incomingQueue"> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - <security-setting match="queue.outgoingQueue"> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - <queues> - <queue name="queue.incomingQueue"> - <address>queue.incomingQueue</address> - </queue> - <queue name="queue.outgoingQueue"> - <address>queue.outgoingQueue</address> - </queue> - </queues> - - <connector-services> - <connector-service name="my-incoming-tweets"> - <factory-class>org.apache.activemq.integration.twitter.TwitterIncomingConnectorServiceFactory</factory-class> - <param key="queue" value="queue.incomingQueue"/> - <param key="consumerKey" value="${twitter.consumerKey}"/> - <param key="consumerSecret" value="${twitter.consumerSecret}"/> - <param key="accessToken" value="${twitter.accessToken}"/> - <param key="accessTokenSecret" value="${twitter.accessTokenSecret}"/> - <param key="interval" value="60"/> - </connector-service> - <connector-service name="my-outgoing-tweets"> - <factory-class>org.apache.activemq.integration.twitter.TwitterOutgoingConnectorServiceFactory</factory-class> - <param key="queue" value="queue.outgoingQueue"/> - <param key="consumerKey" value="${twitter.consumerKey}"/> - <param key="consumerSecret" value="${twitter.consumerSecret}"/> - <param key="accessToken" value="${twitter.accessToken}"/> - <param key="accessTokenSecret" value="${twitter.accessTokenSecret}"/> - </connector-service> - </connector-services> - -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/examples/core/twitter-connector/src/main/resources/server0/activemq-jms.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/resources/server0/activemq-jms.xml b/examples/core/twitter-connector/src/main/resources/server0/activemq-jms.xml deleted file mode 100644 index 452b958..0000000 --- a/examples/core/twitter-connector/src/main/resources/server0/activemq-jms.xml +++ /dev/null @@ -1,19 +0,0 @@ -<configuration xmlns="urn:activemq" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq /schema/activemq-jms.xsd"> - <!--the connection factory used by the example--> - <connection-factory name="ConnectionFactory"> - <connectors> - <connector-ref connector-name="netty-connector"/> - </connectors> - <entries> - <entry name="ConnectionFactory"/> - </entries> - </connection-factory> - - <!--the queue used by the example--> - <queue name="exampleQueue"> - <entry name="/queue/exampleQueue"/> - </queue> - -</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/examples/core/twitter-connector/src/main/resources/server0/activemq-users.xml ---------------------------------------------------------------------- diff --git a/examples/core/twitter-connector/src/main/resources/server0/activemq-users.xml b/examples/core/twitter-connector/src/main/resources/server0/activemq-users.xml deleted file mode 100644 index ae30546..0000000 --- a/examples/core/twitter-connector/src/main/resources/server0/activemq-users.xml +++ /dev/null @@ -1,7 +0,0 @@ -<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="urn:activemq /schema/activemq-users.xsd"> - <!-- the default user. this is used where username is null--> - <defaultuser name="guest" password="guest"> - <role name="guest"/> - </defaultuser> -</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/integration/activemq-twitter-integration/pom.xml ---------------------------------------------------------------------- diff --git a/integration/activemq-twitter-integration/pom.xml b/integration/activemq-twitter-integration/pom.xml deleted file mode 100644 index 8248b0c..0000000 --- a/integration/activemq-twitter-integration/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-pom</artifactId> - <version>6.0.0-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - - <artifactId>activemq-twitter-integration</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ6 Twitter Integration</name> - - <properties> - <activemq.basedir>${project.basedir}/../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.jboss.logging</groupId> - <artifactId>jboss-logging-processor</artifactId> - </dependency> - - <!-- - JBoss Logging - --> - <dependency> - <groupId>org.jboss.logging</groupId> - <artifactId>jboss-logging</artifactId> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.twitter4j</groupId> - <artifactId>twitter4j-core</artifactId> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterConstants.java ---------------------------------------------------------------------- diff --git a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterConstants.java b/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterConstants.java deleted file mode 100644 index e171329..0000000 --- a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterConstants.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.integration.twitter; - -import java.util.HashSet; -import java.util.Set; - -/** - * A TwitterConstants - * - * @author <a href="[email protected]">Tomohisa Igarashi</a> - */ -public final class TwitterConstants -{ - public static final String KEY_ID = "id"; - public static final String KEY_SOURCE = "source"; - public static final String KEY_CREATED_AT = "createdAt"; - public static final String KEY_IS_TRUNCATED = "isTruncated"; - public static final String KEY_IN_REPLY_TO_STATUS_ID = "inReplyToStatusId"; - public static final String KEY_IN_REPLY_TO_USER_ID = "inReplyToUserId"; - public static final String KEY_IN_REPLY_TO_SCREEN_NAME = "inReplyToScreenName"; - public static final String KEY_IS_FAVORITED = "isFavorited"; - public static final String KEY_IS_RETWEET = "isRetweet"; - public static final String KEY_CONTRIBUTORS = "contributors"; - public static final String KEY_GEO_LOCATION_LATITUDE = "geoLocation.latitude"; - public static final String KEY_GEO_LOCATION_LONGITUDE = "geoLocation.longitude"; - public static final String KEY_PLACE_ID = "place.id"; - public static final String KEY_DISPLAY_COODINATES = "displayCoodinates"; - - public static final int DEFAULT_POLLING_INTERVAL_SECS = 10; - public static final int DEFAULT_PAGE_SIZE = 100; - public static final int FIRST_ATTEMPT_PAGE_SIZE = 1; - public static final int START_SINCE_ID = 1; - public static final int INITIAL_MESSAGE_BUFFER_SIZE = 50; - - public static final Set<String> ALLOWABLE_INCOMING_CONNECTOR_KEYS; - public static final Set<String> REQUIRED_INCOMING_CONNECTOR_KEYS; - - public static final Set<String> ALLOWABLE_OUTGOING_CONNECTOR_KEYS; - public static final Set<String> REQUIRED_OUTGOING_CONNECTOR_KEYS; - - public static final String CONSUMER_KEY = "consumerKey"; - public static final String CONSUMER_SECRET = "consumerSecret"; - public static final String ACCESS_TOKEN = "accessToken"; - public static final String ACCESS_TOKEN_SECRET = "accessTokenSecret"; - public static final String QUEUE_NAME = "queue"; - public static final String INCOMING_INTERVAL = "interval"; - - static - { - ALLOWABLE_INCOMING_CONNECTOR_KEYS = new HashSet<String>(); - ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(CONSUMER_KEY); - ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(CONSUMER_SECRET); - ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(ACCESS_TOKEN); - ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(ACCESS_TOKEN_SECRET); - ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(QUEUE_NAME); - ALLOWABLE_INCOMING_CONNECTOR_KEYS.add(INCOMING_INTERVAL); - - REQUIRED_INCOMING_CONNECTOR_KEYS = new HashSet<String>(); - REQUIRED_INCOMING_CONNECTOR_KEYS.add(CONSUMER_KEY); - REQUIRED_INCOMING_CONNECTOR_KEYS.add(CONSUMER_SECRET); - REQUIRED_INCOMING_CONNECTOR_KEYS.add(ACCESS_TOKEN); - REQUIRED_INCOMING_CONNECTOR_KEYS.add(ACCESS_TOKEN_SECRET); - REQUIRED_INCOMING_CONNECTOR_KEYS.add(QUEUE_NAME); - - ALLOWABLE_OUTGOING_CONNECTOR_KEYS = new HashSet<String>(); - ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(CONSUMER_KEY); - ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(CONSUMER_SECRET); - ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(ACCESS_TOKEN); - ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(ACCESS_TOKEN_SECRET); - ALLOWABLE_OUTGOING_CONNECTOR_KEYS.add(QUEUE_NAME); - - REQUIRED_OUTGOING_CONNECTOR_KEYS = new HashSet<String>(); - REQUIRED_OUTGOING_CONNECTOR_KEYS.add(CONSUMER_KEY); - REQUIRED_OUTGOING_CONNECTOR_KEYS.add(CONSUMER_SECRET); - REQUIRED_OUTGOING_CONNECTOR_KEYS.add(ACCESS_TOKEN); - REQUIRED_OUTGOING_CONNECTOR_KEYS.add(ACCESS_TOKEN_SECRET); - REQUIRED_OUTGOING_CONNECTOR_KEYS.add(QUEUE_NAME); - } - - private TwitterConstants() - { - // utility class - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterIncomingConnectorServiceFactory.java ---------------------------------------------------------------------- diff --git a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterIncomingConnectorServiceFactory.java b/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterIncomingConnectorServiceFactory.java deleted file mode 100644 index 0934dad..0000000 --- a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterIncomingConnectorServiceFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.integration.twitter; - -import org.apache.activemq.core.persistence.StorageManager; -import org.apache.activemq.core.postoffice.PostOffice; -import org.apache.activemq.core.server.ConnectorService; -import org.apache.activemq.core.server.ConnectorServiceFactory; -import org.apache.activemq.integration.twitter.impl.IncomingTweetsHandler; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; - -/** - * @author <a href="mailto:[email protected]">Andy Taylor</a> - * Created Jun 29, 2010 - */ -public class TwitterIncomingConnectorServiceFactory implements ConnectorServiceFactory -{ - public ConnectorService createConnectorService(String connectorName, final Map<String, Object> configuration, - final StorageManager storageManager, - final PostOffice postOffice, - final ScheduledExecutorService scheduledThreadPool) - { - return new IncomingTweetsHandler(connectorName, configuration, storageManager, postOffice, scheduledThreadPool); - } - - public Set<String> getAllowableProperties() - { - return TwitterConstants.ALLOWABLE_INCOMING_CONNECTOR_KEYS; - } - - public Set<String> getRequiredProperties() - { - return TwitterConstants.REQUIRED_INCOMING_CONNECTOR_KEYS; - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterOutgoingConnectorServiceFactory.java ---------------------------------------------------------------------- diff --git a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterOutgoingConnectorServiceFactory.java b/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterOutgoingConnectorServiceFactory.java deleted file mode 100644 index 1ceb3c9..0000000 --- a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/TwitterOutgoingConnectorServiceFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.integration.twitter; - -import org.apache.activemq.core.persistence.StorageManager; -import org.apache.activemq.core.postoffice.PostOffice; -import org.apache.activemq.core.server.ConnectorService; -import org.apache.activemq.core.server.ConnectorServiceFactory; -import org.apache.activemq.integration.twitter.impl.OutgoingTweetsHandler; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; - -/** - * @author <a href="mailto:[email protected]">Andy Taylor</a> - * Created Jun 29, 2010 - */ -public class TwitterOutgoingConnectorServiceFactory implements ConnectorServiceFactory -{ - public ConnectorService createConnectorService(String connectorName, Map<String, Object> configuration, StorageManager storageManager, PostOffice postOffice, ScheduledExecutorService scheduledThreadPool) - { - return new OutgoingTweetsHandler(connectorName, configuration, postOffice); - } - - public Set<String> getAllowableProperties() - { - return TwitterConstants.ALLOWABLE_OUTGOING_CONNECTOR_KEYS; - } - - public Set<String> getRequiredProperties() - { - return TwitterConstants.REQUIRED_OUTGOING_CONNECTOR_KEYS; - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/impl/IncomingTweetsHandler.java ---------------------------------------------------------------------- diff --git a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/impl/IncomingTweetsHandler.java b/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/impl/IncomingTweetsHandler.java deleted file mode 100644 index 15279a5..0000000 --- a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/impl/IncomingTweetsHandler.java +++ /dev/null @@ -1,234 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.integration.twitter.impl; - -import java.util.Map; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -import org.apache.activemq.api.core.SimpleString; -import org.apache.activemq.core.persistence.StorageManager; -import org.apache.activemq.core.postoffice.Binding; -import org.apache.activemq.core.postoffice.PostOffice; -import org.apache.activemq.core.server.ConnectorService; -import org.apache.activemq.core.server.ServerMessage; -import org.apache.activemq.core.server.impl.ServerMessageImpl; -import org.apache.activemq.integration.twitter.TwitterConstants; -import org.apache.activemq.twitter.ActiveMQTwitterLogger; -import org.apache.activemq.utils.ConfigurationHelper; -import twitter4j.GeoLocation; -import twitter4j.Paging; -import twitter4j.Place; -import twitter4j.ResponseList; -import twitter4j.Status; -import twitter4j.Twitter; -import twitter4j.TwitterFactory; -import twitter4j.http.AccessToken; - -/** - * IncomingTweetsHandler consumes from twitter and forwards to the - * configured ActiveMQ address. - */ -public class IncomingTweetsHandler implements ConnectorService -{ - private final String connectorName; - - private final String consumerKey; - - private final String consumerSecret; - - private final String accessToken; - - private final String accessTokenSecret; - - private final String queueName; - - private final int intervalSeconds; - - private final StorageManager storageManager; - - private final PostOffice postOffice; - - private Paging paging; - - private Twitter twitter; - - private boolean isStarted = false; - - private final ScheduledExecutorService scheduledPool; - - private ScheduledFuture<?> scheduledFuture; - - public IncomingTweetsHandler(final String connectorName, - final Map<String, Object> configuration, - final StorageManager storageManager, - final PostOffice postOffice, - final ScheduledExecutorService scheduledThreadPool) - { - this.connectorName = connectorName; - this.consumerKey = ConfigurationHelper.getStringProperty(TwitterConstants.CONSUMER_KEY, null, configuration); - this.consumerSecret = ConfigurationHelper.getStringProperty(TwitterConstants.CONSUMER_SECRET, null, configuration); - this.accessToken = ConfigurationHelper.getStringProperty(TwitterConstants.ACCESS_TOKEN, null, configuration); - this.accessTokenSecret = ConfigurationHelper.getStringProperty(TwitterConstants.ACCESS_TOKEN_SECRET, null, configuration); - this.queueName = ConfigurationHelper.getStringProperty(TwitterConstants.QUEUE_NAME, null, configuration); - Integer intervalSeconds = ConfigurationHelper.getIntProperty(TwitterConstants.INCOMING_INTERVAL, 0, configuration); - if (intervalSeconds > 0) - { - this.intervalSeconds = intervalSeconds; - } - else - { - this.intervalSeconds = TwitterConstants.DEFAULT_POLLING_INTERVAL_SECS; - } - this.storageManager = storageManager; - this.postOffice = postOffice; - this.scheduledPool = scheduledThreadPool; - } - - public void start() throws Exception - { - Binding b = postOffice.getBinding(new SimpleString(queueName)); - if (b == null) - { - throw new Exception(connectorName + ": queue " + queueName + " not found"); - } - - paging = new Paging(); - TwitterFactory tf = new TwitterFactory(); - this.twitter = tf.getOAuthAuthorizedInstance(this.consumerKey, - this.consumerSecret, - new AccessToken(this.accessToken, - this.accessTokenSecret)); - this.twitter.verifyCredentials(); - - // getting latest ID - this.paging.setCount(TwitterConstants.FIRST_ATTEMPT_PAGE_SIZE); - - // If I used annotations here, it won't compile under JDK 1.7 - ResponseList res = this.twitter.getHomeTimeline(paging); - this.paging.setSinceId(((Status) res.get(0)).getId()); - ActiveMQTwitterLogger.LOGGER.debug(connectorName + " initialise(): got latest ID: " + this.paging.getSinceId()); - - // TODO make page size configurable - this.paging.setCount(TwitterConstants.DEFAULT_PAGE_SIZE); - - scheduledFuture = this.scheduledPool.scheduleWithFixedDelay(new TweetsRunnable(), - intervalSeconds, - intervalSeconds, - TimeUnit.SECONDS); - isStarted = true; - } - - public void stop() throws Exception - { - if (!isStarted) - { - return; - } - scheduledFuture.cancel(true); - paging = null; - isStarted = false; - } - - public boolean isStarted() - { - return isStarted; - } - - private void poll() throws Exception - { - // get new tweets - // If I used annotations here, it won't compile under JDK 1.7 - ResponseList res = this.twitter.getHomeTimeline(paging); - - if (res == null || res.size() == 0) - { - return; - } - - for (int i = res.size() - 1; i >= 0; i--) - { - Status status = (Status) res.get(i); - - ServerMessage msg = new ServerMessageImpl(this.storageManager.generateID(), - TwitterConstants.INITIAL_MESSAGE_BUFFER_SIZE); - msg.setAddress(new SimpleString(this.queueName)); - msg.setDurable(true); - msg.encodeMessageIDToBuffer(); - - putTweetIntoMessage(status, msg); - - this.postOffice.route(msg, false); - ActiveMQTwitterLogger.LOGGER.debug(connectorName + ": routed: " + status.toString()); - } - - this.paging.setSinceId(((Status) res.get(0)).getId()); - ActiveMQTwitterLogger.LOGGER.debug(connectorName + ": update latest ID: " + this.paging.getSinceId()); - } - - private void putTweetIntoMessage(final Status status, final ServerMessage msg) - { - msg.getBodyBuffer().writeString(status.getText()); - msg.putLongProperty(TwitterConstants.KEY_ID, status.getId()); - msg.putStringProperty(TwitterConstants.KEY_SOURCE, status.getSource()); - - msg.putLongProperty(TwitterConstants.KEY_CREATED_AT, status.getCreatedAt().getTime()); - msg.putBooleanProperty(TwitterConstants.KEY_IS_TRUNCATED, status.isTruncated()); - msg.putLongProperty(TwitterConstants.KEY_IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId()); - msg.putIntProperty(TwitterConstants.KEY_IN_REPLY_TO_USER_ID, status.getInReplyToUserId()); - msg.putBooleanProperty(TwitterConstants.KEY_IS_FAVORITED, status.isFavorited()); - msg.putBooleanProperty(TwitterConstants.KEY_IS_RETWEET, status.isRetweet()); - msg.putObjectProperty(TwitterConstants.KEY_CONTRIBUTORS, status.getContributors()); - GeoLocation gl; - if ((gl = status.getGeoLocation()) != null) - { - msg.putDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LATITUDE, gl.getLatitude()); - msg.putDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LONGITUDE, gl.getLongitude()); - } - Place place; - if ((place = status.getPlace()) != null) - { - msg.putStringProperty(TwitterConstants.KEY_PLACE_ID, place.getId()); - } - } - - public String getName() - { - return connectorName; - } - - private final class TweetsRunnable implements Runnable - { - /** - * TODO streaming API support - * TODO rate limit support - */ - public void run() - { - // Avoid canceling the task with RuntimeException - try - { - poll(); - } - catch (Throwable t) - { - ActiveMQTwitterLogger.LOGGER.errorPollingTwitter(t); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/impl/OutgoingTweetsHandler.java ---------------------------------------------------------------------- diff --git a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/impl/OutgoingTweetsHandler.java b/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/impl/OutgoingTweetsHandler.java deleted file mode 100644 index 10213a7..0000000 --- a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/integration/twitter/impl/OutgoingTweetsHandler.java +++ /dev/null @@ -1,266 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.integration.twitter.impl; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.apache.activemq.api.core.SimpleString; -import org.apache.activemq.core.filter.Filter; -import org.apache.activemq.core.postoffice.Binding; -import org.apache.activemq.core.postoffice.PostOffice; -import org.apache.activemq.core.server.ConnectorService; -import org.apache.activemq.core.server.Consumer; -import org.apache.activemq.core.server.HandleStatus; -import org.apache.activemq.core.server.ActiveMQServerLogger; -import org.apache.activemq.core.server.MessageReference; -import org.apache.activemq.core.server.Queue; -import org.apache.activemq.core.server.ServerMessage; -import org.apache.activemq.integration.twitter.TwitterConstants; -import org.apache.activemq.twitter.ActiveMQTwitterLogger; -import org.apache.activemq.utils.ConfigurationHelper; -import twitter4j.GeoLocation; -import twitter4j.StatusUpdate; -import twitter4j.Twitter; -import twitter4j.TwitterException; -import twitter4j.TwitterFactory; -import twitter4j.http.AccessToken; - -/** - * OutgoingTweetsHandler consumes from configured ActiveMQ address - * and forwards to the twitter. - */ -public class OutgoingTweetsHandler implements Consumer, ConnectorService -{ - private final String connectorName; - - private final String consumerKey; - - private final String consumerSecret; - - private final String accessToken; - - private final String accessTokenSecret; - - private final String queueName; - - private final PostOffice postOffice; - - private Twitter twitter = null; - - private Queue queue = null; - - private Filter filter = null; - - private boolean isStarted = false; - - - public String debug() - { - return toString(); - } - - public OutgoingTweetsHandler(final String connectorName, - final Map<String, Object> configuration, - final PostOffice postOffice) - { - this.connectorName = connectorName; - this.consumerKey = ConfigurationHelper.getStringProperty(TwitterConstants.CONSUMER_KEY, null, configuration); - this.consumerSecret = ConfigurationHelper.getStringProperty(TwitterConstants.CONSUMER_SECRET, null, configuration); - this.accessToken = ConfigurationHelper.getStringProperty(TwitterConstants.ACCESS_TOKEN, null, configuration); - this.accessTokenSecret = ConfigurationHelper.getStringProperty(TwitterConstants.ACCESS_TOKEN_SECRET, null, configuration); - this.queueName = ConfigurationHelper.getStringProperty(TwitterConstants.QUEUE_NAME, null, configuration); - this.postOffice = postOffice; - } - - /** - * TODO streaming API support - * TODO rate limit support - */ - public synchronized void start() throws Exception - { - if (this.isStarted) - { - return; - } - - if (this.connectorName == null || this.connectorName.trim().equals("")) - { - throw new Exception("invalid connector name: " + this.connectorName); - } - - if (this.queueName == null || this.queueName.trim().equals("")) - { - throw new Exception("invalid queue name: " + queueName); - } - - SimpleString name = new SimpleString(this.queueName); - Binding b = this.postOffice.getBinding(name); - if (b == null) - { - throw new Exception(connectorName + ": queue " + queueName + " not found"); - } - this.queue = (Queue) b.getBindable(); - - TwitterFactory tf = new TwitterFactory(); - this.twitter = tf.getOAuthAuthorizedInstance(this.consumerKey, - this.consumerSecret, - new AccessToken(this.accessToken, - this.accessTokenSecret)); - this.twitter.verifyCredentials(); - - // TODO make filter-string configurable - // this.filter = FilterImpl.createFilter(filterString); - this.filter = null; - - this.queue.addConsumer(this); - - this.queue.deliverAsync(); - this.isStarted = true; - ActiveMQTwitterLogger.LOGGER.debug(connectorName + ": started"); - } - - public boolean isStarted() - { - return isStarted; //To change body of implemented methods use File | Settings | File Templates. - } - - public synchronized void stop() throws Exception - { - if (!this.isStarted) - { - return; - } - - ActiveMQTwitterLogger.LOGGER.debug(connectorName + ": receive shutdown request"); - - this.queue.removeConsumer(this); - - this.isStarted = false; - ActiveMQTwitterLogger.LOGGER.debug(connectorName + ": shutdown"); - } - - public String getName() - { - return connectorName; - } - - public Filter getFilter() - { - return filter; - } - - /* (non-Javadoc) - * @see org.apache.activemq.core.server.Consumer#getDeliveringMessages() - */ - @Override - public List<MessageReference> getDeliveringMessages() - { - return Collections.emptyList(); - } - - public HandleStatus handle(final MessageReference ref) throws Exception - { - if (filter != null && !filter.match(ref.getMessage())) - { - return HandleStatus.NO_MATCH; - } - - synchronized (this) - { - ref.handled(); - - ServerMessage message = ref.getMessage(); - - StatusUpdate status = new StatusUpdate(message.getBodyBuffer().readString()); - - // set optional property - - if (message.containsProperty(TwitterConstants.KEY_IN_REPLY_TO_STATUS_ID)) - { - status.setInReplyToStatusId(message.getLongProperty(TwitterConstants.KEY_IN_REPLY_TO_STATUS_ID)); - } - - if (message.containsProperty(TwitterConstants.KEY_GEO_LOCATION_LATITUDE)) - { - double geolat = message.getDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LATITUDE); - double geolong = message.getDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LONGITUDE); - status.setLocation(new GeoLocation(geolat, geolong)); - } - - if (message.containsProperty(TwitterConstants.KEY_PLACE_ID)) - { - status.setPlaceId(message.getStringProperty(TwitterConstants.KEY_PLACE_ID)); - } - - if (message.containsProperty(TwitterConstants.KEY_DISPLAY_COODINATES)) - { - status.setDisplayCoordinates(message.getBooleanProperty(TwitterConstants.KEY_DISPLAY_COODINATES)); - } - - // send to Twitter - try - { - this.twitter.updateStatus(status); - } - catch (TwitterException e) - { - if (e.getStatusCode() == 403) - { - // duplicated message - ActiveMQTwitterLogger.LOGGER.error403(connectorName); - queue.acknowledge(ref); - - return HandleStatus.HANDLED; - } - else - { - throw e; - } - } - - queue.acknowledge(ref); - ActiveMQTwitterLogger.LOGGER.debug(connectorName + ": forwarded to twitter: " + message.getMessageID()); - return HandleStatus.HANDLED; - } - } - - public void proceedDeliver(MessageReference ref) - { - // no op - } - - @Override - public String toManagementString() - { - return toString(); - } - - @Override - public void disconnect() - { - try - { - stop(); - } - catch (Exception e) - { - ActiveMQServerLogger.LOGGER.errorStoppingConnectorService(e, getName()); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/twitter/ActiveMQTwitterBundle.java ---------------------------------------------------------------------- diff --git a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/twitter/ActiveMQTwitterBundle.java b/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/twitter/ActiveMQTwitterBundle.java deleted file mode 100644 index d6a7718..0000000 --- a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/twitter/ActiveMQTwitterBundle.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.twitter; - - -import org.jboss.logging.annotations.MessageBundle; - -/** - * @author <a href="mailto:[email protected]">Andy Taylor</a> - * 3/12/12 - * - * Logger Code 18 - * - * each message id must be 6 digits long starting with 18, the 3rd digit should be 9 - * - * so 189000 to 189999 - */ -@MessageBundle(projectCode = "AMQ") -public class ActiveMQTwitterBundle -{ -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/twitter/ActiveMQTwitterLogger.java ---------------------------------------------------------------------- diff --git a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/twitter/ActiveMQTwitterLogger.java b/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/twitter/ActiveMQTwitterLogger.java deleted file mode 100644 index 9c66407..0000000 --- a/integration/activemq-twitter-integration/src/main/java/org/apache/activemq/twitter/ActiveMQTwitterLogger.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.twitter; - -import org.jboss.logging.BasicLogger; -import org.jboss.logging.Logger; -import org.jboss.logging.annotations.Cause; -import org.jboss.logging.annotations.LogMessage; -import org.jboss.logging.annotations.Message; -import org.jboss.logging.annotations.MessageLogger; - -/** - * @author <a href="mailto:[email protected]">Andy Taylor</a> - * 3/15/12 - * - * Logger Code 18 - * - * each message id must be 6 digits long starting with 18, the 3rd digit donates the level so - * - * INF0 1 - * WARN 2 - * DEBUG 3 - * ERROR 4 - * TRACE 5 - * FATAL 6 - * - * so an INFO message would be 181000 to 181999 - */ -@MessageLogger(projectCode = "AMQ") -public interface ActiveMQTwitterLogger extends BasicLogger -{ - /** - * The twitter logger. - */ - ActiveMQTwitterLogger LOGGER = Logger.getMessageLogger(ActiveMQTwitterLogger.class, ActiveMQTwitterLogger.class.getPackage().getName()); - - @LogMessage(level = Logger.Level.WARN) - @Message(id = 182001, value = "{0}: HTTP status code = 403: Ignore duplicated message", format = Message.Format.MESSAGE_FORMAT) - void error403(String connectorName); - - @LogMessage(level = Logger.Level.WARN) - @Message(id = 182002, value = "Error polling Twitter", format = Message.Format.MESSAGE_FORMAT) - void errorPollingTwitter(@Cause Throwable t); -} http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 580ce49..912fa6a 100644 --- a/pom.xml +++ b/pom.xml @@ -281,14 +281,6 @@ <artifactId>jboss-logging-spi</artifactId> <version>2.1.0.GA</version> </dependency> - <!--needed to compile twitter support--> - <dependency> - <groupId>org.twitter4j</groupId> - <artifactId>twitter4j-core</artifactId> - <!-- there is a new version of this JAR but it breaks our usage of it --> - <version>2.1.2</version> - </dependency> - <!----> <dependency> <groupId>org.apache.qpid</groupId> @@ -505,7 +497,6 @@ <module>activemq-service-extensions</module> <!-- <module>integration/activemq-jboss-as-integration</module> --> <module>integration/activemq-spring-integration</module> - <module>integration/activemq-twitter-integration</module> <module>integration/activemq-aerogear-integration</module> <module>integration/activemq-vertx-integration</module> <module>tests</module> @@ -532,7 +523,6 @@ <module>activemq-service-extensions</module> <module>integration/activemq-jboss-as-integration</module> <module>integration/activemq-spring-integration</module> - <module>integration/activemq-twitter-integration</module> <module>integration/activemq-aerogear-integration</module> <module>integration/activemq-vertx-integration</module> <module>examples</module> @@ -559,7 +549,6 @@ <module>activemq-service-extensions</module> <module>integration/activemq-jboss-as-integration</module> <module>integration/activemq-spring-integration</module> - <module>integration/activemq-twitter-integration</module> <module>integration/activemq-aerogear-integration</module> <module>integration/activemq-vertx-integration</module> <module>examples</module> @@ -588,7 +577,6 @@ <module>activemq-service-extensions</module> <module>integration/activemq-jboss-as-integration</module> <module>integration/activemq-spring-integration</module> - <module>integration/activemq-twitter-integration</module> <module>integration/activemq-aerogear-integration</module> <module>integration/activemq-vertx-integration</module> <module>tests</module> @@ -627,7 +615,6 @@ <module>activemq-service-extensions</module> <module>integration/activemq-jboss-as-integration</module> <module>integration/activemq-spring-integration</module> - <module>integration/activemq-twitter-integration</module> <module>integration/activemq-aerogear-integration</module> <module>integration/activemq-vertx-integration</module> <module>tests</module> @@ -662,7 +649,6 @@ <module>activemq-service-extensions</module> <module>integration/activemq-jboss-as-integration</module> <module>integration/activemq-spring-integration</module> - <module>integration/activemq-twitter-integration</module> <module>integration/activemq-aerogear-integration</module> <module>integration/activemq-vertx-integration</module> <module>tests</module> http://git-wip-us.apache.org/repos/asf/activemq-6/blob/a3afd625/tests/integration-tests/pom.xml ---------------------------------------------------------------------- diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml index 42a31ba..d09a575 100644 --- a/tests/integration-tests/pom.xml +++ b/tests/integration-tests/pom.xml @@ -71,11 +71,6 @@ </dependency> <dependency> <groupId>org.apache.activemq</groupId> - <artifactId>activemq-twitter-integration</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> <artifactId>activemq-spring-integration</artifactId> <version>${project.version}</version> </dependency> @@ -122,10 +117,6 @@ <artifactId>jbosssx</artifactId> </dependency> <dependency> - <groupId>org.twitter4j</groupId> - <artifactId>twitter4j-core</artifactId> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency>
