Appending Receiver endpoint in routes if RX message type is same

Signed-off-by: wahidw <abdulwahid.w@nokia.com>
Change-Id: I51c6f9b2be95c1bc3a3b6ebca602c611b3d8e33f
diff --git a/RELNOTES b/RELNOTES
index 8a1ed82..96deaaa 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -1,3 +1,6 @@
+### v0.6.8
+* Appending Receiver endpoint in routes if RX message type is same
+
 ### v0.6.7
 * Publish Route only once to the endpoint that requests it. Periodic/Event based distribution will be done only for the process with RMR Control Port 4561.
 
diff --git a/cmd/rtmgr.go b/cmd/rtmgr.go
index af0aba1..1234622 100644
--- a/cmd/rtmgr.go
+++ b/cmd/rtmgr.go
@@ -68,17 +68,17 @@
 	rtmgr.Mtype = make(rtmgr.MessageTypeList)
 	rtmgr.Rtmgr_ready = false
 
-// RMR thread is starting port: 4560
+	// RMR thread is starting port: 4560
 	c := nbi.NewControl()
 	go c.Run()
 
-// Waiting for RMR to be ready
+	// Waiting for RMR to be ready
 	time.Sleep(time.Duration(2) * time.Second)
 	for xapp.Rmr.IsReady() == false {
-	        time.Sleep(time.Duration(2) * time.Second)
+		time.Sleep(time.Duration(2) * time.Second)
 	}
 
-	dummy_whid := int(xapp.Rmr.Openwh("localhost:4560"))
+	dummy_whid := int(xapp.Rmr.Openwh("rtmgr:4560"))
 	xapp.Logger.Info("created dummy Wormhole ID for routingmanager and dummy_whid :%d", dummy_whid)
 
 	nbi.Serve()
diff --git a/container-tag.yaml b/container-tag.yaml
index 041cba7..5bb3ab8 100644
--- a/container-tag.yaml
+++ b/container-tag.yaml
@@ -2,4 +2,4 @@
 # By default this file is in the docker build directory,
 # but the location can configured in the JJB template.
 ---
-tag: 0.6.7
+tag: 0.6.8
diff --git a/pkg/rpe/rpe.go b/pkg/rpe/rpe.go
index 4097ae0..3a3eac1 100644
--- a/pkg/rpe/rpe.go
+++ b/pkg/rpe/rpe.go
@@ -184,31 +184,49 @@
 
 }
 
-
 func (r *Rpe) generateXappToXappRoutes(RecvxAppEp *rtmgr.Endpoint, endPointList rtmgr.Endpoints, routeTable *rtmgr.RouteTable) {
 	xapp.Logger.Debug("rpe.generateXappToXappRoutes invoked")
 
 	for _, rxmsg := range RecvxAppEp.RxMessages {
 
 		var src_present bool
+		identicalMsg := false
+		var RxGrp []rtmgr.Endpoint
 		xapp.Logger.Debug("RecvxAppEp.RxMessages Endpoint: %v, xAppType: %v and rxmsg: %v ", RecvxAppEp.Name, RecvxAppEp.XAppType, rxmsg)
-		if (rxmsg != "RIC_SUB_RESP" && rxmsg != "RIC_SUB_FAILURE" && rxmsg != "RIC_SUB_DEL_RESP" && rxmsg != "RIC_SUB_DEL_FAILURE" && rxmsg != "RIC_INDICATION" && rxmsg != "RIC_CONTROL_ACK" && rxmsg != "RIC_CONTROL_FAILURE" && rxmsg != "A1_POLICY_REQ") {
+		if rxmsg != "RIC_SUB_RESP" && rxmsg != "RIC_SUB_FAILURE" && rxmsg != "RIC_SUB_DEL_RESP" && rxmsg != "RIC_SUB_DEL_FAILURE" && rxmsg != "RIC_INDICATION" && rxmsg != "RIC_CONTROL_ACK" && rxmsg != "RIC_CONTROL_FAILURE" && rxmsg != "A1_POLICY_REQ" {
 			for _, SrcxAppEp := range endPointList {
 				if SrcxAppEp.XAppType != sbi.PlatformType && (len(SrcxAppEp.TxMessages) > 0) && SrcxAppEp.Name != RecvxAppEp.Name {
 					for _, txmsg := range SrcxAppEp.TxMessages {
-							if (rxmsg == txmsg) {
-								r.addRoute(rxmsg, SrcxAppEp, RecvxAppEp, routeTable, -1, "")
-								src_present = true
-								break
-							}
+						if rxmsg == txmsg {
+							r.addRoute(rxmsg, SrcxAppEp, RecvxAppEp, routeTable, -1, "")
+							src_present = true
+							break
+						}
 					}
 				}
 			}
-			if src_present == false {
+			for _, SrcxAppEp := range endPointList {
+
+				if SrcxAppEp.XAppType != sbi.PlatformType && (len(SrcxAppEp.RxMessages) > 0) && SrcxAppEp.Name != RecvxAppEp.Name {
+					for _, newrxmsg := range SrcxAppEp.RxMessages {
+						if newrxmsg == rxmsg {
+							RxGrp = append(RxGrp, *SrcxAppEp)
+							identicalMsg = true
+						}
+					}
+				}
+			}
+			if src_present == false && identicalMsg == false {
+				xapp.Logger.Debug("Message type %v,for SrcxAppEp.Name %v", rxmsg, RecvxAppEp)
 				r.addRoute(rxmsg, nil, RecvxAppEp, routeTable, -1, "")
 			}
+			if identicalMsg == true {
+				xapp.Logger.Debug("Appending Message type %v,for SrcxAppEp.Name %v", rxmsg, RecvxAppEp)
+				RxGrp = append(RxGrp, *RecvxAppEp)
+				r.addRoute_rx_list(rxmsg, nil, RxGrp, routeTable, -1, "")
+				return
+			}
 		}
-
 	}
 }
 
@@ -235,7 +253,7 @@
 				r.addRoute("RIC_CONTROL_FAILURE", nil, xAppEp, routeTable, subscription.SubID, "")
 			}
 		} else {
-				xapp.Logger.Error("generateSubscriptionRoutes xAppEp is nil, xApp UUID: %v", xAppUuid)
+			xapp.Logger.Error("generateSubscriptionRoutes xAppEp is nil, xApp UUID: %v", xAppUuid)
 		}
 	}
 }