package eu.dnetlib.stat.zmq;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import akka.actor.UntypedActor;
import akka.dispatch.Dispatchers;

@SuppressWarnings("unchecked")
class MyActor extends UntypedActor {
	private static final Log log = LogFactory.getLog(MyActor.class); // NOPMD by marko on 11/24/08 5:02 PM

	public static BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(2);
	
	public MyActor() {
		
//		getContext().setDispatcher(
//				Dispatchers.newExecutorBasedEventDrivenDispatcher("test").withNewThreadPoolWithCustomBlockingQueue(queue).setCorePoolSize(1)
//						.setMaxPoolSize(1).setRejectionPolicy(new CallerRunsPolicy()).build());
		
		getContext().setDispatcher(Dispatchers.newThreadBasedDispatcher(getContext(), 1));
	}

	@Override
	public void onReceive(Object arg0) throws Exception {
		log.info("receving " + arg0);
		
		Thread.sleep(4000);
	}
}
