{"id":19368621,"url":"https://github.com/ghusta/spring-boot-demo-event-publishing","last_synced_at":"2026-04-20T04:04:55.970Z","repository":{"id":148621185,"uuid":"614562272","full_name":"ghusta/spring-boot-demo-event-publishing","owner":"ghusta","description":"Demo for Spring Boot Application Events","archived":false,"fork":false,"pushed_at":"2023-06-02T18:53:48.000Z","size":77,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T13:48:41.045Z","etag":null,"topics":["event","spring-boot"],"latest_commit_sha":null,"homepage":"","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/ghusta.png","metadata":{"files":{"readme":"README.adoc","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":"2023-03-15T21:00:07.000Z","updated_at":"2023-03-15T21:02:20.000Z","dependencies_parsed_at":"2025-01-06T22:33:11.176Z","dependency_job_id":"a0d71fc3-f915-42fc-a583-e017c56c26bf","html_url":"https://github.com/ghusta/spring-boot-demo-event-publishing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ghusta/spring-boot-demo-event-publishing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghusta%2Fspring-boot-demo-event-publishing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghusta%2Fspring-boot-demo-event-publishing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghusta%2Fspring-boot-demo-event-publishing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghusta%2Fspring-boot-demo-event-publishing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghusta","download_url":"https://codeload.github.com/ghusta/spring-boot-demo-event-publishing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghusta%2Fspring-boot-demo-event-publishing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271650860,"owners_count":24796725,"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","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["event","spring-boot"],"created_at":"2024-11-10T08:07:20.083Z","updated_at":"2026-04-20T04:04:55.923Z","avatar_url":"https://github.com/ghusta.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Demo for Spring Boot Application Events\n:author: Guillaume HUSTA\n:toc:\n\n== Overview\n\nDemo for testing publish/subscribe events with Spring Boot.\n\nSome subscribers are *synchronous*, others are *asynchronous* like email sending.\n\n=== Publisher\n\nOne publisher publishes events.\nAll these events will be subclasses of `ObservationEvent`.\n\n=== Subscribers\n\nThere are 2 kinds of subscribers : synchronous and asynchronous.\n\n==== Synchronous\n\n* `ObservationEventCyanLoggerListener` prints events on console with color _cyan_\n* `ObservationEventGreenLoggerListener` prints events on console with color _green_\n* `ObservationEventRedLoggerListener` prints events on console with color _red_\n\n==== Asynchronous\n\n* `AsyncObservationEventLoggerListener` prints events on console asynchronously\n* `SendMailObservationListener` sends emails asynchronously, if SMTP server is available\n\n== How to test it\n\n=== Ensure a SMTP server is accessible\n\nEither configure `src/main/resources/application.properties` with your own SMTP server (see https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#appendix.application-properties.mail[Spring Boot mail configuration]), or launch a fake SMTP server.\n\nYou can do the latter with the provided link:docker-compose.yml[docker-compose.yml] file, launching a SMTP server by default on localhost, port 2525 :\n\n[source,bash]\n----\ndocker compose up -d\n----\n\nThe sent emails will then be accessible in the local folder `sent-emails`.\n\n=== Launch Spring Boot app\n\nWith Maven :\n\n[source,bash]\n----\nmvn spring-boot:run\n----\n\n=== Execution log example\n\n====\n[%hardbreaks]\n2023-03-16T10:22:19.486+01:00  INFO 6240 --- [           main] c.e.d.DemoEventPublishingApplication     : Starting DemoEventPublishingApplication using Java 17.0.6 with PID 6240 (\\Java\\demo-event-publishing\\target\\classes started by g in \\Java\\demo-event-publishing)\n2023-03-16T10:22:19.489+01:00  INFO 6240 --- [           main] c.e.d.DemoEventPublishingApplication     : No active profile set, falling back to 1 default profile: \"default\"\n2023-03-16T10:22:19.868+01:00  INFO 6240 --- [           main] c.e.d.DemoEventPublishingApplication     : Started DemoEventPublishingApplication in 0.619 seconds (process running for 0.825)\n2023-03-16T10:22:19.870+01:00  INFO 6240 --- [           main] c.e.d.DemoEventPublishingApplication     : Running the app...\n2023-03-16T10:22:19.870+01:00  INFO 6240 --- [           main] c.e.d.service.MyService                  : Entering addObservation()...\nASYNC -- It's a ObservationAddedEvent !\n[blue]#It's a ObservationAddedEvent... Content is : Nothing interesting 😴#\n[green]#It's a ObservationAddedEvent... Content is : Nothing interesting 😴#\n[red]#It's a ObservationAddedEvent... Content is : Nothing interesting 😴#\n2023-03-16T10:22:19.885+01:00  INFO 6240 --- [           main] c.e.d.service.MyService                  : Entering publishObservation()...\nASYNC -- It's a ObservationPublishedEvent !\n[blue]#It's a ObservationPublishedEvent !#\n[green]#It's a ObservationPublishedEvent !#\n[red]#It's a ObservationPublishedEvent !#\n2023-03-16T10:22:19.886+01:00  INFO 6240 --- [           main] c.e.d.service.MyService                  : Entering removeObservation()...\n2023-03-16T10:22:19.886+01:00 DEBUG 6240 --- [         task-4] c.e.d.l.SendMailObservationListener      : Sending a mail async... (Observation published) (in task-4)\n2023-03-16T10:22:19.885+01:00 DEBUG 6240 --- [         task-2] c.e.d.l.SendMailObservationListener      : Sending a mail async... (Observation added) (in task-2)\n[blue]#It's a ObservationRemovedEvent !#\n[green]#It's a ObservationRemovedEvent !#\n[red]#It's a ObservationRemovedEvent !#\n2023-03-16T10:22:19.887+01:00 DEBUG 6240 --- [         task-6] c.e.d.l.SendMailObservationListener      : Event not managed (com.example.demoeventpublishing.event.ObservationRemovedEvent)\n2023-03-16T10:22:20.014+01:00 DEBUG 6240 --- [         task-4] c.e.d.l.SendMailObservationListener      : Mail sent (in task-4)\n2023-03-16T10:22:20.015+01:00 DEBUG 6240 --- [         task-2] c.e.d.l.SendMailObservationListener      : Mail sent (in task-2)\n====\n\n== References\n\n* Spring Boot :\n** https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.spring-application.application-events-and-listeners[Application Events and Listeners]\n** https://docs.spring.io/spring-boot/docs/current/reference/html/io.html#io.email[Sending Email]\n** https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.task-execution-and-scheduling[Task Execution and Scheduling], for asynchronous task execution (`@EnableAsync`)\n* Articles :\n** https://reflectoring.io/spring-boot-application-events-explained/[Spring Boot Application Events Explained]\n** https://howtodoinjava.com/spring-core/how-to-publish-and-listen-application-events-in-spring/[Spring Application Events]\n* Issues / Mentions :\n** ⭐ https://github.com/spring-projects/spring-framework/issues/27777[Mention explicitly that @EventListener should be put on public methods] =\u003e *INVALID*\n*** Related : https://github.com/spring-projects/spring-framework/pull/26785","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghusta%2Fspring-boot-demo-event-publishing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghusta%2Fspring-boot-demo-event-publishing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghusta%2Fspring-boot-demo-event-publishing/lists"}