Example xApp enhancement

Change-Id: I5da8e30f0fc06f4b69746e810fc2dd351401569e
Signed-off-by: Mohamed Abukar <abukar.mohamed@nokia.com>
diff --git a/ci/Dockerfile b/ci/Dockerfile
index 1e2d663..ed8b36f 100755
--- a/ci/Dockerfile
+++ b/ci/Dockerfile
@@ -17,7 +17,7 @@
 #
 #----------------------------------------------------------
 
-FROM nexus3.o-ran-sc.org:10004/o-ran-sc/bldr-ubuntu18-c-go:1.9.0 as xapp-base
+FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu18-c-go:1.9.0 as xapp-base
 RUN apt-get update -y \
     &&apt-get install -y \
     apt-utils \
diff --git a/examples/build/Dockerfile b/examples/build/Dockerfile
index 5d0be6e..7cbc8ac 100755
--- a/examples/build/Dockerfile
+++ b/examples/build/Dockerfile
@@ -18,7 +18,7 @@
 #   platform project (RICP).
 #==================================================================================
 
-FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:4-u18.04-nng as ubuntu-example-xapp
+FROM nexus3.o-ran-sc.org:10002/o-ran-sc/bldr-ubuntu18-c-go:1.9.0 as ubuntu-example-xapp
 
 # Install utilities
 RUN apt update && apt install -y iputils-ping net-tools curl sudo
diff --git a/examples/build/build_example_xapp.sh b/examples/build/build_example_xapp.sh
index 7d1a623..18facc0 100755
--- a/examples/build/build_example_xapp.sh
+++ b/examples/build/build_example_xapp.sh
@@ -22,12 +22,12 @@
 echo "--> build_example_xapp.sh starts"
 
 # Install RMR from deb packages at packagecloud.io
-rmr=rmr_4.2.2_amd64.deb
-wget --content-disposition  https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmr/download.deb
+rmr=rmr_4.5.0_amd64.deb
+wget --content-disposition  https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/$rmr/download.deb
 sudo dpkg -i $rmr
 rm $rmr
-rmrdev=rmr-dev_4.2.2_amd64.deb
-wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/$rmrdev/download.deb
+rmrdev=rmr-dev_4.5.0_amd64.deb
+wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/$rmrdev/download.deb
 sudo dpkg -i $rmrdev
 rm $rmrdev
 
diff --git a/examples/cmd/example-xapp.go b/examples/cmd/example-xapp.go
index acb0b8d..f2ea456 100755
--- a/examples/cmd/example-xapp.go
+++ b/examples/cmd/example-xapp.go
@@ -30,7 +30,6 @@
 
 // This could be defined in types.go
 type ExampleXapp struct {
-	msgChan               chan *xapp.RMRParams
 	stats                 map[string]xapp.Counter
 	rmrReady              bool
 	waitForSdl            bool
@@ -55,25 +54,6 @@
 	}
 }
 
-func (e *ExampleXapp) messageLoop() {
-	for {
-		msg := <-e.msgChan
-		id := xapp.Rmr.GetRicMessageName(msg.Mtype)
-		defer xapp.Rmr.Free(msg.Mbuf)
-
-		xapp.Logger.Info("Message received: name=%s meid=%s subId=%d txid=%s len=%d", id, msg.Meid.RanName, msg.SubId, msg.Xid, msg.PayloadLen)
-
-		switch id {
-		case "RIC_INDICATION":
-			e.handleRICIndication(msg.Meid.RanName, msg)
-		case "RIC_EXAMPLE_MESSAGE":
-			e.handleRICExampleMessage(msg.Meid.RanName, msg)
-		default:
-			xapp.Logger.Info("Unknown Message Type '%d', discarding", msg.Mtype)
-		}
-	}
-}
-
 func (e *ExampleXapp) Subscribe() {
 	// Setup response callback to handle subscription response from SubMgr
 	xapp.Subscription.SetResponseCB(func(resp *clientmodel.SubscriptionResponse) {
@@ -115,8 +95,24 @@
 	}
 }
 
-func (e *ExampleXapp) Consume(rp *xapp.RMRParams) (err error) {
-	e.msgChan <- rp
+func (e *ExampleXapp) Consume(msg *xapp.RMRParams) (err error) {
+	id := xapp.Rmr.GetRicMessageName(msg.Mtype)
+
+	xapp.Logger.Info("Message received: name=%s meid=%s subId=%d txid=%s len=%d", id, msg.Meid.RanName, msg.SubId, msg.Xid, msg.PayloadLen)
+
+	switch id {
+	case "RIC_INDICATION":
+		e.handleRICIndication(msg.Meid.RanName, msg)
+	case "RIC_EXAMPLE_MESSAGE":
+		e.handleRICExampleMessage(msg.Meid.RanName, msg)
+	default:
+		xapp.Logger.Info("Unknown Message Type '%d', discarding", msg.Mtype)
+	}
+
+	defer func() {
+		xapp.Rmr.Free(msg.Mbuf)
+		msg.Mbuf = nil
+	}()
 	return
 }
 
@@ -145,7 +141,6 @@
 	// Inject own REST handler for testing purpose
 	xapp.Resource.InjectRoute("/ric/v1/testing", e.TestRestHandler, "POST")
 
-	go e.messageLoop()
 	xapp.RunWithParams(e, e.waitForSdl)
 }
 
@@ -159,7 +154,6 @@
 func NewExampleXapp(rmrReady bool) *ExampleXapp {
 	metrics := GetMetricsOpts()
 	return &ExampleXapp{
-		msgChan:    make(chan *xapp.RMRParams),
 		stats:      xapp.Metric.RegisterCounterGroup(metrics, "ExampleXapp"),
 		rmrReady:   rmrReady,
 		waitForSdl: xapp.Config.GetBool("db.waitForSdl"),
diff --git a/examples/go.mod b/examples/go.mod
old mode 100644
new mode 100755
index 750f9a8..570e3ec
--- a/examples/go.mod
+++ b/examples/go.mod
@@ -2,10 +2,10 @@
 
 module gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/example-xapp
 
-require gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.6.1
+require gerrit.o-ran-sc.org/r/ric-plt/xapp-frame v0.7.1
 
-replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.6.1
+replace gerrit.o-ran-sc.org/r/ric-plt/xapp-frame => gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.7.1
 
 replace gerrit.o-ran-sc.org/r/ric-plt/sdlgo => gerrit.o-ran-sc.org/r/ric-plt/sdlgo.git v0.5.0
 
-replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.1
+replace gerrit.o-ran-sc.org/r/com/golog => gerrit.o-ran-sc.org/r/com/golog.git v0.0.2
diff --git a/examples/go.sum b/examples/go.sum
index f36f60f..7a9fc76 100644
--- a/examples/go.sum
+++ b/examples/go.sum
@@ -1,10 +1,14 @@
 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 gerrit.o-ran-sc.org/r/com/golog.git v0.0.1 h1:9RfO/Whehaaq5KiJTT7s+YOzmi9mT1C3HktfhwwMEmw=
 gerrit.o-ran-sc.org/r/com/golog.git v0.0.1/go.mod h1:b8YB31U8/4iRpABioeSzGi/YMzOQ/Zq7hrJmmXKqlJk=
+gerrit.o-ran-sc.org/r/com/golog.git v0.0.2 h1:Ix6SgFuzd6yW6Ur6+qDlGhDO65UYs8PiIkeAL1VaQ2o=
+gerrit.o-ran-sc.org/r/com/golog.git v0.0.2/go.mod h1:A7hUL52YQSO4dFIZNcj76XQ09C9PftAe3LyL7kqBnok=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.0 h1:Uvyfuq2jyb1aosy2BEzH1g3pe2gy4sMgpsXlvjVeBzI=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.0/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2 h1:XNfkp3PwZ7pfkPszX7NaX6DzToCGjcWTLbIHYqCFNu0=
 gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.4.2/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
+gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0 h1:OKDsIDlttbaoHwleyjflIWVZPgPvYbDhim6gWF0zf5E=
+gerrit.o-ran-sc.org/r/ric-plt/alarm-go.git/alarm v0.5.0/go.mod h1:AdEWKtERGvOQy9ybLhyhrb9w9LLVn8i9xzTwoR5n4BY=
 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21 h1:eK9nUZOTMJ/EnMpH9bkWtMgOvCn3u4+PNCb9gu10s6w=
 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.21/go.mod h1:QJ1uPPZosGbhxUWpUpeM5fLqFHdnWTrVnvW2DgyOCes=
 gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common v1.0.35 h1:TGXHb4DNY8on+ej4S9VUnk2HibIC/5chDy64OE+bQBQ=
@@ -27,6 +31,8 @@
 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.4.6/go.mod h1:29CdUcCrNEqVBjQWAlgeGrYxSWqSZ4e67xzhuSf6BkI=
 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.6.1 h1:w//eBu78PZNfTgiPD8encOMTfYQUkniNTCoVtQqgE/A=
 gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.6.1/go.mod h1:bjhhEII07w+zPQzyvqTq84TjKQPa6IkcnSyWB1DfGHo=
+gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.7.1 h1:gQOQip8Z3kixjL6SOLaJpzNGkm0J6WqO5EIHK+GjGnk=
+gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.7.1/go.mod h1:MRTeTBLROgTA2t91SXYjTbRsxoOhMMvvkK/ChLVRZUU=
 github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
@@ -69,6 +75,7 @@
 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
 github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
 github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
 github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik=
@@ -214,6 +221,8 @@
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
 github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
+github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
 github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
 github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
@@ -312,3 +321,6 @@
 gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
+k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw=
+k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=