/** Cleanup */ private void reset() { request = null; requestContent.setLength(0); responseContent.setLength(0); try { queueSend.close(); } catch (JMSException e) { logger.error("{}", e); } }
/** * Accepts JSON object and submits it to the JMS queue for processing * * @param requestAsJson JSON formatted string. See {@link workshop.dto.TrackingDataTO} * @return ResultTO to be passed on to the HTTP client with possible errorcodes */ public ResultTO submitPayload(String requestAsJson) { ResultTO resultTO; if (trackingType == TrackingType.UNKNOWN) { resultTO = new ResultTO(ResultCode.UNKNOWN_ROUTE); } else { try { TrackingDataTO trackingDataTO = gson.fromJson(requestAsJson, TrackingDataTO.class); trackingDataTO.setType(trackingType); trackingDataTO.setTimestamp(DateTime.now().toDate()); queueSend.send(trackingDataTO); resultTO = new ResultTO(ResultCode.SUCCESS); } catch (JsonSyntaxException e) { resultTO = new ResultTO(ResultCode.MALFORMED_INPUT); } catch (JMSException e) { resultTO = new ResultTO(ResultCode.INTERNAL_ERROR); } } return resultTO; }