DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • How To Use Pandas and Matplotlib To Perform EDA In Python
  • Database Integration Tests With Spring Boot and Testcontainers
  • Reactive Programming
  • Chaining API Requests With API Gateway

Trending

  • How To Use Pandas and Matplotlib To Perform EDA In Python
  • Database Integration Tests With Spring Boot and Testcontainers
  • Reactive Programming
  • Chaining API Requests With API Gateway
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Jersey SSE Capability in GlassFish 4.0.1

Jersey SSE Capability in GlassFish 4.0.1

Abhishek Gupta user avatar by
Abhishek Gupta
CORE ·
Jul. 11, 14 · Interview
Like (0)
Save
Tweet
Share
4.43K Views

Join the DZone community and get the full member experience.

Join For Free

glassfish bundles different reference implementations for various java ee specifications e.g. weld for cdi, mojarra for jsf, tyrus for websocket, jersey for jax-rs. glass fish 4.0.1 is in the pipeline and slated to cover updates for many of the components/modules which both include new features and bug fixes of course.

server sent events feature in jersey will be supported with glass fish 4.0.1. let’s try and test out this feature

  1. download the latest glass fish build from here

1 2. unzip the contents of the zip installer and configure the same in your ide ( i am using netbeans ). note : i am using using jdk 8. remember to configure glass fish to use the same

2

jdk8_1

jdk8_2

3. make sure you include the highlighted jars ( below ) in your class path. these are available under gf_install/glassfish/modules

3

4

now, the sample code for jersey sse feature demonstration. its relatively simple.

there are three primary classes involved

aresource.java

it serves as a producer of stream of events and is modeled as jax-rs resource which emits events when invoked with a get method. the returned event streams are abstracted in the form of org.glassfish.jersey.media.sse.eventoutput on to which a org.glassfish.jersey.media.sse.outboundevent object is written. the outboundevent consists of the actual event data.

aresource

atestservlet.java

this class serves as consumer of the events produced by the aresource.java class. this is a simple jax-rs client which sends a get request to the published jax-rs resource, reads the org.glassfish.jersey.client.chunkedinput and further extracts the actual event data from org.glassfish.jersey.media.sse.inboundevent instance

atestservlet

restconfig.java

as commonly the case with jax-rs, this serves as bootstrap class

restconfig

to test the sse functionality from server ( producer ) to client ( consumer ), deploy your application and just access the servlet on http://you_gfish_ip:port/jerseysse/ssetest . you should see the following logs

logs

fishcat

about the fishcat – glass fish community acceptance testing program . everyone is welcome to participate!

more on jersey and server sent events here .

this was a rather quick one.. not bad ! now you have time to go and do something more useful ;-)

GlassFish Server-sent events Event

Published at DZone with permission of Abhishek Gupta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • How To Use Pandas and Matplotlib To Perform EDA In Python
  • Database Integration Tests With Spring Boot and Testcontainers
  • Reactive Programming
  • Chaining API Requests With API Gateway

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: