How to implement websocket in Dropwizard

I have a requirement to implement websocket with the dropwizard project. However, I cannot find any document related to it. Can anyone point the resources to the same thing.

+7
source share
3 answers

I was dealing with the same problem and thought I wanted to share my solution: http://cvwjensen.wordpress.com/2014/08/02/websockets-in-dropwizard/

I use the Atmosphere environment, and the solution uses websockets by default, but can go on a long survey if necessary.

That should be enough for you to start ...

+7
source

I want to do it too. This is the best info I've found so far:

Presumably one of the most popular websocket frameworks works well with Jersey (Jersey bundled with Dropwizard). Learn more about this here: https://github.com/Atmosphere/atmosphere

In addition, someone published a repository combining two of them: https://github.com/mgutz/dropwizard-atmosphere/

+1
source

I implemented websockets in the Dropwizard project by including CometD.

CometD includes a servlet for working with WS queries, and Dropwizard provides an environment for registering arbitrary servlets.

Short excerpt from my application (Groovy):

environment.addServlet(new Initializer(httpClient, amqpConsumer), "/_initializer") .setInitOrder(2) environment.addServlet(AnnotationCometdServlet, "/cometd/*") .addInitParams([ transports: 'org.cometd.websocket.server.WebSocketTransport', services: EventService.getCanonicalName(), jsonContext: 'org.cometd.server.JacksonJSONContextServer', maxSessionsPerBrowser: serviceConfiguration.maxBrowserSessions.toString(), maxInterval: '7200', logLevel: "2" ]).setInitOrder(1) 

The initializer servlet simplifies operation, as shown in the CometD tutorials.

+1
source

All Articles