Is it possible to send asynchronously while preserving order? For example:
for (int i = 0; i <= COUNT; i++) {
Object body = Integer.valueOf(i);
producerTemplate.asyncCallbackRequestBody(URL, body, callback);
}
Assuming that "URL" is a FIFO queue, is there some way for the recipient
to receive the messages in the order that the sender has sent them? I
think the answer is no, since async calls just schedule a task on an
executor, and it's possible for the thread scheduler to choose/process
send tasks out of order. [*]
If that's correct, then *if order is important*, all sends must be
synchronous, and performance will suffer (transmission will be in serial
instead of in parallel, and any network latency will make matters worse
since InOut requires round-trip communication). For this case, it
really would be useful to be able to async send and guarantee
transmission order (for JMS or whatever endpoint being used).
[*] One could set a single-threaded executor on the producer template.
The call would be asynchronous and transmission in order, however the
actual send operations would still be in serial (each InOut message must
be completely processed before the next message is sent), so the
performance would still suffer.
Comments?
Jim