Permalink
Browse files

Use log4j for reporting errors

  • Loading branch information...
1 parent 11ef195 commit fffbe8ccd378a8e8fc8b1e0eaeaa0d328d39ed6a @samstokes samstokes committed Oct 1, 2011
Showing with 12 additions and 7 deletions.
  1. +5 −0 pom.xml
  2. +7 −7 src/main/java/com/rapportive/storm/spout/AMQPSpout.java
View
5 pom.xml
@@ -20,6 +20,11 @@
<artifactId>amqp-client</artifactId>
<version>2.6.1</version>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ </dependency>
</dependencies>
<build>
<plugins>
View
14 src/main/java/com/rapportive/storm/spout/AMQPSpout.java
@@ -3,6 +3,8 @@
import java.io.IOException;
import java.util.Map;
+import org.apache.log4j.Logger;
+
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
@@ -13,7 +15,6 @@
import backtype.storm.topology.IRichSpout;
import backtype.storm.topology.OutputFieldsDeclarer;
-
/**
* Spout to feed messages into Storm from an AMQP exchange.
*
@@ -50,6 +51,8 @@
public class AMQPSpout implements IRichSpout {
private static final long serialVersionUID = 11258942292629263L;
+ private static final Logger log = Logger.getLogger(AMQPSpout.class);
+
private static final long WAIT_FOR_NEXT_MESSAGE = 50L;
private final String amqpHost;
@@ -119,17 +122,15 @@ public void close() {
amqpChannel.close();
}
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.warn("Error closing AMQP channel", e);
}
try {
if (amqpConnection != null) {
amqpConnection.close();
}
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.warn("Error closing AMQP connection", e);
}
}
@@ -165,8 +166,7 @@ public void open(@SuppressWarnings("rawtypes") Map config, TopologyContext conte
setupAMQP();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.error("AMQP setup failed", e);
}
}

0 comments on commit fffbe8c

Please sign in to comment.