Code example for ScheduledExecutorService

Methods: scheduleAtFixedRate

0
    Map<String, InEvent> groupByKeyEvents = new LinkedHashMap<String, InEvent>();
 
 
    public GroupByPerSnapshotOutputRateManager(Long value, ScheduledExecutorService scheduledExecutorService, WrappedSnapshotOutputRateManager wrappedSnapshotOutputRateManager) {
        super(wrappedSnapshotOutputRateManager);
        scheduledExecutorService.scheduleAtFixedRate(new EventSender(), 0, value, TimeUnit.MILLISECONDS);
    } 
 
    @Override 
    public synchronized void send(long timeStamp, StreamEvent currentEvent, StreamEvent expiredEvent, String groupByKey) {
        this.timeStamp = timeStamp;
        if (currentEvent != null) {
            if (currentEvent instanceof ListEvent) {
                groupByKeyEvents.put(groupByKey, (InEvent) ((ListEvent) currentEvent).getEvent(((ListEvent) currentEvent).getActiveEvents()));
            } else { 
                groupByKeyEvents.put(groupByKey, (InEvent) currentEvent);
            } 
        } 
    } 
 
    public synchronized void sendEvents() {