@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()); messageSender.send( // new Message<PaymentReceivedEventPayload>( // "PaymentReceivedEvent", // message.getTraceId(), // new PaymentReceivedEventPayload() // .setRefId(retrievePaymentCommand.getRefId())) .setCorrelationId(message.getCorrelationId())); }
@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(); }