Search in sources :

Example 1 with ByteArrayMessageConverter

use of org.springframework.messaging.converter.ByteArrayMessageConverter in project spring-integration by spring-projects.

the class ConfigurableCompositeMessageConverter method initDefaults.

private static Collection<MessageConverter> initDefaults() {
    List<MessageConverter> converters = new LinkedList<>();
    if (JacksonPresent.isJackson2Present()) {
        converters.add(new MappingJackson2MessageConverter());
    }
    converters.add(new ByteArrayMessageConverter());
    converters.add(new ObjectStringMessageConverter());
    // TODO do we port it together with MessageConverterUtils ?
    // converters.add(new JavaSerializationMessageConverter());
    converters.add(new GenericMessageConverter());
    return converters;
}
Also used : GenericMessageConverter(org.springframework.messaging.converter.GenericMessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) CompositeMessageConverter(org.springframework.messaging.converter.CompositeMessageConverter) GenericMessageConverter(org.springframework.messaging.converter.GenericMessageConverter) MessageConverter(org.springframework.messaging.converter.MessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) LinkedList(java.util.LinkedList)

Example 2 with ByteArrayMessageConverter

use of org.springframework.messaging.converter.ByteArrayMessageConverter in project spring-cloud-stream by spring-cloud.

the class CompositeMessageConverterFactory method initDefaultConverters.

@SuppressWarnings("deprecation")
private void initDefaultConverters() {
    ApplicationJsonMessageMarshallingConverter applicationJsonConverter = new ApplicationJsonMessageMarshallingConverter(this.objectMapper);
    applicationJsonConverter.setStrictContentTypeMatch(true);
    this.converters.add(applicationJsonConverter);
    this.converters.add(new TupleJsonMessageConverter(this.objectMapper));
    this.converters.add(new ByteArrayMessageConverter());
    this.converters.add(new ObjectStringMessageConverter());
    // Deprecated converters
    this.converters.add(new JavaSerializationMessageConverter());
    this.converters.add(new KryoMessageConverter(null, true));
    this.converters.add(new JsonUnmarshallingConverter(this.objectMapper));
}
Also used : ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter)

Example 3 with ByteArrayMessageConverter

use of org.springframework.messaging.converter.ByteArrayMessageConverter in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method brokerMessageConverter.

@Bean
public CompositeMessageConverter brokerMessageConverter() {
    List<MessageConverter> converters = new ArrayList<>();
    boolean registerDefaults = configureMessageConverters(converters);
    if (registerDefaults) {
        converters.add(new StringMessageConverter());
        converters.add(new ByteArrayMessageConverter());
        if (jackson2Present) {
            converters.add(createJacksonConverter());
        } else if (gsonPresent) {
            converters.add(new GsonMessageConverter());
        } else if (jsonbPresent) {
            converters.add(new JsonbMessageConverter());
        } else if (kotlinSerializationJsonPresent) {
            converters.add(new KotlinSerializationJsonMessageConverter());
        }
    }
    return new CompositeMessageConverter(converters);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) KotlinSerializationJsonMessageConverter(org.springframework.messaging.converter.KotlinSerializationJsonMessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) JsonbMessageConverter(org.springframework.messaging.converter.JsonbMessageConverter) ArrayList(java.util.ArrayList) GsonMessageConverter(org.springframework.messaging.converter.GsonMessageConverter) JsonbMessageConverter(org.springframework.messaging.converter.JsonbMessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) KotlinSerializationJsonMessageConverter(org.springframework.messaging.converter.KotlinSerializationJsonMessageConverter) CompositeMessageConverter(org.springframework.messaging.converter.CompositeMessageConverter) GsonMessageConverter(org.springframework.messaging.converter.GsonMessageConverter) MessageConverter(org.springframework.messaging.converter.MessageConverter) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) CompositeMessageConverter(org.springframework.messaging.converter.CompositeMessageConverter) Bean(org.springframework.context.annotation.Bean)

Example 4 with ByteArrayMessageConverter

use of org.springframework.messaging.converter.ByteArrayMessageConverter in project spring-framework by spring-projects.

the class DefaultMessageHandlerMethodFactoryTests method customMessageConverterFailure.

@Test
public void customMessageConverterFailure() throws Exception {
    DefaultMessageHandlerMethodFactory instance = createInstance();
    MessageConverter messageConverter = new ByteArrayMessageConverter();
    instance.setMessageConverter(messageConverter);
    instance.afterPropertiesSet();
    InvocableHandlerMethod invocableHandlerMethod = createInvocableHandlerMethod(instance, "simpleString", String.class);
    assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() -> invocableHandlerMethod.invoke(MessageBuilder.withPayload(123).build()));
}
Also used : ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) MessageConversionException(org.springframework.messaging.converter.MessageConversionException) InvocableHandlerMethod(org.springframework.messaging.handler.invocation.InvocableHandlerMethod) MessageConverter(org.springframework.messaging.converter.MessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) Test(org.junit.jupiter.api.Test)

Example 5 with ByteArrayMessageConverter

use of org.springframework.messaging.converter.ByteArrayMessageConverter in project spring-framework by spring-projects.

the class DefaultStompSessionTests method setUp.

@BeforeEach
public void setUp() {
    this.connectHeaders = new StompHeaders();
    this.session = new DefaultStompSession(this.sessionHandler, this.connectHeaders);
    this.session.setMessageConverter(new CompositeMessageConverter(Arrays.asList(new StringMessageConverter(), new ByteArrayMessageConverter())));
    SettableListenableFuture<Void> future = new SettableListenableFuture<>();
    future.set(null);
    given(this.connection.send(this.messageCaptor.capture())).willReturn(future);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) ByteArrayMessageConverter(org.springframework.messaging.converter.ByteArrayMessageConverter) SettableListenableFuture(org.springframework.util.concurrent.SettableListenableFuture) CompositeMessageConverter(org.springframework.messaging.converter.CompositeMessageConverter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ByteArrayMessageConverter (org.springframework.messaging.converter.ByteArrayMessageConverter)5 CompositeMessageConverter (org.springframework.messaging.converter.CompositeMessageConverter)3 MessageConverter (org.springframework.messaging.converter.MessageConverter)3 MappingJackson2MessageConverter (org.springframework.messaging.converter.MappingJackson2MessageConverter)2 StringMessageConverter (org.springframework.messaging.converter.StringMessageConverter)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 Bean (org.springframework.context.annotation.Bean)1 GenericMessageConverter (org.springframework.messaging.converter.GenericMessageConverter)1 GsonMessageConverter (org.springframework.messaging.converter.GsonMessageConverter)1 JsonbMessageConverter (org.springframework.messaging.converter.JsonbMessageConverter)1 KotlinSerializationJsonMessageConverter (org.springframework.messaging.converter.KotlinSerializationJsonMessageConverter)1 MessageConversionException (org.springframework.messaging.converter.MessageConversionException)1 InvocableHandlerMethod (org.springframework.messaging.handler.invocation.InvocableHandlerMethod)1 SettableListenableFuture (org.springframework.util.concurrent.SettableListenableFuture)1