• Stars
    star
    731
  • Rank 61,621 (Top 2 %)
  • Language
    Java
  • Created about 11 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Overview

A sample demonstrating capabilities in the Spring Framework to build WebSocket-style messaging applications. The application uses STOMP (over WebSocket) for messaging between browsers and server and SockJS for WebSocket fallback options.

Client-side libraries used:

Server-side runs on Tomcat, Jetty, WildFly, Glassfish, and other Servlet 3.0+ containers with WebSocket support.

Tomcat

For Tomcat, set TOMCAT_HOME as an environment variable and use deployTomcat.sh and shutdownTomcat.sh in this directory.

Open a browser and go to http://localhost:8080/spring-websocket-portfolio/index.html

Jetty

The easiest way to run on Jetty is with mvn jetty:run.

Open a browser and go to http://localhost:8080/spring-websocket-portfolio/index.html

Note: To deploy to a Jetty installation, add this to Jetty's start.ini:

OPTIONS=plus
etc/jetty-plus.xml
OPTIONS=annotations
etc/jetty-annotations.xml

WildFly 10+

Unzip the WildFly server.

Set WILDFLY_HOME as an environment variable and use deployWildFly.sh in this directory.

Open a browser and go to http://localhost:8080/spring-websocket-portfolio/index.html

WebSphere Liberty 16+

Build and deploy with the following server configuration:

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
    <!-- Enable features -->
    <featureManager>
        <feature>jsp-2.3</feature>
        <feature>webSocket-1.1</feature>
    </featureManager>
    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint id="defaultHttpEndpoint"
                  httpPort="9080"
                  httpsPort="9443" />
    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>
</server>

Glassfish

After unzipping Glassfish 4 start the server:

<unzip_dir>/glassfish4/bin/asadmin start-domain

Set GLASSFISH4_HOME as an environment variable and use deployGlassfish.sh in this directory.

Open a browser and go to http://localhost:8080/spring-websocket-portfolio/index.html

Using a Message Broker

Out of the box, a "simple" message broker is used to send messages to subscribers (e.g. stock quotes) but you can optionally use a fully featured STOMP message broker such as RabbitMQ, ActiveMQ, and others, by following these steps:

  1. Install and start the message broker. For RabbitMQ make sure you've also installed the RabbitMQ STOMP plugin. For ActiveMQ you need to configure a STOMP transport connnector.
  2. Use the MessageBrokerConfigurer in WebSocketConfig.java to enable the STOMP broker relay instead of the simple broker.
  3. You may also need to configure additional STOMP broker relay properties such as relayHost, relayPort, systemLogin, systemPassword, depending on your message broker. The default settings should work for RabbitMQ and ActiveMQ.

Logging

To see all logging, enable TRACE for org.springframework.messaging and org.springframework.samples in log4j.xml.

Keep in mind that will generate a lot of information as messages flow through the application. The QuoteService for example generates a lot of messages frequently. You can modify it to send quotes less frequently or simply comment out the @Scheduled annotation.

More Repositories

1

spring-mvc-chat

Sample code using the Spring MVC 3.2, Servlet-based, async support
Java
174
star
2

spring-websocket-test

Java
167
star
3

demo-reactive-spring

Demo code for "Servlet and Reactive Stacks" talk
Java
163
star
4

reactive-for-webmvc

Demo from talk on reactive programming for existing applications
Java
86
star
5

spring-mvc-31-demo

Demonstrates Spring MVC 3.1 Specific Customization Options
CSS
83
star
6

spring-mvc-jquery-jsp

Ajax requests and partial rendering with jQuery and JSPs
Java
29
star
7

spring-mvc-jquery-sitemesh

Ajax requests and partial rendering with jQuery, JSPs, and SiteMesh
Java
13
star
8

spring-31-and-mvc-testing-support

"Spring 3.1 and MVC Testing Support" presentation for SpringOne 2GX 2011
13
star
9

spring-32-test-webapps

Testing Web Applications with Spring 3.2 Presentation Source
12
star
10

s2gx2015-intro-to-reactive-programming

Demos for "Intro to Reactive Programming" talk
Java
11
star
11

webinar-websocket-spring

Slides for Webinar: "Building WebSocket Browser Applications with Spring"
JavaScript
11
star
12

s2gx2015-reactive-web-apps

Demos for "Reactive Web Apps" at SpringOne2GX 2015
JavaScript
10
star
13

spring-mvc-jquery-tiles

Ajax requests and partial rendering with jQuery, JSPs, and Apache Tiles
Java
9
star
14

s2gx2013-websocket-browser-apps-with-spring

Building WebSocket Browser Applications with Spring (SpringOne2GX Presentation Source)
JavaScript
9
star
15

async-http-client-perftest

Test the performance of sending a large number of concurrent requests
Java
8
star
16

spring-mvc-32-update

"What's New In Spring MVC 3.2" presentation
8
star
17

spring-mvc-31-update

"What's New In Spring MVC 3.1" Presentation
8
star
18

s2gx2015-spring-mvc-42

Demos for "Spring MVC 4.2: New and Noteworthy"
JavaScript
7
star
19

spring-mvc-31-walkthrough

Source for presentation delivered at DevNexus in March 2012
7
star
20

spring-sockjs-protocol-webapp

A Web Application using Spring Framework 4 snapshots to use with SockJS protocol tests
Java
6
star
21

springx2013-websocket

Presentations for Spring eXchange 2013
CSS
5
star
22

rstoyanchev.github.com

Published content for GitHub Pages (http://pages.github.com)
JavaScript
4
star
23

s2gx2013-intro-websocket-spring-framework-4

Intro To WebSocket Applications with Spring Framework 4.0 (SpringOne2GX Presentation Source)
JavaScript
4
star
24

http2-test

Java
3
star
25

spring-mvc-31-indepth

Source for presentation delivered at DevNexus in March 2012
3
star
26

spring-mvc-intro

Basic intro of HTML-based apps with Spring Boot
Shell
2
star
27

sandbox-rfc7807

Sandbox for RFC 7807 Support
Java
2
star
28

dispatch-test-spring-mvc

Java
2
star
29

jmeter-spring5-example

Java
1
star
30

dispatch-test

A simple project based on discussion at http://java.net/projects/servlet-spec/lists/users/archive/2012-05/message/10
Java
1
star
31

spring-payment

Copy of spring-payment project source
Java
1
star
32

graphql-context-sample

Java
1
star
33

spr16246

Shell
1
star