Question

We have an application that connects to several other systems and pushes events into a stream. Each connector will also send a status message as its status changes. I would like to have an esper query that shows me the last status sent for each connector even if that status was sent a while ago. Our bean looks like this

public class ConnectorStatus
{
    private final String name;
    private final boolean available;
    private final boolean connected;

    public ConnectorStatus(String name, boolean available, boolean connected)
    {
        this.name = name;
        this.available = available;
        this.connected = connected;
    }

    public String getName() { return name; }
    public boolean getAvailable() { return available; }
    public boolean getConnected() { return connected; }
}

I have tried the following esper query, but it seems to only return the first status message for each name.

select name, available, connected
from ConnectorStatus.std:groupwin(name).std:lastevent()
output every 10 sec

I'm new to esper. I'm not bad with normal time window queries, but keeping the last event around for a long time is stumping me. There are only a couple of dozen connectors and their status may not change for hours, but we still want to see the last status sent.

Was it helpful?

Solution

The "std:unique" data window holds the last event per unique criteria. The "output snapshot" tells the engine to output data window contents.

select name, available, connected from ConnectorStatus.std:unique(name) output snapshot every 10 sec

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top