Joke Collection Website - Blessing messages - What exactly is a message queue? How to realize message queue with Java

What exactly is a message queue? How to realize message queue with Java

The so-called queue is a data structure established according to the rule that queues come first. Message queue is a queue sorted according to certain rules after messages arrive, but the messages at the head of the queue must be answered first.

For example:

The public static string do_post (string url, List & ltNameValuePair & gt name-value pair) throws IOException {

String body = " { }

default http client http client = new default http client();

Try {

http post http post = new http post(URL);

http post . setentity(new UrlEncodedFormEntity(name _ value _ pair,StandardCharsets。 UTF _ 8));

HttpResponse response = http client . execute(http post);

HttpEntity entity = response . get entity();

Body = EntityUtils.toString (entity);

} Finally {

http client . getconnectionmanager()。 Shut down ();

}

Return the text;

}

The public static string do_get (string url) raises ClientProtocolException, IOException {

String body = " { }

default http client http client = new default http client();

Try {

http get http get = new http get(URL);

HttpResponse response = http client . execute(http get);

HttpEntity entity = response . get entity();

Body = EntityUtils.toString (entity);

} Finally {

http client . getconnectionmanager()。 Shut down ();

}

Return the text;

}