protected void handleException(Throwable exception, StompFrame command) throws IOException { LOG.warn("Exception occurred processing: \n" + command + ": " + exception.toString()); if (LOG.isDebugEnabled()) { LOG.debug("Exception detail", exception); } // Let the stomp client know about any protocol errors. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter stream = new PrintWriter(new OutputStreamWriter(baos, "UTF-8")); exception.printStackTrace(stream); stream.close(); HashMap<String, String> headers = new HashMap<String, String>(); headers.put(Stomp.Headers.Error.MESSAGE, exception.getMessage()); if (command != null) { final String receiptId = command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED); if (receiptId != null) { headers.put(Stomp.Headers.Response.RECEIPT_ID, receiptId); } } StompFrame errorMessage = new StompFrame(Stomp.Responses.ERROR, headers, baos.toByteArray()); sendToStomp(errorMessage); }
protected void handleException(Throwable exception, StompFrame command) throws IOException { if (command == null) { LOG.warn("Exception occurred while processing a command: {}", exception.toString()); } else { LOG.warn("Exception occurred processing: {} -> {}", safeGetAction(command), exception.toString()); } if (LOG.isDebugEnabled()) { LOG.debug("Exception detail", exception); } if (command != null && LOG.isTraceEnabled()) { LOG.trace("Command that caused the error: {}", command); } // Let the stomp client know about any protocol errors. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter stream = new PrintWriter(new OutputStreamWriter(baos, "UTF-8")); exception.printStackTrace(stream); stream.close(); HashMap<String, String> headers = new HashMap<>(); headers.put(Stomp.Headers.Error.MESSAGE, exception.getMessage()); headers.put(Stomp.Headers.CONTENT_TYPE, "text/plain"); if (command != null) { final String receiptId = command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED); if (receiptId != null) { headers.put(Stomp.Headers.Response.RECEIPT_ID, receiptId); } } StompFrame errorMessage = new StompFrame(Stomp.Responses.ERROR, headers, baos.toByteArray()); sendToStomp(errorMessage); }
protected void handleException(Throwable exception, StompFrame command) throws IOException { if (command == null) { LOG.warn("Exception occurred while processing a command: {}", exception.toString()); } else { LOG.warn("Exception occurred processing: {} -> {}", safeGetAction(command), exception.toString()); } if (LOG.isDebugEnabled()) { LOG.debug("Exception detail", exception); } if (command != null && LOG.isTraceEnabled()) { LOG.trace("Command that caused the error: {}", command); } // Let the stomp client know about any protocol errors. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter stream = new PrintWriter(new OutputStreamWriter(baos, "UTF-8")); exception.printStackTrace(stream); stream.close(); HashMap<String, String> headers = new HashMap<>(); headers.put(Stomp.Headers.Error.MESSAGE, exception.getMessage()); headers.put(Stomp.Headers.CONTENT_TYPE, "text/plain"); if (command != null) { final String receiptId = command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED); if (receiptId != null) { headers.put(Stomp.Headers.Response.RECEIPT_ID, receiptId); } } StompFrame errorMessage = new StompFrame(Stomp.Responses.ERROR, headers, baos.toByteArray()); sendToStomp(errorMessage); }
protected void handleException(Throwable exception, StompFrame command) throws IOException { if (command == null) { LOG.warn("Exception occurred while processing a command: {}", exception.toString()); } else { LOG.warn("Exception occurred processing: {} -> {}", safeGetAction(command), exception.toString()); } if (LOG.isDebugEnabled()) { LOG.debug("Exception detail", exception); } if (command != null && LOG.isTraceEnabled()) { LOG.trace("Command that caused the error: {}", command); } // Let the stomp client know about any protocol errors. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter stream = new PrintWriter(new OutputStreamWriter(baos, "UTF-8")); exception.printStackTrace(stream); stream.close(); HashMap<String, String> headers = new HashMap<>(); headers.put(Stomp.Headers.Error.MESSAGE, exception.getMessage()); headers.put(Stomp.Headers.CONTENT_TYPE, "text/plain"); if (command != null) { final String receiptId = command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED); if (receiptId != null) { headers.put(Stomp.Headers.Response.RECEIPT_ID, receiptId); } } StompFrame errorMessage = new StompFrame(Stomp.Responses.ERROR, headers, baos.toByteArray()); sendToStomp(errorMessage); }
protected void sendReceipt(StompFrame command) { final String receiptId = command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED); if (receiptId != null) { StompFrame sc = new StompFrame(); sc.setAction(Stomp.Responses.RECEIPT); sc.setHeaders(new HashMap<String, String>(1)); sc.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID, receiptId); try { sendToStomp(sc); } catch (IOException e) { LOG.warn("Could not send a receipt for {}", command, e); } } }
protected void sendReceipt(StompFrame command) { final String receiptId = command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED); if (receiptId != null) { StompFrame sc = new StompFrame(); sc.setAction(Stomp.Responses.RECEIPT); sc.setHeaders(new HashMap<String, String>(1)); sc.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID, receiptId); try { sendToStomp(sc); } catch (IOException e) { LOG.warn("Could not send a receipt for {}", command, e); } } }
protected void sendReceipt(StompFrame command) { final String receiptId = command.getHeaders().get(Stomp.Headers.RECEIPT_REQUESTED); if (receiptId != null) { StompFrame sc = new StompFrame(); sc.setAction(Stomp.Responses.RECEIPT); sc.setHeaders(new HashMap<String, String>(1)); sc.getHeaders().put(Stomp.Headers.Response.RECEIPT_ID, receiptId); try { sendToStomp(sc); } catch (IOException e) { LOG.warn("Could not send a receipt for {}", command, e); } } }
@Override void onMessageDispatch(MessageDispatch md, String ackId) throws IOException, JMSException { if (md.getMessage() != null) { super.onMessageDispatch(md, ackId); } else { StompFrame browseDone = new StompFrame(Stomp.Responses.MESSAGE); browseDone.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, this.getSubscriptionId()); browseDone.getHeaders().put(Stomp.Headers.Message.BROWSER, "end"); browseDone.getHeaders().put(Stomp.Headers.Message.DESTINATION, protocolConverter.findTranslator(null).convertDestination(protocolConverter, this.destination)); browseDone.getHeaders().put(Stomp.Headers.Message.MESSAGE_ID, "0"); protocolConverter.sendToStomp(browseDone); } }
@Override void onMessageDispatch(MessageDispatch md, String ackId) throws IOException, JMSException { if (md.getMessage() != null) { super.onMessageDispatch(md, ackId); } else { StompFrame browseDone = new StompFrame(Stomp.Responses.MESSAGE); browseDone.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, this.getSubscriptionId()); browseDone.getHeaders().put(Stomp.Headers.Message.BROWSER, "end"); browseDone.getHeaders().put(Stomp.Headers.Message.DESTINATION, protocolConverter.findTranslator(null).convertDestination(protocolConverter, this.destination)); browseDone.getHeaders().put(Stomp.Headers.Message.MESSAGE_ID, "0"); protocolConverter.sendToStomp(browseDone); } }
@Override void onMessageDispatch(MessageDispatch md, String ackId) throws IOException, JMSException { if (md.getMessage() != null) { super.onMessageDispatch(md, ackId); } else { StompFrame browseDone = new StompFrame(Stomp.Responses.MESSAGE); browseDone.getHeaders().put(Stomp.Headers.Message.SUBSCRIPTION, this.getSubscriptionId()); browseDone.getHeaders().put(Stomp.Headers.Message.BROWSER, "end"); browseDone.getHeaders().put(Stomp.Headers.Message.DESTINATION, protocolConverter.findTranslator(null).convertDestination(protocolConverter, this.destination)); browseDone.getHeaders().put(Stomp.Headers.Message.MESSAGE_ID, "0"); protocolConverter.sendToStomp(browseDone); } }