io.continual.messaging.impl.LoggerPublisher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of continualMessaging Show documentation
Show all versions of continualMessaging Show documentation
Continual event definition and utilities
package io.continual.messaging.impl;
import java.util.Collection;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.continual.messaging.ContinualMessage;
import io.continual.messaging.ContinualMessagePublisher;
import io.continual.messaging.ContinualMessageSink;
import io.continual.messaging.ContinualMessageStream;
import io.continual.services.ServiceContainer;
import io.continual.services.SimpleService;
public class LoggerPublisher extends SimpleService implements ContinualMessagePublisher
{
public LoggerPublisher ()
{
}
public LoggerPublisher ( JSONObject config )
{
}
public LoggerPublisher ( ServiceContainer sc, JSONObject config )
{
}
@Override
public void flush ()
{
}
@Override
public void close ()
{
}
@Override
public ContinualMessageSink getTopic ( String topic ) throws TopicUnavailableException
{
return new ContinualMessageSink ()
{
@Override
public void send ( ContinualMessageStream stream, Collection msgs )
{
for ( ContinualMessage msg : msgs )
{
log.info ( topic + " (" + stream.getName () + "): " + msg.toJson ().toString () ); // msg.getMessagePayload ().toString () );
}
}
};
}
private static final Logger log = LoggerFactory.getLogger ( LoggerPublisher.class );
}