@Override
public void process(Exchange exchange) throws Exception {
try {
String dtoAsString = exchange.getIn().getBody(String.class);
OutboundConfigurationWithPayloadDTO dto = objectMapper.readValue(dtoAsString,
OutboundConfigurationWithPayloadDTO.class);
OutboundConfiguration outboundConfiguration =
createOutboundConfigurationFromDto(dto.getOutboundConfiguration());
OutboundClient outboundClient =
outboundClientFactory.createOutboundClientForOutboundConfiguration(outboundConfiguration);
if (dto.getDataType() == OutboundDataType.RAW) {
outboundClient.putRawMessage(JSONObject.fromObject(dto.getPayload()));
} else if (dto.getDataType() == OutboundDataType.PROCESSED) {
SobaMessageResponseDTO responseDTO =
objectMapper.readValue(dto.getPayload(), SobaMessageResponseDTO.class);
outboundClient.putProcessedMessage(responseDTO);
} else if (dto.getDataType() == OutboundDataType.INSIGHT) {
SobaMessageResponseDTO responseDTO =
objectMapper.readValue(dto.getPayload(), SobaMessageResponseDTO.class);
outboundClient.putInsightMessage(responseDTO);
} else {
throw new OutboundStorageException("The received OutboundConfigurationWithPayloadDTO does not " +
"specify a valid dataType. Was " + dto.getDataType() +
" but was expecting one of [RAW, PROCESSED, or Insight]");
}
} catch (Exception e) {
logger.error("Unable to send payload outbound", e);
}