Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
e7d9c26a
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e7d9c26a
编写于
6月 27, 2013
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make STOMP message broker host and port configurable
上级
ee9c46ad
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
76 addition
and
9 deletion
+76
-9
spring-websocket/src/main/java/org/springframework/web/messaging/stomp/support/StompRelayPubSubMessageHandler.java
...ssaging/stomp/support/StompRelayPubSubMessageHandler.java
+76
-9
未找到文件。
spring-websocket/src/main/java/org/springframework/web/messaging/stomp/support/StompRelayPubSubMessageHandler.java
浏览文件 @
e7d9c26a
...
...
@@ -54,13 +54,21 @@ import reactor.tcp.netty.NettyTcpClient;
* @author Rossen Stoyanchev
* @since 4.0
*/
public
class
StompRelayPubSubMessageHandler
extends
AbstractPubSubMessageHandler
implements
SmartLifecycle
{
public
class
StompRelayPubSubMessageHandler
extends
AbstractPubSubMessageHandler
implements
SmartLifecycle
{
private
static
final
String
STOMP_RELAY_SYSTEM_SESSION_ID
=
"stompRelaySystemSessionId"
;
private
MessageChannel
clientChannel
;
private
String
relayHost
=
"127.0.0.1"
;
private
int
relayPort
=
61613
;
private
String
systemLogin
=
"guest"
;
private
String
systemPasscode
=
"guest"
;
private
final
StompMessageConverter
stompMessageConverter
=
new
StompMessageConverter
();
private
MessageConverter
payloadConverter
;
...
...
@@ -83,6 +91,67 @@ public class StompRelayPubSubMessageHandler extends AbstractPubSubMessageHandler
this
.
payloadConverter
=
new
CompositeMessageConverter
(
null
);
}
/**
* Set the STOMP message broker host.
*/
public
void
setRelayHost
(
String
relayHost
)
{
Assert
.
hasText
(
relayHost
,
"relayHost must not be empty"
);
this
.
relayHost
=
relayHost
;
}
/**
* @return the STOMP message broker host.
*/
public
String
getRelayHost
()
{
return
this
.
relayHost
;
}
/**
* Set the STOMP message broker port.
*/
public
void
setRelayPort
(
int
relayPort
)
{
this
.
relayPort
=
relayPort
;
}
/**
* @return the STOMP message broker port.
*/
public
int
getRelayPort
()
{
return
this
.
relayPort
;
}
/**
* Set the login for a "system" TCP connection used to send messages to the STOMP
* broker without having a client session (e.g. REST/HTTP request handling method).
*/
public
void
setSystemLogin
(
String
systemLogin
)
{
Assert
.
hasText
(
systemLogin
,
"systemLogin must not be empty"
);
this
.
systemLogin
=
systemLogin
;
}
/**
* @return the login for a shared, "system" connection to the STOMP message broker.
*/
public
String
getSystemLogin
()
{
return
this
.
systemLogin
;
}
/**
* Set the passcode for a "system" TCP connection used to send messages to the STOMP
* broker without having a client session (e.g. REST/HTTP request handling method).
*/
public
void
setSystemPasscode
(
String
systemPasscode
)
{
this
.
systemPasscode
=
systemPasscode
;
}
/**
* @return the passcode for a shared, "system" connection to the STOMP message broker.
*/
public
String
getSystemPasscode
()
{
return
this
.
systemPasscode
;
}
public
void
setMessageConverters
(
List
<
MessageConverter
>
converters
)
{
this
.
payloadConverter
=
new
CompositeMessageConverter
(
converters
);
}
...
...
@@ -113,19 +182,17 @@ public class StompRelayPubSubMessageHandler extends AbstractPubSubMessageHandler
public
void
start
()
{
synchronized
(
this
.
lifecycleMonitor
)
{
// TODO: make this configurable
this
.
tcpClient
=
new
TcpClient
.
Spec
<
String
,
String
>(
NettyTcpClient
.
class
)
.
using
(
new
Environment
())
.
codec
(
new
DelimitedCodec
<
String
,
String
>((
byte
)
0
,
true
,
StandardCodecs
.
STRING_CODEC
))
.
connect
(
"127.0.0.1"
,
61616
)
.
connect
(
this
.
relayHost
,
this
.
relayPort
)
.
get
();
StompHeaderAccessor
headers
=
StompHeaderAccessor
.
create
(
StompCommand
.
CONNECT
);
headers
.
setAcceptVersion
(
"1.1,1.2"
);
headers
.
setLogin
(
"guest"
);
headers
.
setPasscode
(
"guest"
);
headers
.
setHeartbeat
(
0
,
0
);
headers
.
setLogin
(
this
.
systemLogin
);
headers
.
setPasscode
(
this
.
systemPasscode
);
headers
.
setHeartbeat
(
0
,
0
);
// TODO
Message
<?>
message
=
MessageBuilder
.
withPayload
(
new
byte
[
0
]).
copyHeaders
(
headers
.
toNativeHeaderMap
()).
build
();
...
...
@@ -270,7 +337,7 @@ public class StompRelayPubSubMessageHandler extends AbstractPubSubMessageHandler
readStompFrame
(
stompFrame
);
}
});
stompHeaders
.
setHeartbeat
(
0
,
0
);
// TODO
stompHeaders
.
setHeartbeat
(
0
,
0
);
// TODO
forwardInternal
(
message
,
stompHeaders
,
connection
);
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录