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

io.continual.messaging.impl.LoggerPublisher Maven / Gradle / Ivy

There is a newer version: 0.3.20
Show newest version
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 );
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy