{"id":23109956,"url":"https://github.com/tareqk/jesse","last_synced_at":"2025-04-03T23:27:43.440Z","repository":{"id":45535368,"uuid":"158587911","full_name":"TareqK/Jesse","owner":"TareqK","description":"Server side event framework built on Java EE APIs","archived":false,"fork":false,"pushed_at":"2022-11-16T08:55:28.000Z","size":123,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-02-09T11:23:01.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TareqK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-21T18:04:16.000Z","updated_at":"2019-10-15T17:19:09.000Z","dependencies_parsed_at":"2022-09-14T13:30:53.777Z","dependency_job_id":null,"html_url":"https://github.com/TareqK/Jesse","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TareqK%2FJesse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TareqK%2FJesse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TareqK%2FJesse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TareqK%2FJesse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TareqK","download_url":"https://codeload.github.com/TareqK/Jesse/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247095582,"owners_count":20882809,"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":[],"created_at":"2024-12-17T01:47:24.923Z","updated_at":"2025-04-03T23:27:43.422Z","avatar_url":"https://github.com/TareqK.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/me.kisoft/jesse.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22me.kisoft%22%20AND%20a:%22jesse%22)\n# Jesse\n\nJesse stands for **J**ava **E**nterprise **S**erver **S**ide **E**vents. It is a framework built using JEE APIs to provide server-side event capability in a JEE web application.\n\n# Getting Started\n\n## Adding It to your project\n\nAdd This to your dependencies :\n\n```xml\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003eme.kisoft\u003c/groupId\u003e\n        \u003cartifactId\u003ejesse\u003c/artifactId\u003e\n    \u003c/dependency\u003e\n\n```\n## Setup\nYou need to add some entries into your web.xml\n\n```xml\n\n    \u003cservlet\u003e\n        \u003cservlet-name\u003e{Servlet Name}\u003c/servlet-name\u003e\n        \u003cservlet-class\u003eme.kisoft.jesse.JesseServlet\u003c/servlet-class \u003e\n        \u003cload-on-startup\u003e1\u003c/load-on-startup\u003e\n        \u003casync-supported\u003etrue\u003c/async-supported\u003e\n    \u003c/servlet\u003e\n    \u003cservlet-mapping\u003e\n        \u003cservlet-name\u003e{Servlet Name}\u003c/servlet-name\u003e\n        \u003curl-pattern\u003e{URI mapping}\u003c/url-pattern\u003e\n    \u003c/servlet-mapping\u003e\n\n```\n\nIf you would like to use your own implementation of the SseSessionManager, then you need to add the following init params to your servlet defenition\n\n```xml\n\n    \u003cinit-param \u003e\n        \u003cparam-name\u003eme.kisoft.jesse.session.manager\u003c/param-name \u003e\n        \u003cparam-value\u003e{Class name of session manager}\u003c/param-value \u003e\n    \u003c/init-param \u003e\n\n```\n\n\nYou can also set the interval for the Keep-Alive, by using this paramter\n\n```xml\n\n    \u003cinit-param \u003e\n        \u003cparam-name\u003eme.kisoft.jesse.session.keepalive.interval\u003c/param-name \u003e\n        \u003cparam-value\u003e{interval in secconds}\u003c/param-value \u003e\n    \u003c/init-param \u003e\n\n```\n\nYou can also specify the domains that are allowed to access the event stream, by setting this parameter. Otherwise, it defaults to the domain that made the request(effectively all domains)\n\n\n```xml\n\n    \u003cinit-param \u003e\n        \u003cparam-name\u003eme.kisoft.jesse.session.domains\u003c/param-name \u003e\n        \u003cparam-value\u003e{comma,separated,domain,names}\u003c/param-value \u003e\n    \u003c/init-param \u003e\n\n```\n\nAditionally, you can add mappers for MediaTypes, by adding this to the web.xml\n\n```xml\n\n    \u003cinit-param\u003e\n        \u003cparam-name\u003eme.kisoft.jesse.feature\u003c/param-name\u003e\n        \u003cparam-value\u003e{comma,seperated,features,class,names}\u003c/param-value\u003e\n    \u003c/init-param\u003e\n\n```\nYou can add your own custom mappers by implementing the ```MapperFeature``` interface.\n\nFor example,this is a complete configuration with a custom session manager and the Jackson Mapper\n\n```xml\n\n    \u003cservlet \u003e\n        \u003cservlet-name\u003e EventStream Endpoint \u003c/servlet-name\u003e\n        \u003cservlet-class\u003eme.kisoft.jesse.JesseServlet\u003c/servlet-class \u003e\n        \u003cinit-param\u003e\n            \u003cparam-name \u003eme.kisoft.jesse.session.manager\u003c/param-name \u003e\n            \u003cparam-value\u003eme.kisoft.core.sse.BusrSessionManager\u003c/param-value \u003e\n        \u003c/init-param\u003e\n        \u003cinit-param \u003e\n            \u003cparam-name\u003eme.kisoft.jesse.session.keepalive.enabled\u003c/param-name \u003e\n            \u003cparam-value\u003etrue\u003c/param-value \u003e\n         \u003c/init-param \u003e\n         \u003cinit-param\u003e\n            \u003cparam-name\u003eme.kisoft.jesse.feature\u003c/param-name\u003e\n            \u003cparam-value\u003eme.kisoft.jesse.feature.JacksonMapperFeature\u003c/param-value\u003e\n        \u003c/init-param\u003e\n         \u003cload-on-startup\u003e1\u003c/load-on-startup\u003e\n         \u003casync-supported\u003etrue\u003c/async-supported\u003e\n    \u003c/servlet\u003e\n    \u003cservlet-mapping\u003e\n        \u003cservlet-name\u003e EventStream Endpoint \u003c/servlet-name\u003e\n        \u003curl-pattern\u003e/event/*\u003c/url-pattern\u003e\n    \u003c/servlet-mapping\u003e\n\n```\n\nAnd Thats it! you are now ready to go\n\n# Usage\n\n## Sending Sse Events\n\n```java\n\n DefaultSessionManager.broadcastAll(SseEvent.getBuilder()\n                            .event(\"test\")\n                            .id(33)\n                            .retry(500)\n                            .mediaType(MediaType.APPLICATION_JSON)\n                            .data(notificationData)\n                            .build())\n\n```\n\nLets break this code down\n\n``` DefaultSessionManager ``` is the default implementation of the session manager, which is used by default if no custom SessionManager is provided.\nIt stores all active sessions in a list, and you can broadcast events to groups of sessions, individual sessions, or all sessions.\n\n\n``` SseEventBuilder ``` is a utility class to build a new ``` SseEvent ```. ```event(\"test\")``` sets the type of the event to \"test\", ```mediaType(MediaType.APPLICATION_JSON)``` sets the media type to JSON,  ``` id(33) ``` sets the event id to \"33\",  ``` retry(500) ``` sets the retry interval to 500ms, ``` data(notificationData) ``` sends notification as the event data, and ``` build() ``` creates the ``` SseEvent ``` based on the previous functions. The resulting event would be\n\n```\nid: 33\nevent: test\nretry: 500\ndata:  {\"parameter1\":\"value1\",\"parameter2\":\"value2\",.....,\"parametern\":\"valuen\"}\n\n```\n\n## Custom Session Managers\n\na custom session manager can be created by extending the ``` SseSessionManager ``` class.\nBy default, the sessions are not stored anywhere, so it is up to you to store them in whatever way you see fit.\n\nThe following methods are mandatory to implement\n\n``` onOpen(SseSession sseSession) throws WebApplicationExceptoion ``` : This method is called when a new session is opened. ``` WebApplicationException ``` will terminate this session with the corrseponding Http Response code.\n\n``` onClose(SseSession sseSession) throws WebApplicationExceptoion ``` : This method is called when a session is being closed. will terminate this session. Should not throw any exceptions\n\n``` onError(SseSession sseSession)``` : This method is called if there is an error during opening the session. It should be used for logging/checking if resources were cleared.\n\n\n## Custom Feature Mapping\n\na custom feature mapper can be created by implementing the ```MapperFeature``` interface. As a note, feature registration is global for Jesse, meaning that all your SseSessions will use the same mapper modules. You need to\nimplement these functions\n\n``` serialize(Object object) throws WebApplicationException``` converts the Object into a String form for this mapper feature.\n\n``` getMediaTypeString() ``` returns the String representation of the ```MediaType``` that the Mapper will handle.\n\n``` getMediaType() ``` returns the JAX-RS MediaType representation that the Mapper will handle.\n\nFor now, MapperFeatures are restricted to handling the JAX-RS MediaTypes only, but that might change in the future.\n\n# Building\n\nNothing fancy, just clone and build using the pom.xml file. Unit tests are included\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftareqk%2Fjesse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftareqk%2Fjesse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftareqk%2Fjesse/lists"}