org.axonframework.serialization.Serializer Java Examples

The following examples show how to use org.axonframework.serialization.Serializer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AxonConfiguration.java    From cdi with Apache License 2.0 5 votes vote down vote up
/**
 * Produces JPA token store.
 *
 * @return token store.
 */
@Produces
@ApplicationScoped
public TokenStore tokenStore(EntityManagerProvider entityManagerProvider,
        Serializer serializer) {
    return new JpaTokenStore(entityManagerProvider, serializer);
}
 
Example #2
Source File: AxonCdiExtension.java    From cdi with Apache License 2.0 5 votes vote down vote up
/**
 * Scans for a serializer producer.
 *
 * @param processProducer process producer event.
 */
<T> void processSerializerProducer(
        @Observes final ProcessProducer<T, Serializer> processProducer) {
    // TODO Handle multiple serializer definitions of the same type.

    AnnotatedMember<T> annotatedMember = processProducer.getAnnotatedMember();
    Named named = annotatedMember.getAnnotation(Named.class);

    if (named != null) {
        String namedValue = named.value();
        String serializerName = "".equals(namedValue)
                ? annotatedMember.getJavaMember().getName()
                : namedValue;
        switch (serializerName) {
            case "eventSerializer":
                logger.debug("Producer for event serializer found: {}.",
                        processProducer.getProducer());
                eventSerializerProducer = processProducer.getProducer();
                break;
            case "messageSerializer":
                logger.debug("Producer for message serializer found: {}.",
                        processProducer.getProducer());
                messageSerializerProducer = processProducer.getProducer();
                break;
            case "serializer":
                logger.debug("Producer for serializer found: {}.",
                        processProducer.getProducer());
                this.serializerProducer = processProducer.getProducer();
                break;
            default:
                logger.warn("Unknown named serializer configured: " + serializerName);
        }
    } else {
        logger.debug("Producer for serializer found: {}.", processProducer.getProducer());
        this.serializerProducer = processProducer.getProducer();
    }
}
 
Example #3
Source File: AxonConfiguration.java    From pcf-axon-cqrs-demo with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public SpringAMQPMessageSource complaintEventsMethod(Serializer serializer) {
    return new SpringAMQPMessageSource(new DefaultAMQPMessageConverter(serializer)) {

        @RabbitListener(queues = "${axon.amqp.exchange}")
        @Override
        public void onMessage(Message message, Channel channel) throws Exception {
            LOG.debug("Event Received: {}", message.getBody().toString());
            super.onMessage(message, channel);
        }
    };
}
 
Example #4
Source File: AppConfig.java    From ESarch with Apache License 2.0 4 votes vote down vote up
@Bean
@Qualifier("eventSerializer")
public Serializer eventSerializer(ObjectMapper objectMapper) {
    return new JacksonSerializer(objectMapper);
}
 
Example #5
Source File: TradingEngineApplication.java    From ESarch with Apache License 2.0 4 votes vote down vote up
@Bean
@Qualifier("eventSerializer")
public Serializer eventSerializer(ObjectMapper objectMapper) {
    return new JacksonSerializer(objectMapper);
}
 
Example #6
Source File: KafkaAutoConfiguration.java    From extension-kafka with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public KafkaMessageConverter<String, byte[]> kafkaMessageConverter(
        @Qualifier("eventSerializer") Serializer eventSerializer) {
    return DefaultKafkaMessageConverter.builder().serializer(eventSerializer).build();
}
 
Example #7
Source File: KafkaAutoConfigurationTest.java    From extension-kafka with Apache License 2.0 4 votes vote down vote up
@Bean
public Serializer eventSerializer() {
    return XStreamSerializer.builder().build();
}
 
Example #8
Source File: AxonConfiguration.java    From cdi with Apache License 2.0 4 votes vote down vote up
/**
 * Produces Jackson serializer.
 *
 * @return serializer.
 */
@Produces
@ApplicationScoped
public Serializer serializer() {
    return new JacksonSerializer();
}