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
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

Websocket Component的更多相关文章

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

    转载请在页首注明作者与出处 http://www.cnblogs.com/zhuxiaojie/p/6238826.html 一:本文使用范围 此文不仅仅局限于spring boot,普通的sprin ...

  2. websocket+rabbitmq实战

    1. websocket+rabbitmq实战 1.1. 前言   接到的需求是后台定向给指定web登录用户推送消息,且可能同一账号会登录多个客户端都要接收到消息 1.2. 遇坑 基于springbo ...

  3. springboot - websocket实现及原理

    本文章包括websocket面试相关问题以及spring boot如何整合webSocket. 参考文档 https://blog.csdn.net/prayallforyou/article/det ...

  4. springboot+websocket 归纳收集

    websocket是h5后的技术,主要实现是一个长连接跟tomcat的comet技术差不多,但websocket是基于web协议的,有更广泛的支持.当然,在处理高并发的情况下,可以结合tomcat的a ...

  5. 使用spring boot +WebSocket实现(后台主动)消息推送

    言:使用此webscoket务必确保生产环境能兼容/支持!使用此webscoket务必确保生产环境能兼容/支持!使用此webscoket务必确保生产环境能兼容/支持!主要是tomcat的兼容与支持. ...

  6. spring boot 下websocket实现的两种方法

    websocket前台实现代码,保存为html执行就好 html代码来自:https://blog.csdn.net/M348915654/article/details/53616837 <h ...

  7. spring boot 使用WebSocket与前端进行byte字节数组交互

    一.装逼前先热热身 无论是比较传统的 web项目 还是近几年流行的前后端分离,后端只独立提供数据交互接口服务的项目,都避免不了数据之间交互格式的选择. 从很早之前的 xml 格式 到现在最火热的jso ...

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

    一.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...

  9. SpringBoot2.0集成WebSocket,实现后台向前端推送信息

    感谢作者,支持原创: https://blog.csdn.net/moshowgame/article/details/80275084 什么是WebSocket? WebSocket协议是基于TCP ...

随机推荐

  1. 关于js闭包的误区

    一直以为js的闭包只是内部函数保存了一份外部函数的变量值副本,但是以下代码打破了我的认识: function createFunctions() { var result = new Array(); ...

  2. Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 64 bytes) in D

    Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 64 bytes) in D 从数据库 ...

  3. Activity之间传递参数(三)

    ------siwuxie095 传递值对象,即自定义的有数据类型的对象 1.首先 new 一个 class:User,用于创建自定义对象,同时右键 Generate 出 Constructor.se ...

  4. 什么是IO流 \ 以及文件输入输出

    一.IO流的分类: 流按照操作数据的类型分为两种:字节流:字符流. 1.什么是字节流:读取的是文件的二进制数据,不会对二进制做处理,不会解析成看得懂的数据. 2.什么是字符流:读取的是文件的二进制数据 ...

  5. 用.net访问电子枢纽信用中心的数据查询服务

    概要说明 电子枢纽全称国家交通运输物流公共信息平台,主要提供物流及生产企业进行物流相关数据交换的标准和API,详细介绍可参考其官网www.logink.org,本文假定阅读者对该平台已有了解,并已成功 ...

  6. 四元数(Quaternions)简介

    经常在代码中看到Quaternions,也知道它是用来表达三维空间的旋转的,但一直没有更深的理解.这两天终于花点时间看了看维基百科的介绍,算是多了解了点.做个记录吧! 本质上而言,四元数是一个数学概念 ...

  7. 淌水 UE4的shootergame 案例 准备

    从毕业到现在,从GIS到游戏. 先记录一下cesium源码研究停止了一个多月了,还是有点放不下,等有机会一定研究透彻.感谢一下法克鸡丝博主. 好,研究了近两个月的游戏整体制作,熟悉了maya\unfl ...

  8. 线段树初步&&lazy标记

    线段树 一.概述: 线段树是一种二叉搜索树,与区间树相似,它将一个区间划分成一些单元区间,每个单元区间对应线段树中的一个叶结点. 对于线段树中的每一个非叶子节点[a,b],它的左儿子表示的区间为[a, ...

  9. 关于启动 SecureCRT 遇到一个致命的错误且必须关闭

    --------------------------SecureCRT---------------------------SecureCRT 遇到一个致命的错误且必须关闭. 一个崩溃转储文件已创建于 ...

  10. Http协议的常见参数

    Requests部分 Header 解释 示例 Accept 指定客户端能够接收的内容类型 Accept: text/plain, text/html Accept-Charset 浏览器可以接受的字 ...