io.quarkus.reactivemessaging.http.runtime.converters.StringConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-reactive-messaging-http Show documentation
Show all versions of quarkus-reactive-messaging-http Show documentation
Connect to HTTP or WebSocket and expose HTTP or WebSocket endpoints for Reactive Messaging
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