我正在尝试在Java应用程序中订阅事件频道。 我正在尝试根据此处找到的示例实例化新的订户。
How the java client in cumulocity listens to events?
我对设备上发生的事件特别感兴趣,因此我正在订阅频道“ / events / 123”,其中123是设备ID。
public static void main( String[] args )
{
String uRl = "urlOfMyCumulocityIstance";
CumulocityCredentials rC = new CumulocityCredentials("username","password");
PlatformParameters parameters = new PlatformParameters(uRl,rC,new ClientConfiguration());
CepCustomNotificationsSubscriber t = new CepCustomNotificationsSubscriber(parameters);
System.out.println(t.toString() + " - " + t.CEP_CUSTOM_NOTIFICATIONS_URL.toString()); // It prints an integer number corresponding to the subscriber t.
t.subscribe("/events/123", new SubscriptionListener<String, Object>() {
public void onError(Subscription arg0, Throwable arg1) {
// TODO Auto-generated method stub
System.out.println(arg1.getMessage());
}
public void onNotification(Subscription arg0, Object arg1) {
// TODO Auto-generated method stub
System.out.println(arg1);
}
});
}
尽管如此,我没有将任何事件发送到设备。
总而言之,我想做的就是您在Apama中通过键入内容进行操作
monitor.subscribe(Event.CHANNEL)
on all Event(source=123) as e
{
// do something
}
有什么想法吗? 预先感谢