永发信息网

到底什么是消息队列?Java中如何实现消息队列

答案:1  悬赏:10  手机版
解决时间 2021-02-16 09:07
  • 提问者网友:温旧梦泪无声
  • 2021-02-16 05:47
到底什么是消息队列?Java中如何实现消息队列
最佳答案
  • 五星知识达人网友:白昼之月
  • 2021-02-16 06:55
所谓队列,就是按照队首先出的规则建立的数据结构,消息队列就是根据消息到来后按照一定的规则进行排序,但一定是队首的消息先得到应答的队列。
比如:

public static String do_post(String url, List name_value_pair) throws IOException {
String body = "{}";
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpPost httpost = new HttpPost(url);
httpost.setEntity(new UrlEncodedFormEntity(name_value_pair, StandardCharsets.UTF_8));
HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity();
body = EntityUtils.toString(entity);
} finally {
httpclient.getConnectionManager().shutdown();
}
return body;
}
public static String do_get(String url) throws ClientProtocolException, IOException {
String body = "{}";
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
body = EntityUtils.toString(entity);
} finally {
httpclient.getConnectionManager().shutdown();
}
return body;
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯