Java Code Examples for io.siddhi.core.stream.input.source.SourceEventListener#onEvent()

The following examples show how to use io.siddhi.core.stream.input.source.SourceEventListener#onEvent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestTrpInMemorySource.java    From siddhi-map-json with Apache License 2.0 5 votes vote down vote up
@Override
public StateFactory<State> init(SourceEventListener sourceEventListener, OptionHolder optionHolder,
                                String[] requestedTransportPropertyNames, ConfigReader configReader,
                                SiddhiAppContext siddhiAppContext) {
    super.init(sourceEventListener, optionHolder, requestedTransportPropertyNames, configReader, siddhiAppContext);
    symbol = optionHolder.validateAndGetStaticValue("prop1");
    price = optionHolder.validateAndGetStaticValue("prop2");
    fail = optionHolder.validateAndGetStaticValue("fail", "false");
    this.sourceEventListener = sourceEventListener;
    String topic = optionHolder.validateAndGetStaticValue(TOPIC_KEY, "input inMemory source");
    this.subscriber = new InMemoryBroker.Subscriber() {
        @Override
        public void onMessage(Object event) {
            if (fail.equals("true")) {
                sourceEventListener.onEvent(event, new String[]{symbol});
            } else {
                if (requestedTransportPropertyNames.length == 1 &&
                        requestedTransportPropertyNames[0].equals("symbol")) {
                    sourceEventListener.onEvent(event, new String[]{symbol, price});
                }
            }
        }

        @Override
        public String getTopic() {
            return topic;
        }
    };
    return null;
}
 
Example 2
Source File: TestTrpInMemorySource.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public StateFactory<State> init(SourceEventListener sourceEventListener, OptionHolder optionHolder,
                                String[] requestedTransportPropertyNames, ConfigReader configReader,
                                SiddhiAppContext siddhiAppContext) {
    super.init(sourceEventListener, optionHolder, requestedTransportPropertyNames, configReader, siddhiAppContext);
    symbol = optionHolder.validateAndGetStaticValue("prop1");
    price = optionHolder.validateAndGetStaticValue("prop2");
    fail = optionHolder.validateAndGetStaticValue("fail", "false");
    this.sourceEventListener = sourceEventListener;
    String topic = optionHolder.validateAndGetStaticValue(TOPIC_KEY, "input inMemory source");
    this.subscriber = new InMemoryBroker.Subscriber() {
        @Override
        public void onMessage(Object event) {
            if (fail.equals("true")) {
                sourceEventListener.onEvent(event, new String[]{symbol});
            } else {
                if (requestedTransportPropertyNames.length == 2 &&
                        requestedTransportPropertyNames[0].equals("symbol") &&
                        requestedTransportPropertyNames[1].equals("price")) {
                    sourceEventListener.onEvent(event, new String[]{symbol, price});
                }
            }
        }

        @Override
        public String getTopic() {
            return topic;
        }
    };
    return null;
}
 
Example 3
Source File: TestDepInMemorySource.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
public StateFactory<State> init(SourceEventListener sourceEventListener, OptionHolder optionHolder,
                                String[] requestedTransportPropertyNames, ConfigReader configReader,
                                SiddhiAppContext siddhiAppContext) {
    super.init(sourceEventListener, optionHolder, requestedTransportPropertyNames, configReader, siddhiAppContext);
    symbol = optionHolder.validateAndGetStaticValue("prop1");
    price = optionHolder.validateAndGetStaticValue("prop2");
    fail = optionHolder.validateAndGetStaticValue("fail", "false");
    this.sourceEventListener = sourceEventListener;
    String topic = optionHolder.validateAndGetStaticValue(TOPIC_KEY, "input inMemory source");
    this.subscriber = new InMemoryBroker.Subscriber() {
        @Override
        public void onMessage(Object event) {
            if (fail.equals("true")) {
                sourceEventListener.onEvent(event, new String[]{symbol});
            } else {
                if (requestedTransportPropertyNames.length == 2 &&
                        requestedTransportPropertyNames[0].equals("symbol") &&
                        requestedTransportPropertyNames[1].equals("price")) {
                    sourceEventListener.onEvent(event, new String[]{symbol, price});
                }
            }
        }

        @Override
        public String getTopic() {
            return topic;
        }
    };
    return null;
}