百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

spring-websocket-portfolio

> 编程语言
开源

概述 一个示例,展示了 Spring 框架在构建 WebSocket 类型的消息应用程序方面的功能。该应用程序使用 …

758 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

概述 一个示例,展示了 Spring 框架在构建 WebSocket 类型的消息应用程序方面的功能。该应用程序使用 …

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:

  • stomp-websocket
  • sockjs-client
  • Twitter Bootstrap
  • Knockout.js

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

Jetty

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

Open a browser and go to

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

WebSphere Liberty 16+

Build and deploy with the following server configuration:

        jsp-2.3
        webSocket-1.1

Glassfish

After unzipping Glassfish 4 start the server:

/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

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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言