有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java stormkafka forceStartOffsetTime(int)符号找不到符号

我试图让一个非常简单的卡夫卡喷口在风暴中运行。我的主要功能是对感叹号示例的一个非常简单的改编

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

如果我删除了有“喷口配置”的行。FORCESTARTOFSETTIME(-2);',它编译成功。但是,如果使用:喷口配置。startOffsetTime=kafka。应用程序编程接口。抵销请求。早期时间();它不会将偏移量设置为主题中最早的偏移量。如果我设置spoutConfig,主题“test”中只有4条消息。startOffsetTime=kafka。应用程序编程接口。抵销请求。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) 个答案

  1. # 1 楼答案

    我相信storm 0.9.2 -incubating{a1}{},它接受Boolean值而不是int

    所以你可以做spoutConfig.forceFromStart = true