storm-kafka forceStartOffsetTime(int)符号找不到符号

时间:2015-06-16 23:47:01

标签: java maven apache-kafka apache-storm

我正试图让一个非常简单的卡夫卡鲸鱼喷水暴雨。我的主要功能是来自Exclamation示例的非常简单的改编;

TopologyBuilder builder = new TopologyBuilder();
String zkConnString = "localhost:2181";
String brokerZkPath = "/kafka";
String topicName = "test";
BrokerHosts hosts = new ZkHosts(zkConnString);
SpoutConfig spoutConfig = new SpoutConfig(hosts, topicName, "" , "test123");
spoutConfig.forceStartOffsetTime(-2);
//spoutConfig.startOffsetTime =  kafka.api.OffsetRequest.EarliestTime();
spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);

//builder.setSpout("word", new TestWordSpout(), 10);
builder.setSpout("word", kafkaSpout, 1); 
builder.setBolt("exclaim1", new ExclamationBolt(), 3).shuffleGrouping("word");
builder.setBolt("exclaim2", new ExclamationBolt(), 2).shuffleGrouping("exclaim1");

当我做mvn包时,我收到以下错误:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /usr/local/apache-storm-0.9.2-incubating/examples/test-example/my-app/src/main/java/com/mycompany/app/ExclamationTopology.java:[89,16] cannot find symbol
  symbol:   method forceStartOffsetTime(int)
  location: variable spoutConfig of type storm.kafka.SpoutConfig
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.268 s
[INFO] Finished at: 2015-06-16T19:22:10-04:00
[INFO] Final Memory: 26M/446M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-app: Compilation failure
[ERROR] /usr/local/apache-storm-0.9.2-incubating/examples/test-example/my-app/src/main/java/com/mycompany/app/ExclamationTopology.java:[89,16] cannot find symbol
[ERROR] symbol:   method forceStartOffsetTime(int)
[ERROR] location: variable spoutConfig of type storm.kafka.SpoutConfig
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

如果我删除该行有' spoutConfig.forceStartOffsetTime(-2);',则会成功编译。但是,如果使用:spoutConfig.startOffsetTime = kafka.api.OffsetRequest.EarliestTime();它不会将偏移设置为主题中最早的偏移量。主题'测试'它只有4条消息,如果我设置了spoutConfig.startOffsetTime = kafka.api.OffsetRequest.EarliestTime(),则偏移量设置为4而不是0.我真的需要一种方法来设置它最早的偏移量。

我在pom.xml中的依赖项:

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.8.5</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.easytesting</groupId>
      <artifactId>fest-assert-core</artifactId>
      <version>2.0M8</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jmock</groupId>
      <artifactId>jmock</artifactId>
      <version>2.6.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
     <groupId>org.twitter4j</groupId>
     <artifactId>twitter4j-stream</artifactId>
     <version>3.0.3</version>
    </dependency>
    <dependency>
      <groupId>org.apache.storm</groupId>
      <artifactId>storm-core</artifactId>
      <version>${project.version}</version>
      <!-- keep storm out of the jar-with-dependencies -->
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.storm</groupId>
      <artifactId>storm-kafka</artifactId>
      <version>0.9.2-incubating</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.10</artifactId>
        <version>0.8.2.0</version>
        <!--
        <artifactId>kafka_2.9.2</artifactId>
        <version>0.8.1.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
            </exclusion>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
</dependencies>

1 个答案:

答案 0 :(得分:0)

我相信storm 0.9.2 -incubating the correct property should be forceFromStart接受Boolean值而不是int

所以你可以做spoutConfig.forceFromStart = true

之类的事情