io.eventuate.tram.messaging.common.Message.getPayload()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(215)

本文整理了Java中io.eventuate.tram.messaging.common.Message.getPayload()方法的一些代码示例,展示了Message.getPayload()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getPayload()方法的具体详情如下:
包路径:io.eventuate.tram.messaging.common.Message
类名称:Message
方法名:getPayload

Message.getPayload介绍

暂无

代码示例

代码示例来源:origin: eventuate-tram/eventuate-tram-core

public MessageBuilder(Message message) {
 this(message.getPayload());
 this.headers = message.getHeaders();
}

代码示例来源:origin: eventuate-tram/eventuate-tram-sagas

public <C extends Command> SagaParticipantStubManagerHelper<C> when(C expectedCommand) {
 return new SagaParticipantStubManagerHelper<C>(this, (Class<C>) expectedCommand.getClass(),
     message -> JSonMapper.fromJson(message.getPayload(), expectedCommand.getClass()).equals(expectedCommand));
}

代码示例来源:origin: eventuate-tram/eventuate-tram-sagas

@Override
public void stashMessage(String sagaType, String sagaId, String target, Message message) {
 logger.debug("Stashing message from {} for {} : {}", sagaId, target, message);
 jdbcTemplate.update(insertIntoSagaStashTableSql,
     message.getRequiredHeader(Message.ID),
     target,
     sagaType,
     sagaId,
     JSonMapper.toJson(message.getHeaders()),
     message.getPayload()
     );
}

代码示例来源:origin: eventuate-tram/eventuate-tram-core

@Override
public void accept(Message message) {
 try {
  queue.put(message.getPayload());
 } catch (InterruptedException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: eventuate-tram/eventuate-tram-core

@Override
 protected ContractVerifierMessage convert(Message m) {
  return m == null ? null : contractVerifierMessaging.create(m.getPayload(), m.getHeaders());
 }
}

代码示例来源:origin: io.eventuate.tram.sagas/eventuate-jpa-sagas-framework

@Override
public void stashMessage(String sagaType, String sagaId, String target, Message message) {
 logger.debug("Stashing message from {} for {} : {}", sagaId, target, message);
 jdbcTemplate.update(insertIntoSagaStashTableSql,
     message.getRequiredHeader(Message.ID),
     target,
     sagaType,
     sagaId,
     JSonMapper.toJson(message.getHeaders()),
     message.getPayload()
     );
}

代码示例来源:origin: eventuate-tram/eventuate-tram-core

private void send(Message message) {
 String table = eventuateSchema.qualifyTable("message");
 jdbcTemplate.update(String.format("insert into %s(id, destination, headers, payload) values(?, ?, ?, ?)", table),
     message.getId(),
     message.getRequiredHeader(Message.DESTINATION),
     JSonMapper.toJson(message.getHeaders()),
     message.getPayload());
}

代码示例来源:origin: io.eventuate.tram.core/eventuate-tram-producer-jdbc

private void send(Message message) {
  String table = eventuateSchema.qualifyTable("message");
  jdbcTemplate.update(String.format("insert into %s(id, destination, headers, payload, creation_time) values(?, ?, ?, ?, %s)",
      table,
      currentTimeInMillisecondsSql),
      message.getId(),
      message.getRequiredHeader(Message.DESTINATION),
      JSonMapper.toJson(message.getHeaders()),
      message.getPayload());
 }
}

代码示例来源:origin: io.eventuate.tram.sagas/eventuate-tram-sagas-simple-dsl

@Override
 public SagaActions<Data> handleReply(String currentState, Data sagaData, Message message) {
  Optional<ReplyClassAndHandler> replyHandler = this.findReplyHandler(currentState, sagaData, message);

//    if (!replyHandler.isPresent()) {
//      logger.error("No handler for {}", message);
//      return;
//    }
  ReplyClassAndHandler m = replyHandler.get();

  Object param = JSonMapper.fromJson(message.getPayload(), m.getReplyClass());

  return (SagaActions<Data>) m.getReplyHandler().apply(sagaData, param);
 }

代码示例来源:origin: eventuate-tram/eventuate-tram-sagas

@Override
 public SagaActions<Data> handleReply(String currentState, Data sagaData, Message message) {
  Optional<ReplyClassAndHandler> replyHandler = this.findReplyHandler(currentState, sagaData, message);

//    if (!replyHandler.isPresent()) {
//      logger.error("No handler for {}", message);
//      return;
//    }
  ReplyClassAndHandler m = replyHandler.get();

  Object param = JSonMapper.fromJson(message.getPayload(), m.getReplyClass());

  return (SagaActions<Data>) m.getReplyHandler().apply(sagaData, param);
 }

代码示例来源:origin: io.eventuate.tram.core/eventuate-tram-events

public void messageHandler(Message message) {
 String aggregateType = message.getRequiredHeader(EventMessageHeaders.AGGREGATE_TYPE);
 Optional<DomainEventHandler> handler = domainEventHandlers.findTargetMethod(message);
 if (!handler.isPresent()) {
  return;
 }
 DomainEvent param = JSonMapper.fromJson(message.getPayload(), handler.get().getEventClass());
 handler.get().invoke(new DomainEventEnvelopeImpl<>(message,
     aggregateType,
     message.getRequiredHeader(EventMessageHeaders.AGGREGATE_ID),
     message.getRequiredHeader(Message.ID),
     param));
}

代码示例来源:origin: eventuate-tram/eventuate-tram-core

public void messageHandler(Message message) {
 String aggregateType = message.getRequiredHeader(EventMessageHeaders.AGGREGATE_TYPE);
 Optional<DomainEventHandler> handler = domainEventHandlers.findTargetMethod(message);
 if (!handler.isPresent()) {
  return;
 }
 DomainEvent param = JSonMapper.fromJson(message.getPayload(), handler.get().getEventClass());
 handler.get().invoke(new DomainEventEnvelopeImpl<>(message,
     aggregateType,
     message.getRequiredHeader(EventMessageHeaders.AGGREGATE_ID),
     message.getRequiredHeader(Message.ID),
     param));
}

代码示例来源:origin: eventuate-tram/eventuate-tram-core

public void messageHandler(Message message) {
 logger.trace("Received message {} {}", commandDispatcherId, message);
 Optional<CommandHandler> possibleMethod = commandHandlers.findTargetMethod(message);
 if (!possibleMethod.isPresent()) {
  throw new RuntimeException("No method for " + message);
 }
 CommandHandler m = possibleMethod.get();
 Object param = convertPayload(m, message.getPayload());
 Map<String, String> correlationHeaders = correlationHeaders(message.getHeaders());
 Map<String, String> pathVars = getPathVars(message, m);
 Optional<String> defaultReplyChannel = message.getHeader(CommandMessageHeaders.REPLY_TO);
 List<Message> replies;
 try {
  CommandMessage cm = new CommandMessage(message.getId(), param, correlationHeaders, message);
  replies = invoke(m, cm, pathVars);
  logger.trace("Generated replies {} {} {}", commandDispatcherId, message, replies);
 } catch (Exception e) {
  logger.trace("Generated error {} {} {}", commandDispatcherId, message, e.getClass().getName());
  handleException(message, param, m, e, pathVars, defaultReplyChannel);
  return;
 }
 if (replies != null) {
  publish(correlationHeaders, replies, defaultReplyChannel);
 } else {
  logger.trace("Null replies - not publishling");
 }
}

代码示例来源:origin: eventuate-tram/eventuate-tram-core

private void messageHandler(Message message) {
  logger.info("received message {}" , message);
  TestMessage testMessage = JSonMapper.fromJson(message.getPayload(), TestMessage.class);

  ResponseEntity<String> result = restTemplate.postForEntity(String.format("http://localhost:%s/bar", testMessage
          .getPort()),
      "hello", String.class);

  assertEquals(HttpStatus.OK, result.getStatusCode());
 }
}

代码示例来源:origin: eventuate-tram/eventuate-tram-core

private boolean satisfies(Message message, Contract groovyDsl) {
 if (!headersMatch(message, groovyDsl)) {
  logger.info("Headers don't match {} {} ", groovyDsl.getLabel(), message);
  return false;
 }
 BodyMatchers matchers = groovyDsl.getInput().getBodyMatchers();
 Object dslBody = MapConverter.getStubSideValues(groovyDsl.getInput().getMessageBody());
 Object matchingInputMessage = JsonToJsonPathsConverter
     .removeMatchingJsonPaths(dslBody, matchers);
 JsonPaths jsonPaths = JsonToJsonPathsConverter
     .transformToJsonPathWithStubsSideValuesAndNoArraySizeCheck(
         matchingInputMessage);
 DocumentContext parsedJson = JsonPath.parse(message.getPayload());
 boolean matches = true;
 for (MethodBufferingJsonVerifiable path : jsonPaths) {
  matches &= matchesJsonPath(parsedJson, path.jsonPath());
 }
 logger.info("jsonPaths match {} {} {} ", groovyDsl.getLabel(), matches, message);
 if (matchers != null && matchers.hasMatchers()) {
  for (BodyMatcher matcher : matchers.jsonPathMatchers()) {
   String jsonPath = JsonToJsonPathsConverter.convertJsonPathAndRegexToAJsonPath(matcher, dslBody);
   matches &= matchesJsonPath(parsedJson, jsonPath);
  }
 }
 logger.info("matchers {} {} {} ", groovyDsl.getLabel(), matches, message);
 return matches;
}

代码示例来源:origin: io.eventuate.tram.sagas/eventuate-jpa-sagas-framework

String messageJson = message.getPayload();

代码示例来源:origin: eventuate-tram/eventuate-tram-sagas

@Test
public void shouldReleaseLockAndUnstashMessage() {
 String sagaId1 = idGenerator.genId().toString();
 String sagaId2 = idGenerator.genId().toString();
 String target  = "/target/" + idGenerator.genId().toString();
 String messageId = idGenerator.genId().toString();
 assertTrue(sagaLockManager.claimLock(sagaType, sagaId1, target));
 assertFalse(sagaLockManager.claimLock(sagaType, sagaId2, target));
 String payload = "hello";
 Message message = MessageBuilder.withPayload(payload).withHeader(Message.ID, messageId).build();
 sagaLockManager.stashMessage(sagaType, sagaId2, target, message);
 Optional<Message> unstashedMessage1 = sagaLockManager.unlock(sagaId1, target);
 assertTrue(unstashedMessage1.isPresent());
 assertEquals(messageId, unstashedMessage1.get().getId());
 assertEquals(payload, unstashedMessage1.get().getPayload());
 assertFalse(sagaLockManager.unlock(sagaId2, target).isPresent());
}

相关文章