Websocket Component

As of Camel 2.10, the Websocket component supports SSL/TLS configuration through the Camel JSSE Configuration Utility. So to use wss:// protocol, the SSLContextParameters must be defined:
<to uri="websocket://0.0.0.0:8443/notification?sslContextParameters=#sslContextParameters&amp;sendToAll=true"/>
<camel:sslContextParameters id="sslContextParameters">
    <camel:keyManagers keyPassword="666666">
      <camel:keyStore resource="{{keystore.url}}" password="{{keystore.pwd}}" type="{{keystore.type}}"/>
    </camel:keyManagers>
    <camel:trustManagers>
      <camel:keyStore resource="{{keystore.url}}" password="{{keystore.pwd}}" type="{{keystore.type}}"/>
    </camel:trustManagers>
</camel:sslContextParameters>
There is a built-in default keystore implementation type known as "jks" that is provided by Sun Microsystems. There are two other types of keystores that come with the Sun JDK implementation: jceks, pkcs12.
// properties
websocket.url=0.0.0.0:8443
keystore.url=file:c:/demo/key.jceks
keystore.pwd=666666
keystore.type=jceks

Configuring in Spring XML

<bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
  <property name="location" value="file:C:/demo/etc/settings.cfg"/>
</bean>
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
     … 
     <to uri="websocket://{{websocket.url}}/notification?sslContextParameters=#sslContextParameters&amp;sendToAll=true"/>
     …
</camel:camelContext>
Note: Using the <propertyPlaceholder> tag in camelContext makes the configuration a bit more fresh such as: <propertyPlaceholder id="properties" location="file:C:/demo/etc/settings.cfg"/>

Configuring in Blueprint

When using Blueprint property placeholder in the Blueprint XML file, you can declare the properties in a .properties or .cfg file. If you use Apache ServieMix / Karaf then this container has a convention that it loads the properties from a file in the etc directory with the naming etc/pid.cfg, where pid is the persistence-id.
<!-- OSGI blueprint property placeholder -->
<cm:property-placeholder id="my.placeholder" persistent-id="com.example.demo">
    <!-- list some properties for this test -->
    <cm:default-properties>
        <cm:property name="result" value="mock:result"/>
    </cm:default-properties>
</cm:property-placeholder>

Reference

http://camel.apache.org/websocket.html

http://docs.oracle.com/javase/6/docs/technotes/guides/security/StandardNames.html

http://camel.apache.org/using-propertyplaceholder.html

 

作者:Hans.Hu
出处:http://huyh.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

时间: 2024-08-15 12:29:18

Websocket Component的相关文章

java使用websocket,并且获取HttpSession,源码分析

一:本文使用范围 此文不仅仅局限于spring boot,普通的spring工程,甚至是servlet工程,都是一样的,只不过配置一些监听器的方法不同而已. 本文经过作者实践,确认完美运行. 二:Spring boot使用websocket 2.1:依赖包 websocket本身是servlet容器所提供的服务,所以需要在web容器中运行,像我们所使用的tomcat,当然,spring boot中已经内嵌了tomcat. websocket遵循了javaee规范,所以需要引入javaee的包 <

spring boot Websocket(使用笔记)

本文只作为个人笔记,大部分代码是引用其他人的文章的. 在springboot项目中使用websocket做推送,虽然挺简单的,但初学也踩过几个坑,特此记录. 使用websocket有两种方式:1是使用sockjs,2是使用h5的标准.使用Html5标准自然更方便简单,所以记录的是配合h5的使用方法. 1.pom 核心是@ServerEndpoint这个注解.这个注解是Javaee标准里的注解,tomcat7以上已经对其进行了实现,如果是用传统方法使用tomcat发布项目,只要在pom文件中引入j

springboot+websocket 归纳收集

websocket是h5后的技术,主要实现是一个长连接跟tomcat的comet技术差不多,但websocket是基于web协议的,有更广泛的支持.当然,在处理高并发的情况下,可以结合tomcat的asyncContext来实现长处理的异步返回等操作. 1.引入依赖类 <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <vers

微服务-springboot+websocket在线聊天室

一.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> </dependency> 二.注入ServerEndpointExporter 编写一个WebSocketConfig配置类,注入对象ServerEndpointExporter, 这个bean会自

springboot整合websocket实现客户端与服务端通信

定义 ?WebSocket是通过单个TCP连接提供全双工(双向通信)通信信道的计算机通信协议.此WebSocket API可在用户的浏览器和服务器之间进行双向通信.用户可以向服务器发送消息并接收事件驱动的响应,而无需轮询服务器. 它可以让多个用户连接到同一个实时服务器,并通过API进行通信并立即获得响应. 案例介绍 ? 后端在接收到用户新下的订单后,通知到后台系统 服务端代码 pom.xml <dependency> <groupId>org.springframework.boo

WebSocket技术demo

使用springboot快速搭建测试案例 <!-- 导入websocket --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket</artifactId> <version>1.3.5.RELEASE</version> </dependency>

SpringBoot 整合websocket

1.MyWebSocket package org.hxm.webSocket; import java.io.IOException; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.atomic.AtomicInteger; import javax.websocket.OnClose; import javax.websocket.OnError; import javax.webso

Spring Websocket配置

实现的版本jdk1.7.0_25, tomcat7.0.47.0, Tengine/2.1.1 (nginx/1.6.2), servlet3.0, spring4.2.2 使用maven导入版本3.0+的servlet包: <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>3.0-alpha-1<

Spring之WebSocket网页聊天以及服务器推送

Spring之WebSocket网页聊天以及服务器推送 转自:http://www.xdemo.org/spring-websocket-comet/ /Springframework /Spring之WebSocket网页聊天以及服务器推送 1. WebSocket protocol 是HTML5一种新的协议.它实现了浏览器与服务器全双工通信(full-duplex). 2. 轮询是在特定的的时间间隔(如每1秒),由浏览器对服务器发出HTTP request,然后由服务器返回最新的数据给客服端