bmwcarit / joynr

A transport protocol agnostic (MQTT, HTTP, WebSockets etc.) Franca IDL based communication framework supporting multiple communication paradigms (RPC, Pub-Sub, broadcast etc.)
Apache License 2.0
183 stars 55 forks source link

[Java] [Joynr 1.6.5] Cannot implement the Keyword arbitration strategy #42

Open mihai-stepan opened 5 years ago

mihai-stepan commented 5 years ago

Hi, I tried to implement the Keyword arbitration strategy, unfortunately I am stuck ... Can you please help me and provide support what I missed?

The LastSeen and HighestPriority works fine, but Keyword arbitration strategy ...

Provider:

@Override public void run() { // global variable ... provider = new BatteryStateProvider();

ProviderQos providerQos = new ProviderQos();
CustomParameter[] qosParameters = {// "keyword"
            new CustomParameter(ArbitrationConstants.KEYWORD_PARAMETER, "keyword_joynr_sdsdsd")
};
providerQos.setCustomParameters(qosParameters);
providerQos.setScope(ProviderScope.GLOBAL);

runtime.registerProvider("joynr-infrastructure", provider, providerQos);

// timer task to send battery data
SendBatteryData task = new SendBatteryData(VIN, provider);
    Timer timer = new Timer(true);
    timer.scheduleAtFixedRate(task, 0, 5 * 1000);

    while (true) {
        // just to keep app running
    }

}

Consumer:

@Override public void run() { long discoveryTimeout = 20000L; DiscoveryQos discoveryQos = new DiscoveryQos(discoveryTimeout, ArbitrationStrategy.Keyword, Long.MAX_VALUE); discoveryQos.setDiscoveryScope(DiscoveryScope.LOCAL_AND_GLOBAL); discoveryQos.addCustomParameter(ArbitrationConstants.KEYWORD_PARAMETER, "keyword_joynr_sdsdsd");

MessagingQos messagingQos = new MessagingQos();
messagingQos.setTtl_ms(30000L);

ProxyBuilder<BatteryStateProxy> batteryProxyBuilder = runtime.getProxyBuilder("joynr-infrastructure",
            BatteryStateProxy.class);

MulticastSubscriptionQos executeServiceSubscriptionQos = new MulticastSubscriptionQos();
    executeServiceSubscriptionQos.setValidityMs(10 * 6000 * 20);

try { batteryProxy = batteryProxyBuilder. setMessagingQos(messagingQos). // optional setDiscoveryQos(discoveryQos). // optional build(); subscriptionFutureBatteryState = subscribeToBatteryState(executeServiceSubscriptionQos); } catch (DiscoveryException e) { LOG.error("The consumer could not find any provider. {}", e); } catch (JoynrCommunicationException e) { LOG.error("The consumer could not send message. {}", e); }

.... }

Result: 2019-02-04 15:45:34,725 [ERROR] DispatcherImpl: Error parsing payload. msgId: 6a1b97b0-d7cd-4c4a-9d62-310395b37bda. from: capabilitiesdirectory_participantid to: 67ee9c03-8f41-4dd7-b2d1-d7b06aa08bb7. Reason: Could not resolve type id 'io.joynr.capabilities.CustomParameterPersisted' as a subtype of [simple type, class joynr.types.CustomParameter]: no such class found at [Source: (StringReader); line: 1, column: 674] (through reference chain: joynr.Reply["response"]->java.lang.Object[][0]->joynr.types.GlobalDiscoveryEntry["qos"]->joynr.types.ProviderQos["customParameters"]->java.lang.Object[][0]). Discarding joynr message.

and after the timeout error: 2019-02-04 15:45:54,513 [ERROR] ProxyBuilderDefaultImpl: error creating proxy: interface: battery/BatteryState domains: [joynr-infrastructure], error: ttl expired on: 04/02 15:45:54:054 2019-02-04 15:45:54,543 [ERROR] DispatcherImpl: Error processing request: Request: lookup, requestReplyId: 1eb38f70-facd-420b-ba0e-4c128bf05e47, params: [[Ljava.lang.String;@2695dff2, battery/BatteryState, DiscoveryQos [cacheMaxAge=0, discoveryTimeout=20000, discoveryScope=LOCAL_AND_GLOBAL, providerMustSupportOnChange=false]] joynr.exceptions.ProviderRuntimeException: io.joynr.exceptions.JoynrTimeoutException: ttl expired on: 04/02 15:45:54:054

Cay you please help me to understand what is wrong here? If you can please provide an example how to implement the Keyword arbitration strategy.

Thank you.

mihai-stepan commented 5 years ago

Workaround to fix:

2019-02-04 15:45:34,725 [ERROR] DispatcherImpl: Error parsing payload. msgId: 6a1b97b0-d7cd-4c4a-9d62-310395b37bda. from: capabilitiesdirectory_participantid to: 67ee9c03-8f41-4dd7-b2d1-d7b06aa08bb7. Reason: Could not resolve type id 'io.joynr.capabilities.CustomParameterPersisted' as a subtype of [simple type, class joynr.types.CustomParameter]: no such class found at [Source: (StringReader); line: 1, column: 674] (through reference chain: joynr.Reply["response"]->java.lang.Object[][0]->joynr.types.GlobalDiscoveryEntry["qos"]->joynr.types.ProviderQos["customParameters"]->java.lang.Object[][0]). Discarding joynr message.

Go to http://localhost:4848/common/index.jsf# (console management) From the Application section undeploy accesscontrol-jee, discovery-jee. Then deploy back the accesscontrol-jee, discovery-jee.

Also go to: cd ${GF_HOME}

----Windows cd \payara41\bin run as administrator -> asadmin

asadmin> list-domains domain1 not running joynr-car-domain not running joynr-infrastructure running payaradomain not running Command list-domains executed successfully.

stop-domain joynr-infrastructure stop-database

start-database start-domain joynr-infrastructure