Java 弗林克加入到这条小溪中来,使它富起来
我对阿帕奇·弗林克很陌生。我使用的是v1.9.0。我想加入多个流。运行以下示例时,我遇到以下异常 例外情况: 我的主要方法是:Java 弗林克加入到这条小溪中来,使它富起来,java,apache-flink,Java,Apache Flink,我对阿帕奇·弗林克很陌生。我使用的是v1.9.0。我想加入多个流。运行以下示例时,我遇到以下异常 例外情况: 我的主要方法是: public class ProcessingTimeJoinExercise { @SuppressWarnings("serial") public static void main(String[] args) throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvir
public class ProcessingTimeJoinExercise {
@SuppressWarnings("serial")
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
// Simulated trade stream
DataStream<Trade> tradeStream = FinSources.tradeSource(env);
// Simulated customer stream
DataStream<Customer> customerStream = FinSources.customerSource(env);
// Stream of enriched trades
DataStream<EnrichedTrade> joinedStream = tradeStream
.join(customerStream).where(new KeySelector<Trade, Long>() {
@Override
public Long getKey(Trade trade) throws Exception {
return trade.customerId;
}
}).equalTo(new KeySelector<Customer, Long>() {
@Override
public Long getKey(Customer cust) throws Exception {
// TODO Auto-generated method stub
return cust.customerId;
}
}).window(SlidingEventTimeWindows.of(Time.milliseconds(2) /* size */, Time.milliseconds(1) /* slide */))
.apply(new JoinFunction<Trade, Customer, EnrichedTrade>() {
@Override
public EnrichedTrade join(Trade trade, Customer customer) {
return new EnrichedTrade(trade, customer);
}
});
joinedStream.print();
env.execute("processing-time join");
你知道我做错了什么吗?如果你加上
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
在env初始化之后的最开始处,它将正确运行。如果您添加
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
接近开始时,在env初始化之后,它将正确运行