Search
Close this search box.
Apache Cassandra and Apache Nifi

Apache Cassandra Lunch #60: Apache Cassandra and Apache Nifi

Apache Cassandra Lunch #60: Apache Cassandra and Apache Nifi, we discussed how we can connect Apache Cassandra and Apache Nifi. The live recording of Cassandra Lunch, which includes a more in-depth discussion and a demo, is embedded below in case you were not able to attend live. If you would like to attend Apache Cassandra Lunch live, it is hosted every Wednesday at 12 PM EST. Register here now!

Apache Cassandra Lunch #60, we discussed how we can connect Apache Cassandra and Apache Nifi with a demo on how to set up the Cassandra Session Provider and run a simple CQL query via Nifi.

If you want an introduction to Apache Nifi and to learn how to do some other kinds of data transformations, check out Data Engineer’s Lunch #29: Introduction to Apache Nifi. You can also check out the GitHub repo for that Data Engineer’s Lunch here!

Walkthrough

In this walkthrough, we show you how to set up the Cassandra session provider and use Nifi to run a simple `SELECT *` query on our Cassandra instance. For a more in-depth discussion of the demo, be sure to check out the live recording embedded below!

Prerequisites

1. Setup Dockerized Apache Cassandra

1.1 – Start Apache Cassandra Container and Mount Directory

docker run --name cassandra -p 9042:9042 -d cassandra:latest

1.2 – Run cqlsh

docker exec -it cassandra cqlsh

1.3 – Copy and paste below items into the CQLSH terminal

CREATE KEYSPACE demo WITH REPLICATION={'class': 'SimpleStrategy', 'replication_factor': 1};

CREATE TABLE demo.previous_employees_by_job_title (
    job_title text,
    employee_id uuid,
    employee_name text,
    first_day timestamp,
    last_day timestamp,
    PRIMARY KEY (job_title, employee_id)
) WITH CLUSTERING ORDER BY (employee_id ASC);

insert into previous_employees_by_job_title (job_title, employee_id, employee_name, first_day, last_day)
values('Biologist', e48fd2c9-3abb-4592-a7d6-ccccf06e991e, 'Fiona Lane', '2009-02-26 20:47:18Z', '2005-10-13 20:01:22Z') ;

2. Start Nifi

2.1 – Navigate to Apache Nifi directory and start in background mode

./bin/nifi.sh start

2.2 – Log into Apache Nifi

Navigate to https://localhost:8443/nifi/login

If this is your first time logging into local Apache Nifi, you will need to find the autogenerated credentials. You can do so by running the below command within the Apache Nifi directory and then searching for Username and Password:

cat logs/nifi-app_<date>.log

3. Watch the rest of the walkthrough below!

Resources

Cassandra.Link

Cassandra.Link is a knowledge base that we created for all things Apache Cassandra. Our goal with Cassandra.Link was to not only fill the gap of Planet Cassandra but to bring the Cassandra community together. Feel free to reach out if you wish to collaborate with us on this project in any capacity.

We are a technology company that specializes in building business platforms. If you have any questions about the tools discussed in this post or about any of our services, feel free to send us an email!