2017-03-01 34 views
0

我正在運行一個使用Esper作爲我的核心CEP引擎的應用程序。 當我嘗試獲取之前在Esper運行時註冊的事件類型時,我得到一個UnsupportedOperationException。如何在運行時從Esper配置對象獲取eventType

esperConfiguration.addEventType(streamName, fieldNames, fieldTypes); 

-------- 
//several lines later 
-------- 

String[] propertyNames = esperConfiguration.getEventType(streamName).getPropertyNames(); 

我得到以下異常:

java.lang.UnsupportedOperationException: Obtaining an event type by name is only available at runtime 
     at com.espertech.esper.client.Configuration.getEventType(Configuration.java:905) 

我無法理解爲什麼我的API調用不是「在運行時」,甚至當我在重複使用我用於初始化同一對象Esper引擎。

回答

1

EventType對象在初始化引擎上可用。例如:

esperConfiguration.addEventType(streamName, fieldNames, fieldTypes); 

EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(esperConfiguration); 

String[] propertyNames = epService.getEPAdministrator().getConfiguration().getEventType(streamName).getPropertyNames(); 
相關問題