org.springframework.messaging.handler.annotation.Header.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(212)

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

Header.<init>介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-integration-samples

public void process(String thing, @Header(FileHeaders.FILENAME) String fileName);

代码示例来源:origin: spring-projects/spring-framework

public void handleMessage(
    @Header String param1,
    @Header(name = "name", defaultValue = "bar") String param2,
    @Header(name = "name", defaultValue = "#{systemProperties.systemProperty}") String param3,
    @Header(name = "#{systemProperties.systemProperty}") String param4,
    String param5,
    @Header("foo") Optional<String> param6,
    @Header("nativeHeaders.param1") String nativeHeaderParam1) {
}

代码示例来源:origin: spring-projects/spring-integration-samples

/**
 * Aggregates LoanQuote Messages to return a single reply Message.
 *
 * @param quotes list of loan quotes received from upstream lenders
 * @param responseType header that indicates the response type
 * @return the best {@link LoanQuote} if the 'RESPONSE_TYPE' header value is 'BEST' else all quotes
 */
public Object aggregateQuotes(List<LoanQuote> quotes,
    @Header(value="RESPONSE_TYPE", required=false) String responseType) {
  Collections.sort(quotes);
  return ("BEST".equals(responseType)) ? quotes.get(0) : quotes;
}

代码示例来源:origin: dyc87112/SpringCloud-Learning

@StreamListener(value = TestTopic.INPUT, condition = "headers['version']=='2.0'")
public void receiveV2(String payload, @Header("version") String version) {
  log.info("Received v2 : " + payload + ", " + version);
}

代码示例来源:origin: dyc87112/SpringCloud-Learning

@StreamListener(value = TestTopic.INPUT, condition = "headers['version']=='1.0'")
public void receiveV1(String payload, @Header("version") String version) {
  log.info("Received v1 : " + payload + ", " + version);
}

代码示例来源:origin: spring-projects/spring-batch

public ChunkResponse extract(ChunkResponse input, @Header(JmsHeaders.REDELIVERED) boolean redelivered) {
  if (logger.isDebugEnabled()) {
    logger.debug("Extracted redelivered flag for response, value="+redelivered);
  }
  return new ChunkResponse(input, redelivered);
}

代码示例来源:origin: spring-projects/spring-framework

@MessageMapping("/optionalHeaders")
public void optionalHeaders(@Header(name="foo", required=false) String foo1, @Header("foo") Optional<String> foo2) {
  this.method = "optionalHeaders";
  this.arguments.put("foo1", foo1);
  this.arguments.put("foo2", (foo2.isPresent() ? foo2.get() : null));
}

代码示例来源:origin: spring-projects/spring-integration-samples

/**
 * If this service receives a payload 'failnnn' where nnn is the number of failures,
 * it will fail that many times for a given message id.
 * @param payload
 * @param id
 */
public void testRetry(String payload, @Header("failingId") String id) {
  if (payload.startsWith("fail")) {
    int failHowManyTimes = Integer.parseInt(payload.substring(4).trim());
    AtomicInteger failures = failCount.get(id);
    if (failures == null) {
      failures = new AtomicInteger();
      failCount.put(id, failures);
    }
    int currentFailures = failures.incrementAndGet();
    if (currentFailures <= failHowManyTimes) {
      String message = "Failure " + currentFailures + " of " + failHowManyTimes;
      logger.info("Service failure " + message);
      throw new RuntimeException(message);
    }
  }
  logger.info("Service success for " + payload);
  failCount.remove(id);
}

代码示例来源:origin: spring-projects/spring-framework

void handleIt(@Payload String msg, @Header("my-header") String myHeader);
}

代码示例来源:origin: spring-projects/spring-framework

@MessageMapping("/headers")
public void headers(@Header String foo, @Headers Map<String, Object> headers) {
  this.method = "headers";
  this.arguments.put("foo", foo);
  this.arguments.put("headers", headers);
}

代码示例来源:origin: spring-projects/spring-framework

@Transactional
  @JmsListener(destination = "testQueue")
  @SendTo("foobar")
  public void handleIt(@Header String value, String body) {
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
  @Transactional
  @JmsListener(destination = "testQueue")
  @SendTo("foobar")
  public void handleIt(@Header String value, String body) {
  }
}

代码示例来源:origin: spring-projects/spring-framework

public void resolveCustomHeaderNameAndPayload(@Payload String content, @Header("myCounter") int counter) {
  this.invocations.put("resolveCustomHeaderNameAndPayload", true);
  assertEquals("Wrong @Payload resolution", "my payload", content);
  assertEquals("Wrong @Header resolution", 24, counter);
}

代码示例来源:origin: spring-projects/spring-framework

public void resolveCustomHeaderNameAndPayloadWithHeaderNameSet(@Payload String content, @Header(name = "myCounter") int counter) {
  this.invocations.put("resolveCustomHeaderNameAndPayloadWithHeaderNameSet", true);
  assertEquals("Wrong @Payload resolution", "my payload", content);
  assertEquals("Wrong @Header resolution", 24, counter);
}

代码示例来源:origin: spring-projects/spring-framework

public void resolveHeaderAndPayload(@Payload String content, @Header int myCounter) {
  this.invocations.put("resolveHeaderAndPayload", true);
  assertEquals("Wrong @Payload resolution", "my payload", content);
  assertEquals("Wrong @Header resolution", 55, myCounter);
}

代码示例来源:origin: spring-projects/spring-framework

public void handleIt(@Payload String msg, @Header("my-header") String myHeader) {
    invocations.put("handleIt", true);
    assertEquals("Unexpected payload message", "FOO-BAR", msg);
    assertEquals("Unexpected header value", "my-value", myHeader);
  }
}

代码示例来源:origin: spring-projects/spring-batch

@ServiceActivator
public String cat(String value, @Header(value="stepExecution.jobExecution.jobParameters.getLong('factor')", required=false) Integer input) {
  long factor = input==null ? 1 : input;
  for (int i=1; i<factor; i++) {
    value += value;
  }
  return value;
}

代码示例来源:origin: spring-projects/spring-integration

@MessageMapping("/simple")
public void handle(@Header("stompCommand") String stompCommand) {
  this.stompCommand = stompCommand;
  this.latch.countDown();
}

代码示例来源:origin: spring-projects/spring-integration

@Publisher(channel = "messagePublishingAnnotationUsageTestChannel")
@Payload
public String defaultPayloadButExplicitAnnotation(String fname, @Header String lname) {
  return fname + " " + lname;
}

代码示例来源:origin: spring-projects/spring-integration

@Publisher(channel = "annotationConfigRegistrationTest")
@Payload("#return + #args.lname")
public String setName(String fname, String lname, @Header("x") int num) {
  return fname + " " + lname;
}

相关文章