Search in sources :

Example 1 with EntityQueuedEvent

use of org.bedework.sysevents.events.EntityQueuedEvent in project bw-calendar-engine by Bedework.

the class InoutSched method action.

@Override
public void action(final SysEvent ev) throws NotificationException {
    if (ev == null) {
        return;
    }
    try {
        if (debug) {
            debug("Received message" + ev);
        }
        if (ev instanceof EntityQueuedEvent) {
            counts.total++;
            final EntityQueuedEvent eqe = (EntityQueuedEvent) ev;
            for (int ct = 1; ct <= retryLimit; ct++) {
                if ((ct - 1) > counts.maxRetries) {
                    counts.maxRetries = ct - 1;
                }
                final ProcessMessageResult pmr = handler.processMessage(eqe);
                if (pmr == ProcessMessageResult.PROCESSED) {
                    counts.processed++;
                    return;
                }
                if (pmr == ProcessMessageResult.NO_ACTION) {
                    counts.noaction++;
                    return;
                }
                if (pmr == ProcessMessageResult.STALE_STATE) {
                    counts.staleState++;
                    counts.retries++;
                    if (ct == 1) {
                        counts.retried++;
                    }
                }
                if (pmr == ProcessMessageResult.FAILED_NORETRIES) {
                    counts.failedNoRetries++;
                    return;
                }
                if (pmr == ProcessMessageResult.FAILED) {
                    counts.failed++;
                    counts.retries++;
                    if (ct == 1) {
                        counts.retried++;
                    }
                }
            }
            /* Failed after retries */
            counts.failedRetries++;
        }
    } catch (final Throwable t) {
        error("Error processing message " + ev);
        error(t);
    }
}
Also used : EntityQueuedEvent(org.bedework.sysevents.events.EntityQueuedEvent) ProcessMessageResult(org.bedework.calsvc.MesssageHandler.ProcessMessageResult)

Example 2 with EntityQueuedEvent

use of org.bedework.sysevents.events.EntityQueuedEvent in project bw-calendar-engine by Bedework.

the class JmsNotificationsHandlerImpl method post.

@Override
public void post(final SysEventBase ev) throws NotificationException {
    if (debug) {
        debug(ev.toString());
    }
    long start = System.currentTimeMillis();
    send: {
        if (ev instanceof MillisecsEvent) {
            monitor.post(ev);
            if ((ev instanceof TimedEvent) || (ev instanceof HttpEvent)) {
                break send;
            }
        }
        syslog.post(ev);
        boolean changeEvent = false;
        for (final Attribute attr : ev.getMessageAttributes()) {
            if (!"changeEvent".equals(attr.name)) {
                continue;
            }
            changeEvent = Boolean.valueOf(attr.value);
            break;
        }
        if (changeEvent) {
            changes.post(ev);
        }
        if (ev instanceof EntityQueuedEvent) {
            final EntityQueuedEvent eqe = (EntityQueuedEvent) ev;
            if (((EntityQueuedEvent) ev).getInBox()) {
                scheduleIn.post(ev);
            } else {
                scheduleOut.post(ev);
                break send;
            }
        }
        if (ev instanceof ScheduleUpdateEvent) {
            scheduleIn.post(ev);
        }
    }
    // send
    sends++;
    sendTime += System.currentTimeMillis() - start;
    if ((sends % 100) == 0) {
        debug("Sends: " + sends + " avg: " + sendTime / sends);
    }
}
Also used : EntityQueuedEvent(org.bedework.sysevents.events.EntityQueuedEvent) MillisecsEvent(org.bedework.sysevents.events.MillisecsEvent) Attribute(org.bedework.sysevents.events.SysEventBase.Attribute) TimedEvent(org.bedework.sysevents.events.TimedEvent) HttpEvent(org.bedework.sysevents.events.HttpEvent) ScheduleUpdateEvent(org.bedework.sysevents.events.ScheduleUpdateEvent)

Aggregations

EntityQueuedEvent (org.bedework.sysevents.events.EntityQueuedEvent)2 ProcessMessageResult (org.bedework.calsvc.MesssageHandler.ProcessMessageResult)1 HttpEvent (org.bedework.sysevents.events.HttpEvent)1 MillisecsEvent (org.bedework.sysevents.events.MillisecsEvent)1 ScheduleUpdateEvent (org.bedework.sysevents.events.ScheduleUpdateEvent)1 Attribute (org.bedework.sysevents.events.SysEventBase.Attribute)1 TimedEvent (org.bedework.sysevents.events.TimedEvent)1