public void send(Message<?> m) { try { // avoid too much magic and transform ourselves ObjectMapper mapper = new ObjectMapper(); String jsonMessage = mapper.writeValueAsString(m); // wrap into a proper message for the transport (Kafka/Rabbit) and send it output.send( MessageBuilder.withPayload(jsonMessage).setHeader("messageType", m.getMessageType()).build()); } catch (Exception e) { throw new RuntimeException("Could not tranform and send message due to: "+ e.getMessage(), e); } } }
public void send(Message<?> m) { try { // avoid too much magic and transform ourselves ObjectMapper mapper = new ObjectMapper(); String jsonMessage = mapper.writeValueAsString(m); // wrap into a proper message for the transport (Kafka/Rabbit) and send it output.send( MessageBuilder.withPayload(jsonMessage).setHeader("messageType", m.getMessageType()).build()); } catch (Exception e) { throw new RuntimeException("Could not tranform and send message due to: "+ e.getMessage(), e); } } }
public void send(Message<?> m) { try { // avoid too much magic and transform ourselves ObjectMapper mapper = new ObjectMapper(); String jsonMessage = mapper.writeValueAsString(m); // wrap into a proper message for the transport (Kafka/Rabbit) and send it output.send( MessageBuilder.withPayload(jsonMessage).setHeader("messageType", m.getMessageType()).build()); } catch (Exception e) { throw new RuntimeException("Could not tranform and send message due to: "+ e.getMessage(), e); } } }
@StreamListener(target = Sink.INPUT, condition="(headers['messageType']?:'')=='RetrievePaymentCommand'") @Transactional public void retrievePaymentCommandReceived(String messageJson) throws JsonParseException, JsonMappingException, IOException { Message<RetrievePaymentCommandPayload> message = new ObjectMapper().readValue(messageJson, new TypeReference<Message<RetrievePaymentCommandPayload>>(){}); RetrievePaymentCommandPayload retrievePaymentCommand = message.getPayload(); System.out.println("Retrieve payment: " + retrievePaymentCommand.getAmount() + " for " + retrievePaymentCommand.getRefId()); camunda.getRuntimeService().createMessageCorrelation(message.getMessageType()) // .processInstanceBusinessKey(message.getTraceId()) .setVariable("amount", retrievePaymentCommand.getAmount()) // .setVariable("remainingAmount", retrievePaymentCommand.getAmount()) // .setVariable("refId", retrievePaymentCommand.getRefId()) // .setVariable("correlationId", message.getCorrelationId()) // .correlateWithResult(); }