I wanted to listen all measurement in my microservices. I am able to get the values in EPL but my EPL implementation is taking too much memory from the available memory.
on all MeasurementFragment(type=“xyz”,valueFragment=“xyz”, valueSeries = “ABC”) as mf {
I am getting below error . I and running this application on my local system and connect with dev tenent.
Could you please help me in this.
023-05-25 17:08:41.087 ERROR 32832 — [subscriptions-0] .s.s.i.MicroserviceSubscriptionScheduler : Error while reacting on microservice subscription
com.cumulocity.sdk.client.SDKException: Error invoking GET http://localhost:8181/application/applicationsByName/hello-microservice-notification
at com.cumulocity.microservice.subscription.repository.impl.LegacyMicroserviceRepository.handleException(LegacyMicroserviceRepository.java:150) ~[microservice-subscription-1011.0.12.jar!/:na]
at com.cumulocity.microservice.subscription.repository.impl.LegacyMicroserviceRepository.getByName(LegacyMicroserviceRepository.java:101) ~[microservice-subscription-1011.0.12.jar!/:na]
at com.cumulocity.microservice.subscription.repository.impl.LegacyMicroserviceRepository.register(LegacyMicroserviceRepository.java:62) ~[microservice-subscription-1011.0.12.jar!/:na]
at com.cumulocity.microservice.subscription.repository.MicroserviceSubscriptionsRepository.register(MicroserviceSubscriptionsRepository.java:110) ~[microservice-subscription-1011.0.12.jar!/:na]
at com.cumulocity.microservice.subscription.service.impl.MicroserviceSubscriptionsServiceImpl.registerApplication(MicroserviceSubscriptionsServiceImpl.java:169) ~[microservice-subscription-1011.0.12.jar!/:na]
at com.cumulocity.microservice.subscription.service.impl.MicroserviceSubscriptionsServiceImpl.subscribe(MicroserviceSubscriptionsServiceImpl.java:114) ~[microservice-subscription-1011.0.12.jar!/:na]
at com.cumulocity.microservice.subscription.service.impl.MicroserviceSubscriptionScheduler.lambda$schedulePeriodicSubscription$0(MicroserviceSubscriptionScheduler.java:81) ~[microservice-subscription-1011.0.12.jar!/:na]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: javax.ws.rs.ProcessingException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8181 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
That’s hard to debug remotely. Most likely there is something wrong with your subscription. Please note that you have to subscribe on “mo” context using “measurements” subscription filter.
I am able to deploy
SoftwareAG/cumulocity-microservice-templates/tree/main/realtime"*
with my changes and its running fine on local as well as when i deploy on VM and able to get measurements data as in listener.
I am able to deploy this microservices in complicity tenant as well and i got this response when i check the health of microservice.
I am getting following error on running it on dev platform
2023-06-14 16:18:17.567 INFO 13 — [main] c.e.n.helloworld.NotificationExample : Subscription added for Tenant ID:
2023-06-14 16:18:17.870 INFO 13 — [main] c.e.n.helloworld.NotificationExample : Subscription does not exist. Creating …
2023-06-14 16:18:17.982 INFO 13 — [main] c.e.n.helloworld.NotificationExample : Connecting WebSocket client …
2023-06-14 16:18:18.079 ERROR 13 — [WebSocketConnectReadThread-28] c.e.n.h.w.t.TooTallNateWebSocketClient : WebSocket error:java.net.UnknownHostException: cumulocity.default.svc.cluster.local: Name does not resolve
2023-06-14 16:18:18.079 ERROR 13 — [WebSocketConnectReadThread-28] c.e.n.helloworld.NotificationExample : We got an exception: java.net.UnknownHostException: cumulocity.default.svc.cluster.local: Name does not resolve
2023-06-14 16:18:18.086 INFO 13 — [WebSocketConnectReadThread-28] c.e.n.h.w.t.TooTallNateWebSocketClient : WebSocket closed Code:-1, reason: cumulocity.default.svc.cluster.local: Name does not resolve
2023-06-14 16:18:18.086 INFO 13 — [WebSocketConnectReadThread-28] c.e.n.helloworld.NotificationExample : Connection was closed.
Please suggest , if i need to modify any thing or am i doing some thing wrong over here.
Okay in that case it might be worthwhile to check if this is about the Notifications Endpoint or caused by your local setup. Can you read measurements via API in your local Service? (You can use Measurement API Class )
C8Y_BOOTSTRAP_TENANT={tenant id, e.g. t948822};
C8Y_BOOTSTRAP_USER=servicebootstrap_hello-notification;
C8Y_BOOTSTRAP_PASSWORD={bootstrap user password};
C8Y_MICROSERVICE_ISOLATION=PER_TENANT;
C8Y_TENANT={tenant id, e.g. t948822};
C8Y_USER={my user name};
C8Y_PASSWORD={my user password};
The C8Y_USER needs to have ROLE_NOTIFICATION_2_ADMIN permission. If it does not have the permission, server responds with 403, not 401. So I suspect your problem has to do with your local setup (make sure the required environment variables are set).
To get the Bootstrap user you can use this API endpoint. Use the ID of the hello-notification service here.
// Also, when running from your localhost, make sure you are using wss:// rather than ws:// in your websocket URL.