@Override public void run() { Channel conn = sq.channel; if (conn == null || !conn.isOpen()) { PerChannelQueue.logger.error("connection missing, no inbound communication"); return; } while (true) { if (!forever && sq.inbound.size() == 0) break; try { // block until a message is enqueued GeneratedMessage msg = sq.inbound.take(); // process request and enqueue response if (msg instanceof Request) { Request req = ((Request) msg); // do we need to route the request? System.out.println("#####Inside msg instanceof Request######"); // handle it locally Resource rsc = ResourceFactory.getInstance().resourceInstance(req.getHeader()); Response reply = null; if (rsc == null) { logger.error("failed to obtain resource for " + req); reply = ResourceUtil.buildError( req.getHeader(), ReplyStatus.FAILURE, "Request not processed"); } else { System.out.println( "#####Before Processing a request for reply######" + rsc.getClass()); reply = rsc.process(req); } sq.enqueueResponse(reply); } } catch (InterruptedException ie) { System.out.println("####error in processing - interruptedException####"); break; } catch (Exception e) { System.out.println("####error in processing####"); PerChannelQueue.logger.error("Unexpected processing failure", e); break; } } if (!forever) { PerChannelQueue.logger.info("connection queue closing"); } }