All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.reactivemessaging.http.runtime.converters.JacksonBasedConverter Maven / Gradle / Ivy

package io.quarkus.reactivemessaging.http.runtime.converters;

import java.lang.reflect.Type;

import org.eclipse.microprofile.reactive.messaging.Message;
import org.jboss.logging.Logger;

import io.smallrye.reactive.messaging.MessageConverter;

public abstract class JacksonBasedConverter implements MessageConverter {
    private static final Logger log = Logger.getLogger(JacksonBasedConverter.class);

    @Override
    public Message convert(Message in, Type target) {
        try {
            return doConvert(in, target);
        } catch (Exception any) {
            String suffix = "";
            if (any instanceof IllegalArgumentException) {
                String message = any.getMessage();
                suffix = ": " + message;
            }
            log.error("Failed to convert payload to type " + target + suffix, any);

            return in;
        }
    }

    @Override
    public int getPriority() {
        return CONVERTER_DEFAULT_PRIORITY - 1;
    }

    protected abstract Message doConvert(Message in, Type target);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy