Code example for ScheduledExecutorService

Methods: scheduleAtFixedRate

0
    static final Logger log = Logger.getLogger(LastGroupByPerTimeOutputRateManager.class);
 
 
    public LastGroupByPerTimeOutputRateManager(Long value, ScheduledExecutorService scheduledExecutorService) {
        this.value = value;
        scheduledExecutorService.scheduleAtFixedRate(new EventSender(), 0, value.longValue(), TimeUnit.MILLISECONDS);
 
    } 
 
    @Override 
    public synchronized void send(long timeStamp, StreamEvent currentEvent, StreamEvent expiredEvent, String groupByKey) {
        if (currentEvent != null) {
            if (currentEvent instanceof ListEvent) {
                for (int i = 0, size = ((ListEvent) currentEvent).getActiveEvents(); i < size; i++) {
                    currentGroupByKeyEvents.put(groupByKey, (InEvent) ((ListEvent) currentEvent).getEvent(i));
                    allGroupByKeyEvents.put(groupByKey + "-current", (InEvent) ((ListEvent) currentEvent).getEvent(i));
                } 
            } else { 
                currentGroupByKeyEvents.put(groupByKey, (InEvent) currentEvent);
                allGroupByKeyEvents.put(groupByKey + "-current", (InEvent) currentEvent);
            }