{"id":19921168,"url":"https://github.com/chriniko13/simple-like-cqrs-sample","last_synced_at":"2025-03-01T10:14:03.170Z","repository":{"id":45531673,"uuid":"211969715","full_name":"chriniko13/simple-like-cqrs-sample","owner":"chriniko13","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-16T08:52:59.000Z","size":19,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T23:47:47.062Z","etag":null,"topics":["cdi","elastic-search","jackson","javaee7","kafka-clients","lombok","primefaces"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chriniko13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-30T22:34:51.000Z","updated_at":"2019-10-01T07:09:31.000Z","dependencies_parsed_at":"2023-01-21T18:59:14.748Z","dependency_job_id":null,"html_url":"https://github.com/chriniko13/simple-like-cqrs-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriniko13%2Fsimple-like-cqrs-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriniko13%2Fsimple-like-cqrs-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriniko13%2Fsimple-like-cqrs-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chriniko13%2Fsimple-like-cqrs-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chriniko13","download_url":"https://codeload.github.com/chriniko13/simple-like-cqrs-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241348360,"owners_count":19948164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdi","elastic-search","jackson","javaee7","kafka-clients","lombok","primefaces"],"created_at":"2024-11-12T22:06:50.183Z","updated_at":"2025-03-01T10:14:03.146Z","avatar_url":"https://github.com/chriniko13.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Simple Like Cqrs Sample\n\n#### Description\nA simple app which shows how a cqrs behaves.\n\n* Write Side = Kafka\n* Read Side = Heap or Elastic Search\n\n\n#### Prerequisites - How to run app\n\n* Setup local environment by executing: `docker-compose up` (clean up: `docker-compose down`)\n\n\n* Create kafka topic posts with 20 partitions and replication factor 3\n    * Command: \n        `./kafka-topics.sh --create --zookeeper localhost:2181 --topic posts --partitions 20 --replication-factor 3`\n\n\n* Download Payara application server in order to deploy WAR\n    * https://www.payara.fish/software/payara-server/\n    \n* Create WAR: `mvn clean install` (it will be created inside target folder with the name: `simple-like-cqrs-sample.war`)\n\n* Deploy WAR where is inside target folder with the name: `simple-like-cqrs-sample.war` to Payara Application Server or any other JavaEE7 compliant server.\n\n* Open web browser at: `http://localhost:8080/simple-like-cqrs-sample/`\n\n\n#### Access Elastic Search\n* Visit: `http://localhost:9200/`\n\n\n#### Access Kibana\n* Visit: `http://localhost:5601/app/kibana`\n\n\n#### Storage Selection\n* Use/choose in `PostManager.java` the annotation in ctor injection (line: 29)\n    * `@Materialization(MaterializationType.ELASTIC_SEARCH)`\n    * `@Materialization(MaterializationType.HEAP)`\n    \n    \n#### Useful commands\n\n* List kafka topics\n    * `./kafka-topics.sh --list --zookeeper localhost:2181`\n\n* Describe specified kafka topic (in this example we have 20 partitions but replication factor is 1)\n    * `./kafka-topics.sh --describe --zookeeper localhost:2181 --topic posts`\n        \n        ```\n        Topic:posts\tPartitionCount:20\tReplicationFactor:1\tConfigs:\n            Topic: posts\tPartition: 0\tLeader: 3\tReplicas: 3\tIsr: 3\n            Topic: posts\tPartition: 1\tLeader: 1\tReplicas: 1\tIsr: 1\n            Topic: posts\tPartition: 2\tLeader: 2\tReplicas: 2\tIsr: 2\n            Topic: posts\tPartition: 3\tLeader: 3\tReplicas: 3\tIsr: 3\n            Topic: posts\tPartition: 4\tLeader: 1\tReplicas: 1\tIsr: 1\n            Topic: posts\tPartition: 5\tLeader: 2\tReplicas: 2\tIsr: 2\n            Topic: posts\tPartition: 6\tLeader: 3\tReplicas: 3\tIsr: 3\n            Topic: posts\tPartition: 7\tLeader: 1\tReplicas: 1\tIsr: 1\n            Topic: posts\tPartition: 8\tLeader: 2\tReplicas: 2\tIsr: 2\n            Topic: posts\tPartition: 9\tLeader: 3\tReplicas: 3\tIsr: 3\n            Topic: posts\tPartition: 10\tLeader: 1\tReplicas: 1\tIsr: 1\n            Topic: posts\tPartition: 11\tLeader: 2\tReplicas: 2\tIsr: 2\n            Topic: posts\tPartition: 12\tLeader: 3\tReplicas: 3\tIsr: 3\n            Topic: posts\tPartition: 13\tLeader: 1\tReplicas: 1\tIsr: 1\n            Topic: posts\tPartition: 14\tLeader: 2\tReplicas: 2\tIsr: 2\n            Topic: posts\tPartition: 15\tLeader: 3\tReplicas: 3\tIsr: 3\n            Topic: posts\tPartition: 16\tLeader: 1\tReplicas: 1\tIsr: 1\n            Topic: posts\tPartition: 17\tLeader: 2\tReplicas: 2\tIsr: 2\n            Topic: posts\tPartition: 18\tLeader: 3\tReplicas: 3\tIsr: 3\n            Topic: posts\tPartition: 19\tLeader: 1\tReplicas: 1\tIsr: 1\n        ```\n    \n* Alter partitions of specified kafka topic\n    * `./kafka-topics.sh --alter --zookeeper localhost:2181 --topic posts --partitions 20`\n\n* To increase the number of replicas.\n    1) Specify the extra replicas in a custom reassignment json file (For example, you could create increase-replication-factor.json and put this content in it)\n     \n     ```json5\n    \n    {\"version\":1,\n          \"partitions\":[\n             {\"topic\":\"posts\",\"partition\":0,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":1,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":2,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":3,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":4,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":5,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":6,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":7,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":8,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":9,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":10,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":11,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":12,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":13,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":14,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":15,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":16,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":17,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":18,\"replicas\":[1,2,3]},\n             {\"topic\":\"posts\",\"partition\":19,\"replicas\":[1,2,3]}\n        ]}\n    \n    ````\n    \n    2) Use the file with the --execute option of the kafka-reassign-partitions tool\n    `./kafka-reassign-partitions --zookeeper localhost:2181 --reassignment-json-file increase-replication-factor.json --execute`\n\n    3) Verify the replication factor with the kafka-topics tool\n    `./kafka-topics.sh --describe --zookeeper localhost:2181 --topic posts`\n    \n    Output:\n    ```\n    Topic:posts\tPartitionCount:20\tReplicationFactor:3\tConfigs:\n    \tTopic: posts\tPartition: 0\tLeader: 3\tReplicas: 1,2,3\tIsr: 3,2,1\n    \tTopic: posts\tPartition: 1\tLeader: 1\tReplicas: 1,2,3\tIsr: 1,2,3\n    \tTopic: posts\tPartition: 2\tLeader: 2\tReplicas: 1,2,3\tIsr: 2,1,3\n    \tTopic: posts\tPartition: 3\tLeader: 3\tReplicas: 1,2,3\tIsr: 3,1,2\n    \tTopic: posts\tPartition: 4\tLeader: 1\tReplicas: 1,2,3\tIsr: 1,2,3\n    \tTopic: posts\tPartition: 5\tLeader: 2\tReplicas: 1,2,3\tIsr: 2,1,3\n    \tTopic: posts\tPartition: 6\tLeader: 3\tReplicas: 1,2,3\tIsr: 3,1,2\n    \tTopic: posts\tPartition: 7\tLeader: 1\tReplicas: 1,2,3\tIsr: 1,2,3\n    \tTopic: posts\tPartition: 8\tLeader: 2\tReplicas: 1,2,3\tIsr: 2,1,3\n    \tTopic: posts\tPartition: 9\tLeader: 3\tReplicas: 1,2,3\tIsr: 3,1,2\n    \tTopic: posts\tPartition: 10\tLeader: 1\tReplicas: 1,2,3\tIsr: 1,2,3\n    \tTopic: posts\tPartition: 11\tLeader: 2\tReplicas: 1,2,3\tIsr: 2,1,3\n    \tTopic: posts\tPartition: 12\tLeader: 3\tReplicas: 1,2,3\tIsr: 3,1,2\n    \tTopic: posts\tPartition: 13\tLeader: 1\tReplicas: 1,2,3\tIsr: 1,2,3\n    \tTopic: posts\tPartition: 14\tLeader: 2\tReplicas: 1,2,3\tIsr: 2,1,3\n    \tTopic: posts\tPartition: 15\tLeader: 3\tReplicas: 1,2,3\tIsr: 3,1,2\n    \tTopic: posts\tPartition: 16\tLeader: 1\tReplicas: 1,2,3\tIsr: 1,2,3\n    \tTopic: posts\tPartition: 17\tLeader: 2\tReplicas: 1,2,3\tIsr: 2,1,3\n    \tTopic: posts\tPartition: 18\tLeader: 3\tReplicas: 1,2,3\tIsr: 3,1,2\n    \tTopic: posts\tPartition: 19\tLeader: 1\tReplicas: 1,2,3\tIsr: 1,2,3\n\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriniko13%2Fsimple-like-cqrs-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchriniko13%2Fsimple-like-cqrs-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchriniko13%2Fsimple-like-cqrs-sample/lists"}