private int readInRequest(QueueSession session, HttpServletRequest request, HttpServletResponse response) {
try {
BufferedReader reader = request.getReader();
if (!reader.ready()) return 0;
StringAppender sb = new StringAppender(request.getContentLength());
CharBuffer buffer = CharBuffer.allocate(10);
int read;
while ((read = reader.read(buffer)) > 0) {
buffer.rewind();
for (; read > 0; read--) {
sb.append(buffer.get());
}
buffer.rewind();
}
Message msg = createCommandMessage(sessionProvider.getSession(request.getSession(),
request.getHeader(ClientMessageBus.REMOTE_QUEUE_ID_HEADER)), sb.toString());
if (msg != null) {
try {
service.store(msg);
}
catch (Exception e) {