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

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

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

Message.getRequiredHeader介绍

暂无

代码示例

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

private String getSagaType(Message message) {
 return message.getRequiredHeader(SagaCommandHeaders.SAGA_TYPE);
}

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

public boolean handles(Message message) {
 return aggregateType.equals(message.getRequiredHeader(EventMessageHeaders.AGGREGATE_TYPE))
     && eventClass.getName().equals(message.getRequiredHeader(EventMessageHeaders.EVENT_TYPE));
}

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

public boolean handles(Message message) {
 return aggregateType.equals(message.getRequiredHeader(EventMessageHeaders.AGGREGATE_TYPE))
     && eventClass.getName().equals(message.getRequiredHeader(EventMessageHeaders.EVENT_TYPE));
}

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

private boolean isUnlockMessage(Message message) {
 return message.getRequiredHeader(CommandMessageHeaders.COMMAND_TYPE).equals(SagaUnlockCommand.class.getName());
}

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

@Override
public boolean isSuccessfulReply(Message message) {
 return CommandReplyOutcome.SUCCESS.name().equals(message.getRequiredHeader(ReplyMessageHeaders.REPLY_OUTCOME));
}

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

@Override
public boolean isSuccessfulReply(Message message) {
 return CommandReplyOutcome.SUCCESS.name().equals(message.getRequiredHeader(ReplyMessageHeaders.REPLY_OUTCOME));
}

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

@Override
public boolean handles(Message message) {
 return message.getRequiredHeader(Message.DESTINATION).equals(commandChannel) && super.handles(message) && expectedCommand.test(message);
}

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

@Override
public boolean isSuccessfulReply(Message message) {
 return CommandReplyOutcome.SUCCESS.name().equals(message.getRequiredHeader(ReplyMessageHeaders.REPLY_OUTCOME));
}

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

@PostConstruct
public void subscribe() {
 messageConsumer.subscribe("etmv", singleton("*"), m -> {
  String destination = m.getRequiredHeader(Message.DESTINATION);
  getForDestination(destination).add(m);
 });
}

代码示例来源: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: 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-sagas

public SagaUnitTestSupport to(String commandChannel) {
 assertEquals(1, sentCommands.size());
 sentCommand = sentCommands.get(0);
 assertEquals(commandChannel, sentCommand.getDestination());
 assertEquals(expectedCommand.getClass().getName(), sentCommand.getMessage().getRequiredHeader(CommandMessageHeaders.COMMAND_TYPE));
 // TODO 
 sentCommands.clear();
 return this;
}

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

private void send(Message message) {
 String destination = message.getRequiredHeader(Message.DESTINATION);
 List<MessageHandlerWithSubscriberId> handlers = subscriptions.getOrDefault(destination, Collections.emptyList());
 sendToHandlers(destination, message, handlers);
 sendToHandlers(destination, message, wildcardSubscriptions);
}

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

private void send(Message message) {
 String destination = message.getRequiredHeader(Message.DESTINATION);
 List<MessageHandlerWithSubscriberId> handlers = subscriptions.getOrDefault(destination, Collections.emptyList());
 sendToHandlers(destination, message, handlers);
 sendToHandlers(destination, message, wildcardSubscriptions);
}

代码示例来源: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: eventuate-tram/eventuate-tram-core

@Test
 public void shouldDoSomething() throws InterruptedException {
  String messageId = commandProducer.send("customerService", "/customers/10",
      new MyTestCommand(), myReplyConsumer.getReplyChannel(),
      Collections.emptyMap());

  Message m = myReplyConsumer.messages.poll(30, TimeUnit.SECONDS);

  assertNotNull(m);

  assertEquals(messageId, m.getRequiredHeader(ReplyMessageHeaders.IN_REPLY_TO));

  System.out.println("Received m=" + m);

  verify(myTestCommandHandler).myHandlerMethod(any(CommandMessage.class), any(PathVariables.class));
 }
}

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

public Optional<ReplyClassAndHandler> findReplyHandler(String currentState, Data data, Message message) {
 SagaExecutionState state = decodeState(currentState);
 ParticipantInvocationStep<Data> participantInvocationStep = participantInvocationStepFor(state);
 String replyType = message.getRequiredHeader(ReplyMessageHeaders.REPLY_TYPE);
 Optional<BiConsumer<Data, Object>> possibleReplyHandler = participantInvocationStep.getReplyHandler(replyType, state.isCompensating());
 ParticipantInvocation pi = participantInvocationStep.getParticipantInvocation(state.isCompensating());
 if (pi.isSuccessfulReply(message)) {
  return figureOutNextStepsAndState(data, replyType, state, possibleReplyHandler);
 } else if (state.isCompensating()) {
  throw new UnsupportedOperationException("Failure when compensating");
 } else {
  return figureOutNextStepsAndState(data, replyType, state.startCompensating(), possibleReplyHandler);
 }
}

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

@Override
public void preSend(Message message) {
 MessageHeaderAccessor headers = makeMessageHeaderAccessor(message);
 TraceContextOrSamplingFlags extracted = this.extractor.extract(headers);
 Span span = this.threadLocalSpan.next(extracted);
 MessageHeaderPropagation.removeAnyTraceHeaders(headers, this.tracing.propagation().keys());
 this.injector.inject(span.context(), headers);
 if (!span.isNoop()) {
  span.kind(Span.Kind.PRODUCER).name("send " + message.getRequiredHeader(Message.DESTINATION)).start();
  addMessageTags(span, message);
 }
}

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

@Override
public void preHandle(String subscriberId, Message message) {
 MessageHeaderAccessor headers = makeMessageHeaderAccessor(message);
 TraceContextOrSamplingFlags extracted = this.extractor.extract(headers);
 Span span = this.threadLocalSpan.next(extracted);
 MessageHeaderPropagation.removeAnyTraceHeaders(headers, this.tracing.propagation().keys());
 this.injector.inject(span.context(), headers);
 if (!span.isNoop()) {
  span.kind(Span.Kind.CONSUMER).name("receive " + message.getRequiredHeader(Message.DESTINATION)).start();
  span.tag("subscriberId", subscriberId);
  addMessageTags(span, message);
 }
}

相关文章