Flink persistence
Flink provides a connector with the sinks or persistences, such as:
- Apache Kafka
- Elasticsearch
- Hadoop Filesystem
- RabbitMQ
- Amazon Kinesis Streams
- Apache NiFi
- Apache Casssandra
In this book, we will discuss the Flink and Cassandra connection as it is the most popular.
Integration with Cassandra
We have discussed and explained the setup of Cassandra in previous chapters so we will directly go to the program required to make a connection between Flink and Cassandra:
- Add dependencies in
pom.xml
:
<dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-connector-cassandra_2.11</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>com.codahale.metrics</groupId> <artifactId>metrics-json</artifactId> <version>3.0.2</version> </dependency>
- Create the data stream:
DataStream<Tuple4<Long,Integer,Integer,Long>> messageStream = env.addSource...