我在一次采访中遇到了这个问题,你能告诉我SOAP Web服务是否只支持"POST"http方法,还是有一些方法可以接受服务器端的其他方法?
Spring REST Docs最近发布,文档说:
这种方法使您免受Swagger等工具的限制
所以,我想问一下,当Spring REST Docs与Swagger比较时,以及它可以解除的限制.
我想在端口80上启动Tomcat 6.0.29.我的操作系统是CentOS 5.5版(最终版)我更改了$ TOMCAT_HOME/conf/server.xml中的以下行
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
Run Code Online (Sandbox Code Playgroud)
至
<Connector connectionTimeout="20000" port="80" protocol="HTTP/1.1" redirectPort="8443"/>
Run Code Online (Sandbox Code Playgroud)
然后我运行命令:
sudo /etc/init.d/tomcat6 start
Run Code Online (Sandbox Code Playgroud)
在$ TOMCAT_HOME/logs/catalina.log文件中,我发现了以下异常:
java.net.BindException: Permission denied <null>:80
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549)
at org.apache.tomcat.util.net.JIoEndpoint.start(JIoEndpoint.java:565)
at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:203)
at org.apache.catalina.connector.Connector.start(Connector.java:1087)
at org.apache.catalina.core.StandardService.start(StandardService.java:534)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.net.BindException: Permission denied
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
at java.net.ServerSocket.bind(ServerSocket.java:319)
at java.net.ServerSocket.<init>(ServerSocket.java:185)
at java.net.ServerSocket.<init>(ServerSocket.java:141)
at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50)
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538)
... 12 more
0:11:56 org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start: …
Run Code Online (Sandbox Code Playgroud) 我收集了产品.每个产品都包含一系列项目.
> db.products.find().pretty()
{
"_id" : ObjectId("54023e8bcef998273f36041d"),
"shop" : "shop1",
"name" : "product1",
"items" : [
{
"date" : "01.02.2100",
"purchasePrice" : 1,
"sellingPrice" : 10,
"count" : 15
},
{
"date" : "31.08.2014",
"purchasePrice" : 10,
"sellingPrice" : 1,
"count" : 5
}
]
}
Run Code Online (Sandbox Code Playgroud)
那么,请你给我一个建议,如何查询MongoDB以检索所有只有单个项目的产品,其中日期等于我传递给查询作为参数的日期.
"31.08.2014"的结果必须是:
{
"_id" : ObjectId("54023e8bcef998273f36041d"),
"shop" : "shop1",
"name" : "product1",
"items" : [
{
"date" : "31.08.2014",
"purchasePrice" : 10,
"sellingPrice" : 1,
"count" : 5
}
]
}
Run Code Online (Sandbox Code Playgroud) 我有一个封装REST调用的hystrix命令.如果发生故障(例如超时),我想进行单次重试,如果发生故障,则返回适当的错误.
我可以看到Hystrix不支持重试.使用Hystrix的唯一方法是将主逻辑放入getFallback()方法.但它看起来并不正确.
那么,用hystrix实现超时的正确方法是什么?
根据 Prometheus 文档,为了使用直方图指标获得第 95 个百分点,我可以使用以下查询:
histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))
Run Code Online (Sandbox Code Playgroud)
资料来源:https : //prometheus.io/docs/practices/histograms/#quantiles
由于直方图的每个桶都是一个计数器,我们可以计算每个桶的比率为:
范围向量中时间序列的每秒平均增长率。
请参阅:https : //prometheus.io/docs/prometheus/latest/querying/functions/#rate
因此,例如,如果桶值[t-5m] = 100 和桶值[t] = 200,则桶率[t] = (200-100)/(10*60) = 0.167
最后,最令人困惑的部分是 histogram_quantile 函数如何在知道所有桶率的情况下找到给定指标的第 95 个百分位数?
是否有任何代码或算法可以让我更好地理解它?
我想创建一些能够管理队列内消息的工具.所以我希望能够从队列中获取所有消息(类似于导出)并且不要从那里删除它.
我尝试使用JMX API:
ObjectName mbeanNameQueue = new ObjectName("org.apache.activemq:type=Broker,brokerName=static-broker1,destinationType=Queue,destinationName=tmp_queue2");
org.apache.activemq.broker.jmx.QueueViewMBean queueView = JMX.newMBeanProxy(mbsc, mbeanNameQueue, org.apache.activemq.broker.jmx.QueueViewMBean.class);
System.out.println(queueView.browseAsTable());
Run Code Online (Sandbox Code Playgroud)
但我不能得到超过400条消息.
我也用这种方法:
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:55901");
ActiveMQConnection connection = (ActiveMQConnection)connectionFactory.createConnection();
DestinationSource ds = connection.getDestinationSource();
QueueSession queueSession = connection.createQueueSession(true, Session.CLIENT_ACKNOWLEDGE);
Queue queue = queueSession.createQueue("tmp_queue2");
QueueBrowser browser = queueSession.createBrowser(queue);
Enumeration<?> messagesInQueue = browser.getEnumeration();
while (messagesInQueue.hasMoreElements()) {
Message queueMessage = (Message) messagesInQueue.nextElement();
System.out.println(queueMessage);
}
Run Code Online (Sandbox Code Playgroud)
但是尽管队列包含许多消息,messagesInQueue.hasMoreElements()总是返回false.
此外,如果我尝试使用使用者,它会检索所有消息,但会将其从队列中删除.
我尝试使用命令行工具从队列中导出消息:
activemq browse --amqurl tcp://localhost:55901 tmp_queue2 >> messages22222.txt
Run Code Online (Sandbox Code Playgroud)
但是如果队列包含大约1000000条消息则会抛出
Failed to execute main task. Reason: java.lang.OutOfMemoryError: GC overhead limit exceeded
Run Code Online (Sandbox Code Playgroud)
那么,我如何从队列中获取所有消息并且不从那里删除它们?
是否有任何简单的方法可以将 Micrometer 计时器与 Webflux 控制器一起使用?
看来 @Timed 仅适用于非反应式方法。对于反应性来说,它记录的时间值非常低。
我发现了一个类似的问题:How to use Micrometer Timer to recorduration of async method (returns Mono or Flux)但对于这样一个常见问题来说答案太复杂了
有任何想法吗?
我写了一个简单的程序,它无限地将对象加入到集合中,我想看看PrintTenuringDistribution选项的标准输出:
public static void main(String[] args) {
while (true) {
persons.add(new Person("jorik", "kornev"));
}
}
Run Code Online (Sandbox Code Playgroud)
作为一个程序输出我得到:
Desired survivor size 5242880 bytes, new threshold 7 (max 15)
Desired survivor size 5242880 bytes, new threshold 7 (max 15)
Desired survivor size 5242880 bytes, new threshold 7 (max 15)
Run Code Online (Sandbox Code Playgroud)
其实我建议我得到这样的东西:
Desired survivor size 75497472 bytes, new threshold 15 (max 15)
- age 1: 19321624 bytes, 19321624 total
- age 2: 79376 bytes, 19401000 total
- age 3: 2904256 bytes, 22305256 total
Run Code Online (Sandbox Code Playgroud)
我正在使用带有VM选项的JDK 1.7.0_79: …
我正在开发提供REST API的项目.最近,我们决定将其与Swagger集成,为每个端点创建详细的文档.几乎所有的REST都已成功集成,但对于其中一些我们遇到的困难很少.
因此,我们有一个带有"/ users"资源的REST,它默认按照JSON格式的给定标准返回用户列表,例如:
[
{
name: "user1",
age: 50,
group: "group1"
},
{
name: "user2",
age: 30,
group: "group2"
},
{
name: "user3",
age: 20,
group: "group1"
}
]
Run Code Online (Sandbox Code Playgroud)
此REST的要求之一是按" 组 "字段对用户进行分组,并提供以下格式的响应:
[
group1: [
{
name: "user1",
age: 50,
group: "group1"
},
{
name: "user3",
age: 20,
group: "group1"
}]
group2: [
{
name: "user2",
age: 30,
group: "group2"
}
]
]
Run Code Online (Sandbox Code Playgroud)
当查询param groupby等于"group" 时,我们提供这样的响应.因此,问题在于Swagger允许通过单个端点(方法和响应代码)仅提供单一响应格式.例如,我们不能为/ users端点" 200 "响应代码和GET HTTP方法提供2种响应格式.
而现在我对如何改变我们的REST设计以使其与Swagger兼容的方式感到困惑.
注意: 根据REST设计原则,为 …
java ×5
rest ×2
swagger ×2
api ×1
centos ×1
compare ×1
histogram ×1
http ×1
hystrix ×1
jmx ×1
jvm ×1
micrometer ×1
mongodb ×1
percentile ×1
port ×1
post ×1
prometheus ×1
rate ×1
retry-logic ×1
soap ×1
tomcat ×1
tomcat6 ×1
web-services ×1