- Clear environment. Stop processes and remove existing containers.
docker stop CassandraNode1
docker rm CassandraNode1
- Build docker image.
docker build -t pubsub.java .
- Pull cassandra image.
docker pull cassandra
- Start cassandra instance and wait for it to start.
docker run -p 9042:9042 --rm --name CassandraNode1 -d cassandra
- Monitor with:
docker logs -f CassandraNode1
and wait for the line:
Created default superuser role 'cassandra'
- Run sql shell on cassandra cluster.
docker exec -it CassandraNode1 bash -c 'cqlsh'
and create the application keyspace:
CREATE KEYSPACE pubsubkeyspace
WITH replication =
{
'class' : 'SimpleStrategy',
'replication_factor' : 1
};
also create the table:
use pubsubkeyspace;
create table if not exists pubsubkeyspace.message (
topic text,
partitionId int,
payload text,
messageDate timestamp,
primary key((topic, partitionId), messageDate)
)
with clustering order by (messageDate asc);
- Get IP and load details.
docker exec -it CassandraNode1 bash -c 'nodetool status'
- Hit publish URL:
http://localhost:8082/api/v1/publish
and verify data in the DB:
select * from messages;