diff --git a/src/lib/orionld/dds/ddsNotification.cpp b/src/lib/orionld/dds/ddsNotification.cpp index 072864281f..ba65e39f90 100644 --- a/src/lib/orionld/dds/ddsNotification.cpp +++ b/src/lib/orionld/dds/ddsNotification.cpp @@ -35,6 +35,7 @@ extern "C" #include "orionld/common/traceLevels.h" // KT_T trace levels #include "orionld/common/tenantList.h" // tenant0 #include "orionld/context/orionldContextItemExpand.h" // orionldContextItemExpand +#include "orionld/notifications/orionldAlterationsTreat.h" // orionldAlterationsTreat #include "orionld/serviceRoutines/orionldPutAttribute.h" // orionldPutAttribute #include "orionld/dds/kjTreeLog.h" // kjTreeLog2 #include "orionld/dds/ddsConfigTopicToAttribute.h" // ddsConfigTopicToAttribute @@ -133,4 +134,8 @@ void ddsNotification(const char* typeName, const char* topicName, const char* js // Except of course, if it is registered and exists elsewhere // orionldPutAttribute(); + + // Do what's needed from the function requestCompleted + if (orionldState.alterations != NULL) + orionldAlterationsTreat(orionldState.alterations); } diff --git a/src/lib/orionld/notifications/notificationSend.cpp b/src/lib/orionld/notifications/notificationSend.cpp index 868e5f641c..d3ed169514 100644 --- a/src/lib/orionld/notifications/notificationSend.cpp +++ b/src/lib/orionld/notifications/notificationSend.cpp @@ -582,7 +582,7 @@ static KjNode* notificationTree(OrionldAlterationMatch* matchList) apiEntityP = matchP->altP->finalApiEntityP; // Temporary !!! // If the entity is already in "data", and, it's not a BATCH Operation, skip - already there - if (orionldState.serviceP->isBatchOp == false) + if ((orionldState.serviceP == NULL) || (orionldState.serviceP->isBatchOp == false)) { KjNode* idP = kjLookup(apiEntityP, "id"); if (idP == NULL) diff --git a/src/lib/orionld/notifications/subCacheAlterationMatch.cpp b/src/lib/orionld/notifications/subCacheAlterationMatch.cpp index b277deeca3..cb2332a3a5 100644 --- a/src/lib/orionld/notifications/subCacheAlterationMatch.cpp +++ b/src/lib/orionld/notifications/subCacheAlterationMatch.cpp @@ -88,11 +88,13 @@ static bool entityIdMatch(CachedSubscription* subP, const char* entityId, int eI // static bool entityTypeMatch(CachedSubscription* subP, const char* entityType, int eItems) { + LM_T(LmtSubCacheMatch, ("Sub '%s': checking entity type", subP->subscriptionId)); for (int ix = 0; ix < eItems; ++ix) { EntityInfo* eiP = subP->entityIdInfos[ix]; const char* eType = eiP->entityType.c_str(); + LM_T(LmtSubCacheMatch, ("Sub '%s': matching incoming entity type '%s' to the subs '%s'", subP->subscriptionId, entityType, eType)); if (strcmp(entityType, eType) == 0) return true; @@ -100,7 +102,7 @@ static bool entityTypeMatch(CachedSubscription* subP, const char* entityType, in return true; } - LM_T(LmtSubCacheMatch, ("Sub '%s': no match due to Entity Type", subP->subscriptionId)); + LM_T(LmtSubCacheMatch, ("Sub '%s': no match due to Entity Type ('%s')", subP->subscriptionId, entityType)); return false; } diff --git a/test/functionalTest/cases/0000_dds/dds_notifications.test b/test/functionalTest/cases/0000_dds/dds_notifications.test index 7e683a9dab..f5cfaf63e6 100644 --- a/test/functionalTest/cases/0000_dds/dds_notifications.test +++ b/test/functionalTest/cases/0000_dds/dds_notifications.test @@ -27,7 +27,7 @@ the test client publishes on DDS, the broker receives DDS notifications and crea $REPO_HOME/scripts/configFile.sh "P1,Camera,urn:ngsi-ld:camera:cam1,shutterSpeed" "P2,Arm,urn:ngsi-ld:arm:arm1,armReach" > $HOME/.orionld $REPO_HOME/scripts/configFile.sh "P1,Camera,urn:ngsi-ld:camera:cam1,shutterSpeed" "P2,Arm,urn:ngsi-ld:arm:arm1,armReach" > $HOME/.ftClient dbInit CB -orionldStart CB -mongocOnly -wip dds +orionldStart CB -mongocOnly -wip dds -t 0-255 ftClientStart -t 0-5000 --SHELL-- @@ -39,9 +39,14 @@ ftClientStart -t 0-5000 # 04. Ask FT to publish an entity urn:E4 on topic 'P4' # 05. Query the broker for all its entities, see all three (urn:ngsi-ld:camera:cam1, urn:ngsi-ld:arm:arm1, and the default entity)) # +# 06. Create a subscription for entity type 'Camera' +# 07. Ask FT to publish an entity urn:E1 on topic 'P1' - to provoke a notification to ftClient +# 08. Ping broker to make sure it's still OK (issue XXX says it dies) +# 09. Dump the ftClient to see the notification +# # Later: -# 06. Kill the broker and empty its databae, then restart the broker again -# 07. Query the broker for all its entities, see all three - should be present due to the DDS discovery +# 11. Kill the broker and empty its databae, then restart the broker again +# 12. Query the broker for all its entities, see all three - should be present due to the DDS discovery # echo "01. Ask FT to publish an entity urn:E1 on topic 'P1'" @@ -93,7 +98,53 @@ echo echo -# echo "06. Kill the broker and empty its database, then restart the broker again" +echo "06. Create a subscription for entity type 'Camera'" +echo "==================================================" +payload='{ + "id": "urn:s1", + "type": "Subscription", + "entities": [ + { + "type": "Camera" + } + ], + "notification": { + "endpoint": { + "uri": "http://127.0.0.1:'${FT_PORT}'/notify" + } + } +}' +orionCurl --url /ngsi-ld/v1/subscriptions --payload "$payload" +echo +echo + + +echo "07. Ask FT to publish an entity urn:E1 on topic 'P1' - to provoke a notification to ftClient" +echo "============================================================================================" +payload='{ + "s": "def" +}' +orionCurl --url '/dds/pub?ddsTopicType=xyz&entityId=urn:E1&entityType=T&ddsTopicName=P1' --port $FT_PORT --payload "$payload" +echo +echo + + +echo "08. Ping broker to make sure it's still OK (issue XXX says it dies)" +echo "===================================================================" +orionCurl --url /ngsi-ld/ex/v1/version +echo +echo + + +echo "09. Dump the ftClient to see the notification" +echo "=============================================" +sleep .5 +orionCurl --url /dump --port $FT_PORT --noPayloadCheck +echo +echo + + +# echo "11. Kill the broker and empty its database, then restart the broker again" # echo "=========================================================================" # brokerStop # dbInit CB > /dev/null @@ -103,7 +154,7 @@ echo # echo -# echo "07. Query the broker for all its entities, see all three - should be present due to the DDS discovery " +# echo "12. Query the broker for all its entities, see all three - should be present due to the DDS discovery " # echo "======================================================================================================" # orionCurl --url /ngsi-ld/v1/entities?local=true # echo @@ -275,7 +326,113 @@ Link: