当前位置: 首页>>代码示例>>Java>>正文


Java MappingJackson2MessageConverter.setSerializedPayloadClass方法代码示例

本文整理汇总了Java中org.springframework.messaging.converter.MappingJackson2MessageConverter.setSerializedPayloadClass方法的典型用法代码示例。如果您正苦于以下问题:Java MappingJackson2MessageConverter.setSerializedPayloadClass方法的具体用法?Java MappingJackson2MessageConverter.setSerializedPayloadClass怎么用?Java MappingJackson2MessageConverter.setSerializedPayloadClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.messaging.converter.MappingJackson2MessageConverter的用法示例。


在下文中一共展示了MappingJackson2MessageConverter.setSerializedPayloadClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sqsMessageHandler

import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Bean
public QueueMessageHandler sqsMessageHandler() {
  Collection<MessageConverter> converters = new ArrayList<>();
  MappingJackson2MessageConverter jacksonConverter = new MappingJackson2MessageConverter();
  jacksonConverter.setSerializedPayloadClass(String.class);
  jacksonConverter.setStrictContentTypeMatch(false);
  converters.add(jacksonConverter);

  List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
  CompositeMessageConverter compositeMessageConverter = new CompositeMessageConverter(converters);
  resolvers.add(new NotificationMessageArgumentResolver(compositeMessageConverter));
  resolvers.add(new PayloadArgumentResolver(compositeMessageConverter));

  QueueMessageHandler handler = sqsMessageHandlerFactory().createQueueMessageHandler();
  handler.setArgumentResolvers(resolvers);
  return handler;
}
 
开发者ID:kalnee,项目名称:trivor,代码行数:18,代码来源:AWSConfig.java

示例2: createPayloadArgumentCompositeConverter

import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
private CompositeMessageConverter createPayloadArgumentCompositeConverter() {
    List<MessageConverter> payloadArgumentConverters = new ArrayList<>();

    if (JACKSON_2_PRESENT) {
        MappingJackson2MessageConverter jacksonMessageConverter = new MappingJackson2MessageConverter();
        jacksonMessageConverter.setObjectMapper(Jackson2ObjectMapperBuilder.json().build());
        jacksonMessageConverter.setSerializedPayloadClass(String.class);
        jacksonMessageConverter.setStrictContentTypeMatch(true);
        payloadArgumentConverters.add(jacksonMessageConverter);
    }

    ObjectMessageConverter objectMessageConverter = new ObjectMessageConverter();
    objectMessageConverter.setStrictContentTypeMatch(true);
    payloadArgumentConverters.add(objectMessageConverter);

    payloadArgumentConverters.add(new SimpleMessageConverter());

    return new CompositeMessageConverter(payloadArgumentConverters);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:QueueMessageHandler.java

示例3: initMessageConverter

import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
protected void initMessageConverter(MessageConverter messageConverter) {

        StringMessageConverter stringMessageConverter = new StringMessageConverter();
        stringMessageConverter.setSerializedPayloadClass(String.class);

        List<MessageConverter> messageConverters = new ArrayList<>();
        messageConverters.add(stringMessageConverter);

        if (messageConverter != null) {
            messageConverters.add(messageConverter);
        } else if (JACKSON_2_PRESENT) {
            MappingJackson2MessageConverter mappingJackson2MessageConverter = new MappingJackson2MessageConverter();
            mappingJackson2MessageConverter.setObjectMapper(Jackson2ObjectMapperBuilder.json().build());
            mappingJackson2MessageConverter.setSerializedPayloadClass(String.class);
            messageConverters.add(mappingJackson2MessageConverter);
        }

        setMessageConverter(new CompositeMessageConverter(messageConverters));
    }
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:AbstractMessageChannelMessagingSendingTemplate.java

示例4: instantiation_WithCustomJacksonConverterThatSupportsJava8Types_shouldConvertMessageToString

import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Test
public void instantiation_WithCustomJacksonConverterThatSupportsJava8Types_shouldConvertMessageToString() throws IOException {

    // Arrange
    AmazonSQSAsync amazonSqs = createAmazonSqs();

    ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();

    MappingJackson2MessageConverter simpleMessageConverter = new MappingJackson2MessageConverter();
    simpleMessageConverter.setSerializedPayloadClass(String.class);
    simpleMessageConverter.setObjectMapper(objectMapper);

    QueueMessagingTemplate queueMessagingTemplate = new QueueMessagingTemplate(amazonSqs, (ResourceIdResolver) null, simpleMessageConverter);

    // Act
    queueMessagingTemplate.convertAndSend("test", new TestPerson("Agim", "Emruli", LocalDate.of(2017, 1, 1)));

    // Assert
    ArgumentCaptor<SendMessageRequest> sendMessageRequestArgumentCaptor = ArgumentCaptor.forClass(SendMessageRequest.class);
    verify(amazonSqs).sendMessage(sendMessageRequestArgumentCaptor.capture());
    TestPerson testPerson = objectMapper.readValue(sendMessageRequestArgumentCaptor.getValue().getMessageBody(), TestPerson.class);

    assertEquals("Agim", testPerson.getFirstName());
    assertEquals("Emruli", testPerson.getLastName());
    assertEquals(LocalDate.of(2017, 1, 1), testPerson.getActiveSince());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:27,代码来源:QueueMessagingTemplateTest.java


注:本文中的org.springframework.messaging.converter.MappingJackson2MessageConverter.setSerializedPayloadClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。