这是我连接 aws kinesis 的代码。当我尝试与 FlinkKinesisConsumer 连接时,它会抛出 Classnotfound 异常之类的错误。
import configs.AWSConfigConstants;
import com.amazonaws.services.kinesisanalytics.runtime.KinesisAnalyticsRuntime;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.LocalStreamEnvironment;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kinesis.FlinkKinesisConsumer;
import org.apache.flink.streaming.connectors.kinesis.config.ConsumerConfigConstants;
public class StreamingJob {
public static void main(String[] args) {
try {
final StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment();
String region = "us-east-1";
String inputStreamName = "";
String accesskey = "";
String secretkey = "";
String initPosition = "LATEST";
String arn = "";
Properties consumerConfig = new Properties();
consumerConfig.put(AWSConfigConstants.AWS_REGION, region);
consumerConfig.put(AWSConfigConstants.AWS_ACCESS_KEY_ID, accesskey);
consumerConfig.put(AWSConfigConstants.AWS_SECRET_ACCESS_KEY, secretkey);
consumerConfig.put(AWSConfigConstants.AWS_ROLE_ARN, arn );
consumerConfig.put(AWSConfigConstants.STREAM_INITIAL_POSITION, initPosition);
System.out.println("Consume config properties:");
System.out.println(consumerConfig);
DataStream<String> kinesisInputStream = sEnv.addSource(new FlinkKinesisConsumer<>
(inputStreamName,new SimpleStringSchema(),consumerConfig));
System.out.println(kinesisInputStream);
sEnv.execute("Flink Streaming Processor");
} catch(Exception e) {
System.out.println(e);
}
}
我收到以下错误
在此先感谢您的帮助。