restlet 在实现web service 时相对简单,一个jar程序就可以发布服务。在我的毕设中的web service 程序就是使用 restlet 来发布的。 restlet默认的支持的线程最大响应数貌似只有20。发了一天的时间才找到如何设置默认的请求响应数。
在使用 50个线程并发运行时,抛出错误的类在 BaseHelper,源码中有描述:
/**
* Base connector helper. Here is the list of parameters that are supported.
* They should be set in the connector's context before it is started:
*
*
* Parameter name
* Value type
* Default value
* Description
*
*
* controllerDaemon
* boolean
* true
* Indicates if the controller thread should be a daemon (not blocking JVM
* exit).
*
*
* controllerSleepTimeMs
* int
* 100
* Time for the controller thread to sleep between each control.
*
*
* inboundBufferSize
* int
* {@link IoUtils#BUFFER_SIZE}
* The size of the buffer when reading messages.
*
*
* minThreads
* int
* 1
* Minimum threads waiting to service requests.
*
*
* maxThreads
* int
* 10
* Maximum threads that will service requests.
*
*
* maxConnectionsPerHost
* int
* -1
* Maximum number of concurrent connections per host (IP address).
*
*
* maxTotalConnections
* int
* -1
* Maximum number of concurrent connections in total.
*
*
* outboundBufferSize
* int
* {@link IoUtils#BUFFER_SIZE}
* The size of the buffer when writing messages.
*
*
* persistingConnections
* boolean
* true
* Indicates if connections should be kept alive after a call.
*
*
* pipeliningConnections
* boolean
* false
* Indicates if pipelining connections are supported.
*
*
* threadMaxIdleTimeMs
* int
* 60000
* Time for an idle thread to wait for an operation before being collected.
*
*
* tracing
* boolean
* false
* Indicates if all messages should be printed on the standard console.
*
*
*
* @author Jerome Louvel
*/
这是设置component 响应性能的根本,就是要在创建connector时设置context
在restlet中 Server 对象继承connector 对象并与component关联。因此设置 连接数的代码如下:
try {
Component component = new Component();
Context context = new Context();
context.getParameters().set("maxThreads", "100");
context.getParameters().set("maxConnectionsPerHost", "100");
context.getParameters().set("maxTotalConnections", "100");
Server server = new Server(context,Protocol.HTTP, 8182);
component.getServers().add(server);
ApplicationController application = new ApplicationController();
component.getDefaultHost().attachDefault(application);
component.start();
} catch (Exception e) {
e.printStackTrace();
}
分享到:
相关推荐
restlet相关文档
RESTLET开发实例(二)使用Component、Application的REST服务
用户在安装了Restlet Client之后,直接点击插件图标即可开始使用,只需输入自己的网站并选择好对应的请求模式就能对网站发送Web请求并检查响应,同时使用者可以先将多个API请求组合成一个方案来创建一个针对网站的...
org.restlet.jar
restlet项目
Restlet与Spring 集成
一个简单的Restlet开发框架的Basic认证的例子
restlet2.1学习笔记项目代码
Restlet所需要的所有jar包 一次下载,以后高枕无忧!
restlet入门helloworld示例
本文是对Restlet官方教程http://restlet.com/learn/tutorial/2.2/的中文翻译。
RESTLET框架学习书籍
Restlet2.0用户指南
restlet restful,web工程,可直接运行。启动后,main方法作为client运行调用服务端。服务器数据之间沟通利器,绝对不坑。
Restlet Client 插件是一个类似Postman的Api接口测试工具, 界面友好, UI布局也更合理。相比Postman, Restlet Client无需安装本地客户端, 即装即用, 占用空间小, 功能强大。
资源里面包含了Restlet从入门到高级的开发过程,对学习Restlet有很大的帮助
restlet工程示例,restlet工程小例子
RESTLET开发实例(一)基于JAX-RS的REST服务
Restlet项目为“建立REST概念与Java类之间的映射”提供了一个轻量级而全面的框架。它可用于实现任何种类的REST式系统,而不仅仅是REST式Web服务;而且,事实证明它自从2005年诞生之时起,就是一个可靠的软件。 ...