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

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

Go to download

Connect to HTTP or WebSocket and expose HTTP or WebSocket endpoints for Reactive Messaging

There is a newer version: 2.4.1
Show newest version
package io.quarkus.reactivemessaging.http.runtime.converters;

import java.lang.reflect.Type;

import jakarta.enterprise.context.ApplicationScoped;

import org.eclipse.microprofile.reactive.messaging.Message;

import io.smallrye.reactive.messaging.MessageConverter;
import io.vertx.core.buffer.Buffer;

/**
 * Converts message payload to String
 */
@ApplicationScoped
public class StringConverter implements MessageConverter {
    @Override
    public boolean canConvert(Message in, Type target) {
        return in.getPayload() instanceof Buffer && target == String.class;
    }

    @Override
    public Message convert(Message in, Type target) {
        return in.withPayload(((Buffer) in.getPayload()).toString());
    }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy