{"id":22611269,"url":"https://github.com/bzdgn/apache-camel-twitter-with-spring-boot-example","last_synced_at":"2026-05-12T07:34:53.976Z","repository":{"id":81112531,"uuid":"181955461","full_name":"bzdgn/apache-camel-twitter-with-spring-boot-example","owner":"bzdgn","description":"A demo for Apache Camel with Twitter Component and SQL component integrated with Spring Boot","archived":false,"fork":false,"pushed_at":"2019-04-17T19:29:09.000Z","size":353,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T09:47:48.030Z","etag":null,"topics":["apache-camel","enterprise-integration-patterns","postgresql","spring-boot","twitter","twitter4j"],"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/bzdgn.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-17T19:28:03.000Z","updated_at":"2020-12-15T21:18:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"216534b9-c045-436a-a7b5-1b788614fea6","html_url":"https://github.com/bzdgn/apache-camel-twitter-with-spring-boot-example","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/bzdgn%2Fapache-camel-twitter-with-spring-boot-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzdgn%2Fapache-camel-twitter-with-spring-boot-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzdgn%2Fapache-camel-twitter-with-spring-boot-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bzdgn%2Fapache-camel-twitter-with-spring-boot-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bzdgn","download_url":"https://codeload.github.com/bzdgn/apache-camel-twitter-with-spring-boot-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246112659,"owners_count":20725302,"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":["apache-camel","enterprise-integration-patterns","postgresql","spring-boot","twitter","twitter4j"],"created_at":"2024-12-08T16:10:05.222Z","updated_at":"2026-05-12T07:34:53.932Z","avatar_url":"https://github.com/bzdgn.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Apache Camel Twitter Example With Spring Boot\n=============================================\nThe main purpose of this project is to demonstrate Apache Camel and it's Twitter component.\nApache Camel is used within the Spring Boot context. \n\nTOC\n---\n- [1 Description Of The Project](#1-description-of-the-project) \u003cbr/\u003e\n- [2 Enterprise Integration Patterns](#2-enterprise-integration-patterns) \u003cbr/\u003e\n- [3 Project Setup](#3-project-setup) \u003cbr/\u003e\n- [4 Twitter Tokens](#4-twitter-tokens) \u003cbr/\u003e\n- [5 Notes, Future Improvements, TODOs](#5-notes-future-improvements-todos) \u003cbr/\u003e\n\n\n 1 Description Of The Project\n-----------------------------\n\nThis simple stand-alone application checks the result of twitter-search for the configured\nsearch-term regularly with a constant period which is also configurable, then converts the\nTwitter Status object into a custom Twitter Info object and persist it into the PostgreSQL\ndatabase.\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://github.com/bzdgn/apache-camel-twitter-with-spring-boot-example/blob/master/screenshots/00_diagram.PNG\" alt=\"diagram\"\u003e\n\u003c/p\u003e\n\nAs can be seen in the diagram, the main input of the application is retrieved from Twitter.\nApache Camel's Twitter Component is used to retrieve the input. The input data format is\nin the Status class of the Twitter4j component. Then, this class is transformed into the\ncustom TweetInfo class and lastly, the TweetInfo class object instances are persisted into\nthe PostgreSQL database.\n\nThe flow is simple, every N seconds, the output of the tweeter-search is retrieved. This N\nseconds and the search-term is configurable via application.properties file. After each \ncycle, the tweets are persisted to the TWEET_INFO table in the database.\n\nAfter the start of the program, the retrieved tweets are going to be logged as follows;\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://github.com/bzdgn/apache-camel-twitter-with-spring-boot-example/blob/master/screenshots/01_eclipse_capture.PNG\" alt=\"eclipse_capture\"\u003e\n\u003c/p\u003e\n\nAnd also, database is going to be populated as can be seen as follows;\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://github.com/bzdgn/apache-camel-twitter-with-spring-boot-example/blob/master/screenshots/02_db_capture.PNG\" alt=\"db_capture\"\u003e\n\u003c/p\u003e\n\n[Go back to TOC](#toc)\n\n\n 2 Enterprise Integration Patterns\n----------------------------------\nApache Camel is actually an implementation of Enterprise Integration Patterns. There are a\nfew patterns used in this demo project;\n\n- [Message Channel](http://camel.apache.org/message-channel.html)\n- [Message Translator](http://camel.apache.org/message-translator.html)\n\nThere are two Route classes in the router package which are both Message Channels.\nBetween the channels, the data type should be transformed from the twitter4j.Status\ninto the TweetInfo class structure. To make that, Message Translator is used by using\nthe Processor interface. TweetInfo processor is as simple example of Message Translator.\n\n[Go back to TOC](#toc)\n\n\n 3 Project Setup\n----------------\nBefore starting the fat-jar, there must be an existing postgresql database. It's better\nto use a PostgreSQL docker container for the simplicity;\n\nFor a windows solution, first create a volume, in this case\n\n```\ndocker volume create pg-docker-volume\n```\n\nThen use this volume with the postgresql container;\n\n```\ndocker run --name pg-docker -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 -v pg-docker-volume:/var/lib/postgresql/data  postgres\n```\n\nThe second step is to run the pg-admin (or you can use the command-line), and create a test\ndatabase. For this project, as it is written in the application.properties file, the name\nof the database is **test_db**. So you need to create a database with this name.\n\nThird step is to create the **TWEET_INFO** table as below;\n\n```\nCREATE TABLE TWEET_INFO (\n    ID SERIAL           PRIMARY KEY,\n    TWEET_ID            BIGINT,\n    TEXT                VARCHAR(280) NOT NULL,\n    USERNAME            VARCHAR(50),\n    LANGUAGE            VARCHAR(50),\n    LOCATION            VARCHAR(50),\n    FAVOURITE_COUNT     INT,\n    CREATION_DATE       TIMESTAMP NOT NULL\n);\n```\n\nNow you can install with\n\n`mvn clean install`\n\nand then make the fat-jar with;\n\n`mvn package`\n\nthen run the fat jar as below;\n\n```\njava -jar twitter-monitor.jar\n```\n\n[Go back to TOC](#toc)\n\n\n 4 Twitter Tokens\n-----------------\nIn the application.properties file, you should populate the twitter related entries,\nwhich are;\n\n- twitter.consumerKey\n- twitter.consumerSecret\n- twitter.accessToken\n- twitter.accessTokenSecret\n\nIn order to receive these, you need to create a twitter developer account, create\nan twitter application and receive your tokens as can be seen below;\n\n\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://github.com/bzdgn/apache-camel-twitter-with-spring-boot-example/blob/master/screenshots/03_twitter_tokens.PNG\" alt=\"twitter_tokens_screen\"\u003e\n\u003c/p\u003e\n\n\n[Go back to TOC](#toc)\n\n\n 5 Notes, Future Improvements, TODOs\n------------------------------------\nOne hard thing to get used to a new framework is to know and get used to how to mock the\ndependencies of the new framework. In this case, in the context of Apache Camel, one thing\nI have found hard is to mock the Camel components like Twitter Component or SQL Component.\n\nBest practices of testing these components is a #1 todo to add to this project.\n\nA second things is, a different type of Message Translator can be used. So one to-do\ninvestigation is to see if it is possible to transform the message body directly into\na bean properly. Then the TweetInfoProcessor can be updated or changed.\n\nA third thing is, which way is better to configure the routes. Having one simple class or\nhaving multiple classes as a Spring Component. Which one is easier to maintain, which is\nbetter to read and test?\n\nA fourth thing is, the whole thing should be dockerized. I have already written a docker\nfile but that's not enough. The better solution is to create a docker-compose file. I have\nalso put a compose file here but it's failing right now. The application container cannot\ncommunicate with the database container, this should be fixed.\n\n\n[Go back to TOC](#toc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbzdgn%2Fapache-camel-twitter-with-spring-boot-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbzdgn%2Fapache-camel-twitter-with-spring-boot-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbzdgn%2Fapache-camel-twitter-with-spring-boot-example/lists"}