@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())); }
@Override public void execute(DelegateExecution context) throws Exception { String refId = (String) context.getVariable("refId"); String correlationId = (String) context.getVariable("correlationId"); String traceId = context.getProcessBusinessKey(); messageSender.send( // new Message<PaymentReceivedEventPayload>( // "PaymentReceivedEvent", // traceId, // new PaymentReceivedEventPayload() // .setRefId(refId)) .setCorrelationId(correlationId)); }
@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(); }
@Override public void execute(DelegateExecution context) throws Exception { String traceId = context.getProcessBusinessKey(); String eventNameString = null; if (eventName!=null && eventName.getValue(context)!=null) { eventNameString = (String) eventName.getValue(context); } else { // if not configured we use the element id from the flow definition as default eventNameString = context.getCurrentActivityId(); } messageSender.send(new Message<String>( // eventNameString, // traceId, // null)); // no payload at the moment }
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); } } }