From ccda93af48868821c4d9b253d96c9a41926ec5e3 Mon Sep 17 00:00:00 2001 From: DanB Date: Sun, 24 Jan 2016 18:11:01 +0100 Subject: [PATCH] Diameter - Fix pubsub issue --- agents/dmtagent.go | 3 ++- agents/dmtagent_it_test.go | 2 +- data/conf/samples/dmtagent/cgrates.json | 1 + .../samples/dmtagent/diameter_processors.json | 20 +++++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/agents/dmtagent.go b/agents/dmtagent.go index f111412f8..dec21d553 100644 --- a/agents/dmtagent.go +++ b/agents/dmtagent.go @@ -23,6 +23,7 @@ import ( "strconv" "github.com/cgrates/cgrates/config" + "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/utils" "github.com/cgrates/rpcclient" "github.com/fiorix/go-diameter/diam" @@ -99,7 +100,7 @@ func (self DiameterAgent) processCCR(ccr *CCR, reqProcessor *config.DARequestPro return nil } var reply string - if err := self.pubsubs.Call("PubSubV1.Publish", evt, reply); err != nil { + if err := self.pubsubs.Call("PubSubV1.Publish", engine.CgrEvent(evt), &reply); err != nil { utils.Logger.Err(fmt.Sprintf(" Processing message: %+v failed publishing event, error: %s", ccr.diamMessage, err)) return nil } diff --git a/agents/dmtagent_it_test.go b/agents/dmtagent_it_test.go index 15b3b0bd0..25f7de3a0 100644 --- a/agents/dmtagent_it_test.go +++ b/agents/dmtagent_it_test.go @@ -455,7 +455,7 @@ func TestDmtAgentDryRun1(t *testing.T) { ccr.NewAVP(avp.OriginHost, avp.Mbit, 0, datatype.DiameterIdentity("CGR-DA")) ccr.NewAVP(avp.OriginRealm, avp.Mbit, 0, datatype.DiameterIdentity("cgrates.org")) ccr.NewAVP(avp.AuthApplicationID, avp.Mbit, 0, datatype.Unsigned32(4)) - ccr.NewAVP(avp.ServiceContextID, avp.Mbit, 0, datatype.UTF8String("dryrun1")) // Match specific DryRun profile + ccr.NewAVP(avp.ServiceContextID, avp.Mbit, 0, datatype.UTF8String("pubsub1")) // Match specific DryRun profile ccr.NewAVP(avp.CCRequestType, avp.Mbit, 0, datatype.Enumerated(4)) ccr.NewAVP(avp.CCRequestNumber, avp.Mbit, 0, datatype.Unsigned32(0)) ccr.NewAVP(avp.EventTimestamp, avp.Mbit, 0, datatype.Time(time.Date(2016, 1, 5, 11, 30, 10, 0, time.UTC))) diff --git a/data/conf/samples/dmtagent/cgrates.json b/data/conf/samples/dmtagent/cgrates.json index ff1387e85..93fe0df45 100644 --- a/data/conf/samples/dmtagent/cgrates.json +++ b/data/conf/samples/dmtagent/cgrates.json @@ -53,6 +53,7 @@ "diameter_agent": { "enabled": true, + "pubsubs": "internal", }, } diff --git a/data/conf/samples/dmtagent/diameter_processors.json b/data/conf/samples/dmtagent/diameter_processors.json index 4adf3990e..465dba558 100644 --- a/data/conf/samples/dmtagent/diameter_processors.json +++ b/data/conf/samples/dmtagent/diameter_processors.json @@ -21,6 +21,26 @@ {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "300"}, ], }, + { + "id": "pubsub1", // formal identifier of this processor + "dry_run": true, // do not send the events to SMG, just log them + "publish_event": true, + "request_filter": "Service-Context-Id(pubsub1)", // filter requests processed by this processor + "continue_on_success": false, // continue to the next template if executed + "ccr_fields":[ // import content_fields template, tag will match internally CDR field, in case of .csv value will be represented by index of the field value + {"tag": "TOR", "field_id": "ToR", "type": "*composed", "value": "^*sms", "mandatory": true}, + {"tag": "OriginID", "field_id": "OriginID", "type": "*composed", "value": "Session-Id", "mandatory": true}, + {"tag": "RequestType", "field_id": "RequestType", "type": "*composed", "value": "^*prepaid", "mandatory": true}, + {"tag": "Direction", "field_id": "Direction", "type": "*composed", "value": "^*out", "mandatory": true}, + {"tag": "Tenant", "field_id": "Tenant", "type": "*composed", "value": "^cgrates.org", "mandatory": true}, + {"tag": "Category", "field_id": "Category", "type": "*composed", "value": "^call", "mandatory": true}, + {"tag": "SetupTime", "field_id": "SetupTime", "type": "*composed", "value": "Event-Timestamp", "mandatory": true}, + {"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", "value": "Event-Timestamp", "mandatory": true}, + ], + "cca_fields":[ // fields returned in CCA + {"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "300"}, + ], + }, { "id": "*default", // formal identifier of this processor "dry_run": false, // do not send the events to SMG, just log them