package demo.simple.queue.event;

import com.github.microservice.components.data.mongo.queue.event.ExecQueueEvent;
import com.github.microservice.core.util.random.RandomUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

@Slf4j
@Component
public class QuEvent implements ExecQueueEvent {


    @Override
    public boolean execute(Map<String,Object> o) {
        log.info("time : {} -> {}", System.currentTimeMillis(), o);
        int random = RandomUtil.nextInt(1, 100);
        if (random % 11 == 0) {
            return true;
        }
//        else if (random % 19 == 0) {
//            System.exit(0);
//        }
        return false;
    }
}
