org.springframework.integration.support.AbstractIntegrationMessageBuilder.build()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(115)

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

AbstractIntegrationMessageBuilder.build介绍

暂无

代码示例

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

private void publish(Object object) {
    Message<?> message = null;
    if (object instanceof Message) {
      message = (Message<?>) object;
    }
    else {
      message = getMessageBuilderFactory().withPayload(object).build();
    }
    sendMessage(message);
  }
}

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

@Override
  public void presenceChanged(Presence presence) {
    if (presence != null) {
      if (logger.isDebugEnabled()) {
        logger.debug("presence changed: " + presence.getFrom() + " - " + presence);
      }
      sendMessage(PresenceListeningEndpoint.this.getMessageBuilderFactory().withPayload(presence).build());
    }
  }
}

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

@Override
public Message<?> toMessage(Object object, @Nullable Map<String, Object> headers) throws Exception {
  if (object instanceof Message<?>) {
    return (Message<?>) object;
  }
  return object != null
      ? this.messageBuilderFactory.withPayload(object).copyHeadersIfAbsent(headers).build()
      : null;
}

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

private Message<?> createServiceUnavailableResponse() {
  if (logger.isDebugEnabled()) {
    logger.debug("Endpoint is stopped; returning status " + HttpStatus.SERVICE_UNAVAILABLE);
  }
  return this.getMessageBuilderFactory().withPayload("Endpoint is stopped")
      .setHeader(org.springframework.integration.http.HttpHeaders.STATUS_CODE, HttpStatus.SERVICE_UNAVAILABLE)
      .build();
}

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

@Override
protected Object doTransform(Message<?> message) throws Exception {
  Assert.notNull(message, "message must not be null");
  UUID id = message.getHeaders().getId();
  Assert.notNull(id, "ID header must not be null");
  this.messageStore.addMessage(message);
  AbstractIntegrationMessageBuilder<?> responseBuilder = getMessageBuilderFactory().withPayload(id);
  // headers on the 'current' message take precedence
  responseBuilder.copyHeaders(message.getHeaders());
  return responseBuilder.build();
}

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

@Override
protected Object doTransform(Message<?> message) throws Exception {
  if (this.targetClass != null) {
    return this.jsonObjectMapper.fromJson(message.getPayload(), this.targetClass);
  }
  else {
    Object result = this.jsonObjectMapper.fromJson(message.getPayload(), message.getHeaders());
    AbstractIntegrationMessageBuilder<Object> messageBuilder = this.getMessageBuilderFactory().withPayload(result)
        .copyHeaders(message.getHeaders())
        .removeHeaders(JsonHeaders.HEADERS.toArray(new String[3]));
    return messageBuilder.build();
  }
}

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

@Override
public MutableMessage<?> convert(Document source) {
  @SuppressWarnings("unchecked")
  Map<String, Object> headers =
      MongoDbMessageStore.this.converter.normalizeHeaders((Map<String, Object>) source.get("headers"));
  Object payload = MongoDbMessageStore.this.converter.extractPayload(source);
  return (MutableMessage<?>) MutableMessageBuilder.withPayload(payload)
      .copyHeaders(headers)
      .build();
}

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

protected void send(String line) {
  Message<?> message = this.getMessageBuilderFactory().withPayload(line)
      .setHeader(FileHeaders.FILENAME, this.file.getName())
      .setHeader(FileHeaders.ORIGINAL_FILE, this.file)
      .build();
  super.sendMessage(message);
  updateLastProduce();
}

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

protected Message<Object> buildMessage(org.springframework.amqp.core.Message message, Object converted) {
  AbstractIntegrationMessageBuilder<Object> messageBuilder =
      this.messageBuilderFactory.withPayload(converted);
  if (this.channel.isExtractPayload()) {
    Map<String, Object> headers =
        this.inboundHeaderMapper.toHeadersFromRequest(message.getMessageProperties());
    messageBuilder.copyHeaders(headers);
  }
  return messageBuilder.build();
}

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

@Test
public void testProcessAndSendWithFilterAndProjectionAndMethodInvokingExpressionEvaluated() {
  when(group.getMessages()).thenReturn(messages);
  processor = new ExpressionEvaluatingMessageGroupProcessor(String.format("T(%s).sum(?[payload>2].![payload])",
      getClass().getName()));
  processor.setBeanFactory(mock(BeanFactory.class));
  Object result = processor.processMessageGroup(group);
  assertTrue(result instanceof AbstractIntegrationMessageBuilder<?>);
  Message<?> resultMessage = ((AbstractIntegrationMessageBuilder<?>) result).build();
  assertEquals(3 + 4 + 5, resultMessage.getPayload());
}

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

@Test
public void testProcessAndSendWithSizeExpressionEvaluated() {
  when(group.getMessages()).thenReturn(messages);
  processor = new ExpressionEvaluatingMessageGroupProcessor("#root.size()");
  processor.setBeanFactory(mock(BeanFactory.class));
  Object result = processor.processMessageGroup(group);
  assertTrue(result instanceof AbstractIntegrationMessageBuilder<?>);
  Message<?> resultMessage = ((AbstractIntegrationMessageBuilder<?>) result).build();
  assertEquals(5, resultMessage.getPayload());
}

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

@Test
public void testPushAndPopSequenceDetailsMutable() throws Exception {
  Message<Integer> message1 = MutableMessageBuilder.withPayload(1).pushSequenceDetails("foo", 1, 2).build();
  assertFalse(message1.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
  Message<Integer> message2 = MutableMessageBuilder.fromMessage(message1).pushSequenceDetails("bar", 1, 1).build();
  assertTrue(message2.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
  Message<Integer> message3 = MutableMessageBuilder.fromMessage(message2).popSequenceDetails().build();
  assertFalse(message3.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
}

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

@Test
public void testPushAndPopSequenceDetailsWhenNoSequenceMutable() throws Exception {
  Message<Integer> message1 = MutableMessageBuilder.withPayload(1).setCorrelationId("foo").build();
  assertFalse(message1.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
  Message<Integer> message2 = MutableMessageBuilder.fromMessage(message1).pushSequenceDetails("bar", 1, 1).build();
  assertTrue(message2.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
  Message<Integer> message3 = MutableMessageBuilder.fromMessage(message2).popSequenceDetails().build();
  assertFalse(message3.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
}

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

@Test
public void testProcessAndCheckHeaders() {
  when(group.getMessages()).thenReturn(messages);
  processor = new ExpressionEvaluatingMessageGroupProcessor("#root");
  processor.setBeanFactory(mock(BeanFactory.class));
  Object result = processor.processMessageGroup(group);
  processor.setBeanFactory(mock(BeanFactory.class));
  assertTrue(result instanceof AbstractIntegrationMessageBuilder<?>);
  Message<?> resultMessage = ((AbstractIntegrationMessageBuilder<?>) result).build();
  assertEquals("bar", resultMessage.getHeaders().get("foo"));
}

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

@Test
public void mutable() {
  MutableMessageBuilder<String> builder = MutableMessageBuilder.withPayload("test");
  Message<String> message1 = builder
      .setHeader("foo", "bar").build();
  Message<String> message2 = MutableMessageBuilder.fromMessage(message1).setHeader("another", 1).build();
  assertEquals("bar", message2.getHeaders().get("foo"));
  assertSame(message1.getHeaders().getId(), message2.getHeaders().getId());
  assertTrue(message2 == message1);
}

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

@Test
public void testPushAndPopSequenceDetailsWhenNoCorrelationIdMutable() throws Exception {
  Message<Integer> message1 = MutableMessageBuilder.withPayload(1).build();
  assertFalse(message1.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
  Message<Integer> message2 = MutableMessageBuilder.fromMessage(message1).pushSequenceDetails("bar", 1, 1).build();
  assertFalse(message2.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
  Message<Integer> message3 = MutableMessageBuilder.fromMessage(message2).popSequenceDetails().build();
  assertFalse(message3.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
}

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

@Test
public void testPopSequenceDetailsWhenNotPoppedMutable() throws Exception {
  Message<Integer> message1 = MutableMessageBuilder.withPayload(1).build();
  assertFalse(message1.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
  Message<Integer> message2 = MutableMessageBuilder.fromMessage(message1).popSequenceDetails().build();
  assertFalse(message2.getHeaders().containsKey(IntegrationMessageHeaderAccessor.SEQUENCE_DETAILS));
}

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

@Test
public void mutableFromImmutable() {
  Message<String> message1 = MessageBuilder.withPayload("test")
      .setHeader("foo", "bar").build();
  Message<String> message2 = MutableMessageBuilder.fromMessage(message1).setHeader("another", 1).build();
  assertEquals("bar", message2.getHeaders().get("foo"));
  assertSame(message1.getHeaders().getId(), message2.getHeaders().getId());
  assertNotSame(message1, message2);
  assertFalse(message2 == message1);
}

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

@Test
public void mutableFromImmutableMutate() {
  Message<String> message1 = MessageBuilder.withPayload("test")
      .setHeader("foo", "bar").build();
  Message<String> message2 = new MutableMessageBuilderFactory().fromMessage(message1).setHeader("another", 1).build();
  assertEquals("bar", message2.getHeaders().get("foo"));
  assertSame(message1.getHeaders().getId(), message2.getHeaders().getId());
  assertNotSame(message1, message2);
  assertFalse(message2 == message1);
}

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

@Test
public void testClaimCheck() {
  QueueChannel replyChannel = new QueueChannel();
  Message<String> message = MutableMessageBuilder.withPayload("foo").setReplyChannel(replyChannel).build();
  this.claimCheckInput.send(message);
  Message<?> receive = replyChannel.receive(10000);
  assertNotNull(receive);
  assertSame(message, receive);
  assertEquals(1, this.messageStore.getMessageCount());
  assertSame(message, this.messageStore.getMessage(message.getHeaders().getId()));
}

相关文章