arrowhead-f / arrowhead-kalix

The Arrowhead Kalix Libraries
https://arkalix.se
Eclipse Public License 2.0
2 stars 5 forks source link

Missing ArSystem#Builder#plugins() call results in empty orchestration request #37

Open awoSYS opened 2 years ago

awoSYS commented 2 years ago

I've found another case, in which a missing call of a builder method resulted in hard-to-understand missbehavior (similar to this comment).

I've built an ArSystem like this:

final var consumerSystem = consumerSystemBuilder.localHostnamePort(consumerHost, consumerPort)
                    .name(consumerSystemName).build();

Then I tried to consume a provided service like this:

final var consumerSystem = system.consume().name(provSrvName).oneUsing(MqttConsumer.factory())
                    .ifFailure(ServiceNotFoundException.class, error -> {
                        // log error message
                    }).await();

This always resulted in ServiceNotFoundExceptions with the text No service with the criteria xxx could be found or something like that. It took me days to figure out, that actually no message was sent to the orchestrator at all, but some default method in a Kalix interface returned an empty list which got treated like an empty orchestrator reply, resulting in the ServiceNotFoundException. My mistake was, that I'd forgotten to call the plugins() method when building the consumerSystem, so the system didn't connect to the ArrowHead core services.

I'd propose at least to have more obvious error message in case no connection to the AH system exists. Or even better would be some kind of code/compile time error indicating the missing builder method call (as discussed similarly in the above mentioned issue).

emanuelpalm commented 2 years ago

@awoSYS Relying only on a local cache of service registry entries is something I want Kalix to support, so I'm not going to force the library user to use any particular plugin. What I could do is have the exception list all sources it consulted and provide a hint about the plugin if it isn't being used.

awoSYS commented 2 years ago

@emanuelpalm yeah, these two things would certainly help!