- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章详解spring集成mina实现服务端主动推送(包含心跳检测)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
本文介绍了spring集成mina实现服务端主动推送(包含心跳检测),分享给大家,具体如下:
服务端 。
1.常规的spring工程集成mina时,pom.xml中需要加入如下配置:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<
dependency
>
<
groupId
>org.slf4j</
groupId
>
<
artifactId
>slf4j-jdk14</
artifactId
>
<
version
>1.7.7</
version
>
</
dependency
>
<
dependency
>
<
groupId
>org.apache.mina</
groupId
>
<
artifactId
>mina-integration-beans</
artifactId
>
<
version
>2.0.13</
version
>
</
dependency
>
<
dependency
>
<
groupId
>org.apache.mina</
groupId
>
<
artifactId
>mina-core</
artifactId
>
<
version
>2.0.13</
version
>
<
type
>bundle</
type
>
<
scope
>compile</
scope
>
</
dependency
>
<
dependency
>
<
groupId
>org.apache.mina</
groupId
>
<
artifactId
>mina-integration-spring</
artifactId
>
<
version
>1.1.7</
version
>
</
dependency
>
|
注意此处mina-core的配置写法。如果工程中引入上述依赖之后报错:Missing artifact xxx bundle,则需要在pom.xml的plugins之间加入如下插件配置:
1
2
3
4
5
|
<
plugin
>
<
groupId
>org.apache.felix</
groupId
>
<
artifactId
>maven-bundle-plugin</
artifactId
>
<
extensions
>true</
extensions
>
</
plugin
>
|
2.Filter1:编解码器,实现ProtocolCodecFactory解码工厂 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package
com.he.server;
import
java.nio.charset.Charset;
import
org.apache.mina.core.session.IoSession;
import
org.apache.mina.filter.codec.ProtocolCodecFactory;
import
org.apache.mina.filter.codec.ProtocolDecoder;
import
org.apache.mina.filter.codec.ProtocolEncoder;
import
org.apache.mina.filter.codec.textline.LineDelimiter;
import
org.apache.mina.filter.codec.textline.TextLineDecoder;
import
org.apache.mina.filter.codec.textline.TextLineEncoder;
public
class
MyCodeFactory
implements
ProtocolCodecFactory {
private
final
TextLineEncoder encoder;
private
final
TextLineDecoder decoder;
public
MyCodeFactory() {
this
(Charset.forName(
"utf-8"
));
}
public
MyCodeFactory(Charset charset) {
encoder =
new
TextLineEncoder(charset, LineDelimiter.UNIX);
decoder =
new
TextLineDecoder(charset, LineDelimiter.AUTO);
}
public
ProtocolDecoder getDecoder(IoSession arg0)
throws
Exception {
// TODO Auto-generated method stub
return
decoder;
}
public
ProtocolEncoder getEncoder(IoSession arg0)
throws
Exception {
// TODO Auto-generated method stub
return
encoder;
}
public
int
getEncoderMaxLineLength() {
return
encoder.getMaxLineLength();
}
public
void
setEncoderMaxLineLength(
int
maxLineLength) {
encoder.setMaxLineLength(maxLineLength);
}
public
int
getDecoderMaxLineLength() {
return
decoder.getMaxLineLength();
}
public
void
setDecoderMaxLineLength(
int
maxLineLength) {
decoder.setMaxLineLength(maxLineLength);
}
}
|
此处使用了mina自带的TextLineEncoder编解码器,此解码器支持使用固定长度或者固定分隔符来区分上下两条消息。如果要使用自定义协议,则需要自己编写解码器。要使用websocket,也需要重新编写解码器,关于mina结合websocket,jira上有一个开源项目https://issues.apache.org/jira/browse/DIRMINA-907,专门为mina编写了支持websocket的编解码器,亲测可用。。。此部分不是本文重点,略.
3.Filter2:心跳工厂,加入心跳检测功能需要实现KeepAliveMessageFactory:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package
com.he.server;
import
org.apache.log4j.Logger;
import
org.apache.mina.core.session.IoSession;
import
org.apache.mina.filter.keepalive.KeepAliveMessageFactory;
public
class
MyKeepAliveMessageFactory
implements
KeepAliveMessageFactory{
private
final
Logger LOG = Logger.getLogger(MyKeepAliveMessageFactory.
class
);
/** 心跳包内容 */
private
static
final
String HEARTBEATREQUEST =
"1111"
;
private
static
final
String HEARTBEATRESPONSE =
"1112"
;
public
Object getRequest(IoSession session) {
LOG.warn(
"请求预设信息: "
+ HEARTBEATREQUEST);
return
HEARTBEATREQUEST;
}
public
Object getResponse(IoSession session, Object request) {
LOG.warn(
"响应预设信息: "
+ HEARTBEATRESPONSE);
/** 返回预设语句 */
return
HEARTBEATRESPONSE;
}
public
boolean
isRequest(IoSession session, Object message) {
LOG.warn(
"请求心跳包信息: "
+ message);
if
(message.equals(HEARTBEATREQUEST))
return
true
;
return
false
;
}
public
boolean
isResponse(IoSession session, Object message) {
LOG.warn(
"响应心跳包信息: "
+ message);
if
(message.equals(HEARTBEATRESPONSE))
return
true
;
return
false
;
}
}
|
此处我设置服务端发送的心跳包是1111,客户端应该返回1112. 。
4.实现必不可少的IoHandlerAdapter,得到监听事件处理权:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package
com.he.server;
import
java.net.InetSocketAddress;
import
java.util.Collections;
import
java.util.HashSet;
import
java.util.Set;
import
java.util.concurrent.ConcurrentHashMap;
import
org.apache.log4j.Logger;
import
org.apache.mina.core.service.IoHandlerAdapter;
import
org.apache.mina.core.session.IdleStatus;
import
org.apache.mina.core.session.IoSession;
public
class
MyHandler
extends
IoHandlerAdapter {
//private final int IDLE = 3000;//(单位s)
private
final
Logger LOG = Logger.getLogger(MyHandler.
class
);
// public static Set<IoSession> sessions = Collections.synchronizedSet(new HashSet<IoSession>());
public
static
ConcurrentHashMap<Long, IoSession> sessionsConcurrentHashMap =
new
ConcurrentHashMap<Long, IoSession>();
@Override
public
void
exceptionCaught(IoSession session, Throwable cause)
throws
Exception {
session.closeOnFlush();
LOG.warn(
"session occured exception, so close it."
+ cause.getMessage());
}
@Override
public
void
messageReceived(IoSession session, Object message)
throws
Exception {
String str = message.toString();
LOG.warn(
"客户端"
+ ((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress() +
"连接成功!"
);
session.setAttribute(
"type"
, message);
String remoteAddress = ((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress();
session.setAttribute(
"ip"
, remoteAddress);
LOG.warn(
"服务器收到的消息是:"
+ str);
session.write(
"welcome by he"
);
}
@Override
public
void
messageSent(IoSession session, Object message)
throws
Exception {
LOG.warn(
"messageSent:"
+ message);
}
@Override
public
void
sessionCreated(IoSession session)
throws
Exception {
LOG.warn(
"remote client ["
+ session.getRemoteAddress().toString() +
"] connected."
);
// my
Long time = System.currentTimeMillis();
session.setAttribute(
"id"
, time);
sessionsConcurrentHashMap.put(time, session);
}
@Override
public
void
sessionClosed(IoSession session)
throws
Exception {
LOG.warn(
"sessionClosed."
);
session.closeOnFlush();
// my
sessionsConcurrentHashMap.remove(session.getAttribute(
"id"
));
}
@Override
public
void
sessionIdle(IoSession session, IdleStatus status)
throws
Exception {
LOG.warn(
"session idle, so disconnecting......"
);
session.closeOnFlush();
LOG.warn(
"disconnected."
);
}
@Override
public
void
sessionOpened(IoSession session)
throws
Exception {
LOG.warn(
"sessionOpened."
);
//
//session.getConfig().setIdleTime(IdleStatus.BOTH_IDLE, IDLE);
}
}
|
此处有几点说明:
第一点:网上教程会在此处(sessionOpened()方法中)设置IDLE,IDLE表示session经过多久判定为空闲的时间,单位s,上述代码中已经注释掉了,因为后面在spring配置中加入心跳检测部分时会进行IDLE的配置,已经不需要在此处进行配置了,而且如果在心跳配置部分和此处都对BOTH_IDLE模式设置了空闲时间,亲测发现此处配置不生效.
第二点:关于存放session的容器,建议使用 。
。
。
。
而不是用已经注释掉的Collections.synchronizedSet类型的set或者map,至于原因,java5中新增了ConcurrentMap接口和它的一个实现类ConcurrentHashMap,可以保证线程的足够安全。详细的知识你应该搜索SynchronizedMap和ConcurrentHashMap的区别,学习更加多的并发安全知识.
上述代码中,每次在收到客户端的消息时,我会返回一段文本:welcome by he.
有了map,主动推送就不是问题了,想推给谁,在map中找到谁就可以了.
5.完成spring的配置工作 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
beans
xmlns
=
"http://www.springframework.org/schema/beans"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:p
=
"http://www.springframework.org/schema/p"
xsi:schemaLocation
=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
<
bean
class
=
"org.springframework.beans.factory.config.CustomEditorConfigurer"
>
<
property
name
=
"customEditors"
>
<
map
>
<
entry
key
=
"java.net.SocketAddress"
value
=
"org.apache.mina.integration.beans.InetSocketAddressEditor"
>
</
entry
>
</
map
>
</
property
>
</
bean
>
<
bean
id
=
"ioAcceptor"
class
=
"org.apache.mina.transport.socket.nio.NioSocketAcceptor"
init-method
=
"bind"
destroy-method
=
"unbind"
>
<!--端口号-->
<
property
name
=
"defaultLocalAddress"
value
=
":8888"
/>
<!--绑定自己实现的handler-->
<
property
name
=
"handler"
ref
=
"serverHandler"
/>
<!--声明过滤器的集合-->
<
property
name
=
"filterChainBuilder"
ref
=
"filterChainBuilder"
/>
<
property
name
=
"reuseAddress"
value
=
"true"
/>
</
bean
>
<
bean
id
=
"filterChainBuilder"
class
=
"org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder"
>
<
property
name
=
"filters"
>
<
map
>
<!--mina自带的线程池filter-->
<
entry
key
=
"executor"
value-ref
=
"executorFilter"
/>
<
entry
key
=
"mdcInjectionFilter"
value-ref
=
"mdcInjectionFilter"
/>
<!--自己实现的编解码器filter-->
<
entry
key
=
"codecFilter"
value-ref
=
"codecFilter"
/>
<!--日志的filter-->
<
entry
key
=
"loggingFilter"
value-ref
=
"loggingFilter"
/>
<!--心跳filter-->
<
entry
key
=
"keepAliveFilter"
value-ref
=
"keepAliveFilter"
/>
</
map
>
</
property
>
</
bean
>
<!-- executorFilter多线程处理 -->
<
bean
id
=
"executorFilter"
class
=
"org.apache.mina.filter.executor.ExecutorFilter"
/>
<
bean
id
=
"mdcInjectionFilter"
class
=
"org.apache.mina.filter.logging.MdcInjectionFilter"
>
<
constructor-arg
value
=
"remoteAddress"
/>
</
bean
>
<!--日志-->
<
bean
id
=
"loggingFilter"
class
=
"org.apache.mina.filter.logging.LoggingFilter"
/>
<!--编解码-->
<
bean
id
=
"codecFilter"
class
=
"org.apache.mina.filter.codec.ProtocolCodecFilter"
>
<
constructor-arg
>
<!--构造函数的参数传入自己实现的对象-->
<
bean
class
=
"com.he.server.MyCodeFactory"
></
bean
>
</
constructor-arg
>
</
bean
>
<!--心跳检测filter-->
<
bean
id
=
"keepAliveFilter"
class
=
"org.apache.mina.filter.keepalive.KeepAliveFilter"
>
<!--构造函数的第一个参数传入自己实现的工厂-->
<
constructor-arg
>
<
bean
class
=
"com.he.server.MyKeepAliveMessageFactory"
></
bean
>
</
constructor-arg
>
<!--第二个参数需要的是IdleStatus对象,value值设置为读写空闲-->
<
constructor-arg
type
=
"org.apache.mina.core.session.IdleStatus"
value
=
"BOTH_IDLE"
>
</
constructor-arg
>
<!--心跳频率,不设置则默认60s -->
<
property
name
=
"requestInterval"
value
=
"5"
/>
<!--心跳超时时间,不设置则默认30s -->
<
property
name
=
"requestTimeout"
value
=
"10"
/>
<!--不设置默认false-->
<
property
name
=
"forwardEvent"
value
=
"true"
/>
</
bean
>
<!--自己实现的handler-->
<
bean
id
=
"serverHandler"
class
=
"com.he.server.MyHandler"
/>
</
beans
>
|
好了,xml中已经写了足够多的注释了。说明一下关于心跳检测中的最后一个属性:forwardEvent,默认false,比如在心跳频率为5s时,实际上每5s会触发一次KeepAliveFilter中的session_idle事件,该事件中开始发送心跳包。当此参数设置为false时,对于session_idle事件不再传递给其他filter,如果设置为true,则会传递给其他filter,例如handler中的session_idle事件,此时也会被触发。另外IdleStatus一共有三个值,点击进源码就能看到.
6.写main方法启动服务端 。
1
2
3
4
5
6
7
8
|
package
com.he.server;
import
org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicationContext;
public
class
MainTest {
public
static
void
main(String[] args) {
ClassPathXmlApplicationContext ct =
new
ClassPathXmlApplicationContext(
"applicationContext.xml"
);
}
}
|
run之后,端口就已经开始监听了。此处,如果是web工程,使用tomcat之类的容器,只要在web.xml中配置了 。
1
2
3
4
5
6
7
8
|
<
context-param
>
<
param-name
>contextConfigLocation</
param-name
>
<
param-value
>/WEB-INF/classes/applicationContext.xml</
param-value
>
</
context-param
>
<
listener
>
<
listener-class
>org.springframework.web.context.ContextLoaderListener</
listener-class
>
</
listener
>
|
则容器在启动时就会加载spring的配置文件,端口的监听就开始了,这样就不需要main方法来启动.
客户端,本文采用两种方式来实现客户端 。
方式一:用mina结构来实现客户端,引入mina相关jar包即可,Android也可以使用 。
1.先实现IoHandlerAdater得到监听事件,类似于服务端:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package
com.he.client.minaclient;
import
org.apache.log4j.Logger;
import
org.apache.mina.core.service.IoHandlerAdapter;
import
org.apache.mina.core.session.IdleStatus;
import
org.apache.mina.core.session.IoSession;
public
class
ClientHandler
extends
IoHandlerAdapter{
private
final
Logger LOG = Logger.getLogger(ClientHandler.
class
);
@Override
public
void
messageReceived(IoSession session, Object message)
throws
Exception {
// TODO Auto-generated method stub
LOG.warn(
"客户端收到消息:"
+ message);
if
(message.toString().equals(
"1111"
)) {
//收到心跳包
LOG.warn(
"收到心跳包"
);
session.write(
"1112"
);
}
}
@Override
public
void
messageSent(IoSession session, Object message)
throws
Exception {
// TODO Auto-generated method stub
super
.messageSent(session, message);
}
@Override
public
void
sessionClosed(IoSession session)
throws
Exception {
// TODO Auto-generated method stub
super
.sessionClosed(session);
}
@Override
public
void
sessionCreated(IoSession session)
throws
Exception {
// TODO Auto-generated method stub
super
.sessionCreated(session);
}
@Override
public
void
sessionIdle(IoSession session, IdleStatus status)
throws
Exception {
// TODO Auto-generated method stub
super
.sessionIdle(session, status);
}
@Override
public
void
sessionOpened(IoSession session)
throws
Exception {
// TODO Auto-generated method stub
super
.sessionOpened(session);
}
}
|
2.写main方法启动客户端,连接服务端:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package
com.he.client.minaclient;
import
java.net.InetSocketAddress;
import
java.nio.charset.Charset;
import
org.apache.mina.core.future.ConnectFuture;
import
org.apache.mina.filter.codec.ProtocolCodecFilter;
import
org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import
org.apache.mina.filter.logging.LoggingFilter;
import
org.apache.mina.transport.socket.nio.NioSocketConnector;
public
class
ClientTest {
public
static
void
main(String[] args)
throws
InterruptedException {
//创建客户端连接器.
NioSocketConnector connector =
new
NioSocketConnector();
connector.getFilterChain().addLast(
"logger"
,
new
LoggingFilter());
connector.getFilterChain().addLast(
"codec"
,
new
ProtocolCodecFilter(
new
TextLineCodecFactory(Charset.forName(
"utf-8"
))));
//设置编码过滤器
connector.setHandler(
new
ClientHandler());
//设置事件处理器
ConnectFuture cf = connector.connect(
new
InetSocketAddress(
"127.0.0.1"
,
8888
));
//建立连接
cf.awaitUninterruptibly();
//等待连接创建完成
cf.getSession().write(
"hello,测试!"
);
//发送消息,中英文都有
//cf.getSession().closeOnFlush();
//cf.getSession().getCloseFuture().awaitUninterruptibly();//等待连接断开
//connector.dispose();
}
}
|
过程也是一样的,加各种filter,绑定handler。上述代码运行之后向服务器发送了:“hello,测试”,并且收到返回值:welcome by he。然后每隔5s,就会收到服务端的心跳包:1111。在handler的messageReceived中,确认收到心跳包之后返回1112,实现心跳应答。以上过程,每5s重复一次.
main方法中最后三行注释掉的代码如果打开,客户端在发送完消息之后会主动断开.
方式二:客户端不借助于mina,换用java的普通socket来实现,这样就可以换成其他任何语言:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package
com.he.client;
import
java.io.DataInputStream;
import
java.io.IOException;
import
java.io.PrintWriter;
import
java.net.Socket;
/**
*@function:java的简单socket连接,长连接,尝试连续从服务器获取消息
*@parameter:
*@return:
*@date:2016-6-22 下午03:43:18
*@author:he
*@notice:
*/
public
class
SocketTestTwo {
public
static
final
String IP_ADDR =
"127.0.0.1"
;
// 服务器地址
public
static
final
int
PORT =
8888
;
// 服务器端口号
static
String text =
null
;
public
static
void
main(String[] args)
throws
IOException {
System.out.println(
"客户端启动..."
);
Socket socket =
null
;
socket =
new
Socket(IP_ADDR, PORT);
PrintWriter os =
new
PrintWriter(socket.getOutputStream());
os.println(
"al"
);
os.println(
"two"
);
os.flush();
while
(
true
) {
try
{
// 创建一个流套接字并将其连接到指定主机上的指定端口号
DataInputStream input =
new
DataInputStream(socket.getInputStream());
// 读取服务器端数据
byte
[] buffer;
buffer =
new
byte
[input.available()];
if
(buffer.length !=
0
) {
System.out.println(
"length="
+ buffer.length);
// 读取缓冲区
input.read(buffer);
// 转换字符串
String three =
new
String(buffer);
System.out.println(
"内容="
+ three);
if
(three.equals(
"1111\n"
)) {
System.out.println(
"发送返回心跳包"
);
os =
new
PrintWriter(socket.getOutputStream());
os.println(
"1112"
);
os.flush();
}
}
}
catch
(Exception e) {
System.out.println(
"客户端异常:"
+ e.getMessage());
os.close();
}
}
}
}
|
以上代码运行效果和前一种方式完全一样.
但是注意此种方法和使用mina结构的客户端中有一处不同:对于心跳包的判断。本教程中服务端选用了mina自带的编解码器,通过换行符来区分上下两条消息,也就是每一条消息后面会带上一个换行符,所以在使用java普通的socket来连接时,判断心跳包不再是判断是否为“1111”,而是“1111\n”。对比mina结构的客户端中并不需要加上换行符是因为客户端中绑定了相同的编解码器.
程序运行结果截图:
服务端:
客户端:
红色的打印是mina自带的打印信息,黑色的是本工程中使用的log4j打印,所以你们的工程应该配置有如下log4j的配置文件才能看到一样的打印结果:
1
2
3
4
5
6
|
log4j.rootLogger=WARN,stdout
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.Threshold=WARN
log4j.appender.stdout.layout.ConversionPattern = [%-5p] [%d{yyyy-MM-dd HH\:mm\:ss,SSS}] [%x] %c %l - %m%n
|
应大家需求,工程代码终于抽空放到github了! https://github.com/smile326/minaSpring 。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
原文链接:http://blog.csdn.net/smile326/article/details/51912141 。
最后此篇关于详解spring集成mina实现服务端主动推送(包含心跳检测)的文章就讲到这里了,如果你想了解更多关于详解spring集成mina实现服务端主动推送(包含心跳检测)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我有一个数组列表。 ArrayList arrayList = new ArrayList<>(); arrayList.add("timestamp"); arrayList.add("Code")
我想知道如何控制 Navlink 的类名,如果实际路径是 X,则 NavLink 的类是事件的。我在使用 Laravel 和简单的 bootstrap 之前做过它,但我不知道如何用 React 和 R
我的单页网站目前使用箭头键平滑滚动到 anchor 。问题是当您滚动到每个部分时,悬停的链接不会跟随每个部分。它仅遵循您的箭头键命令。我怎样才能改变这个?这是当前网站 ( http://www.jon
我们有一个主动/被动拓扑,其中有两个具有共享原始存储的 x86 复合体,其中在给定时刻只有一个节点可以访问共享存储(也称为主动节点)。如果主动节点发生故障转移,被动节点将启动接管并成为可以访问共享存储
有源 GPS 会消耗多少电量?没有 gps 导航器软件的开销。秒我想每 2 分钟对 gps 进行一次采样并将其保存到文件中。这将花费我多少电池电量? 我的生命周期会缩短 10% 吗? 20%? ..?
AWS今年针对主动-被动设置(全局数据存储)引入了跨区域复制。这意味着有一个用于读取/写入的主Redis群集和一个用于读取的辅助群集。 就我而言,我们想在不同区域中使用 Active-Active R
我正在使用斯坦福标记器来确定词性。但是,我想从文本中获取更多信息。是否有可能获得更多信息,例如句子的时态或是否处于主动/被动状态? 到目前为止,我使用的是非常基本的 PoS 标记方法: List> t
我尝试将 SSL 与 Active MQ 创建的 JMX 连接器一起使用,但没有成功。我能够让 SSL 与 JVM 平台 JMX 连接器一起工作,但这需要存储 keystore 和信任库密码明文,这对
RFC 1006 TCP 连接中主动连接和被动连接有何区别? 最佳答案 这里有解释:https://www.rfc-editor.org/rfc/rfc793 A passive OPEN reque
在 MarkLogic 7 中,副本是主动-主动还是主动-被动? 最佳答案 您是在询问本地磁盘故障转移(又名林复制)、数据库复制还是灵活复制? 事实上,这三个都是为主动-被动使用而设计的:换句话说,单
我正在使用 Windows Azure 网站和 Web 作业。 我有一个控制台应用程序,用于每晚下载 FTP 文件。他们最近从被动 FTP 切换为主动 FTP。我对此没有任何控制权。 所附代码在我的计
我是 JNDI 和 JMS 技术的初学者。 我的 JNDI 文件为: java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQIn
我使用 Active Android在我的项目中。试图了解更多关于它的信息,特别是关于表项属性的信息 - 类似于 ForeignKeyAction。 如果发生删除操作,我希望我的模型只删除它自己,而不
主-主双活mysql复制如何处理唯一键值。对于主键值,我们可以设置 auto_increment_increment 和 auro_increment_offset 参数以避免主键 auto_incr
我是 Linux 新手,我的应用程序在 Windows 上运行了一段时间,对于文件传输,我们使用第三方 sftp,它在主动和被动模式下都运行良好。 现在我正在迁移我的应用程序以支持 Linux 操作系
我在使用 SymmetricDS(开源版本)在 2 个 Postgres 服务器之间复制数据时遇到问题。以下是了解我的问题的相关信息: 我已经用 Vagrant 部署了 3 个服务器: symmetr
我们可以对 Azure SQL 数据库进行被动只读异步实时同步,以实现灾难恢复。 但我们的要求是在两个事件读写数据库之间实现实时同步,以便为世界不同地点的客户提供低延迟。 例如: I'm provid
我们可以对 Azure SQL 数据库进行被动只读异步实时同步,以实现灾难恢复。 但我们的要求是在两个事件读写数据库之间实现实时同步,以便为世界不同地点的客户提供低延迟。 例如: I'm provid
在我的 TCP 服务器上,我希望有: 非阻塞被动套接字具有非阻塞accept(); 接受连接后,我想执行一些身份验证,例如验证客户端提供的 ID 和密码。所以我有明确定义的协议(protocol),我
我的应用中有 anchor 链接。如果 anchor 链接处于事件状态,如何使事件样式发挥作用。 AnchorLink 最佳答案 对于当前事件链接的样式,您可以为参数 activeClassName
我是一名优秀的程序员,十分优秀!