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

com.quotemedia.streamer.client.impl.MessageEncoder Maven / Gradle / Ivy

Go to download

Java streaming client that provides easy-to-use client APIs to connect and subscribe to QuoteMedia's market data streaming services. https://quotemedia.com/

The newest version!
package com.quotemedia.streamer.client.impl;

import com.quotemedia.streamer.messages.smessage.SMessage;
import com.quotemedia.streamer.messages.smessage.SMessageEncoder;
import org.atmosphere.wasync.Encoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.google.common.base.Preconditions.checkNotNull;

public final class MessageEncoder implements Encoder {
    private static final Logger log = LoggerFactory.getLogger(MessageEncoder.class);
    private final SMessageEncoder encoder;

    public MessageEncoder(final SMessageEncoder encoder) {
        this.encoder = checkNotNull(encoder);
    }

    @Override
    public final String encode(final SMessage msg) {
        try {
            return this.encoder.encode(msg);
        } catch (final Exception e) {
            log.warn("Problem encoding message. Reason {}: {}", e.getClass().getSimpleName(), e.getMessage());
            log.debug("Problem encoding message.", e);
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy