pl.allegro.tech.hermes.consumers.consumer.converter.DefaultMessageConverterResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hermes-consumers Show documentation
Show all versions of hermes-consumers Show documentation
Fast and reliable message broker built on top of Kafka.
package pl.allegro.tech.hermes.consumers.consumer.converter;
import pl.allegro.tech.hermes.api.ContentType;
import pl.allegro.tech.hermes.api.Subscription;
import pl.allegro.tech.hermes.consumers.consumer.Message;
public class DefaultMessageConverterResolver implements MessageConverterResolver {
private final AvroToJsonMessageConverter avroToJsonMessageConverter;
private final NoOperationMessageConverter noOperationMessageConverter;
public DefaultMessageConverterResolver(AvroToJsonMessageConverter avroToJsonMessageConverter,
NoOperationMessageConverter noOperationMessageConverter) {
this.avroToJsonMessageConverter = avroToJsonMessageConverter;
this.noOperationMessageConverter = noOperationMessageConverter;
}
@Override
public MessageConverter converterFor(Message message, Subscription subscription) {
if (message.getContentType() == ContentType.AVRO && subscription.getContentType() == ContentType.JSON) {
return avroToJsonMessageConverter;
}
return noOperationMessageConverter;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy