Problem Statement
Rules Engine can dissect data and send it out to multiple added destinations. For example,
if the data looks as follows,
{u'Data':
{u'Auto':
{u'Color':u'Aquamarine', u'Model': u'Charger',
u'Ticket':
{u'Date': u'9/2/2015', u'City': u'Vanderhoof', u'Misc': None}},
u'PartnerID': 2006
}
}
Send Color information to a Partner and Model to a Vendor.
So Partner sees
{"SiteSensor":{"Data":{"Auto":{"Model":"Charger"}}}}
And Vendor sees
{"SiteSensor":{"Data":{"Auto":{"Color":"Aquamarine"}}}}
How is it done?
First, identify an External RabbitMQ Broker that is reachable over a public IP or URL.
Create 2 exchanges, VendorData and PartnerData in that broker.
Create 2 Queues, VendorQ and bind to VendorData, PartnerQ and bind to PartnerData.
Add the 2 exchanges to the Data Destination in Kinetic.
Generate Data
1. Create a Device behind an existing Gateway (does not matter if GW is online).
2. Give the device a name - say. SiteSensor.
3. Copy the User/Password/Topic/Broker and add Cert to it and generate following data and publish it. Pick your way to publish this data, for example you can use mosquitto_pub.
{"Data":{"PartnerID":2012,"Auto":{"Color":null,"Model":"XC90","Ticket":{"Date":"10/9/2014","Misc":null,"City":"Anyuan"}}}},
{"Data":{"PartnerID":1997,"Auto":{"Color":"Puce","Model":"XK Series","Ticket":{"Date":"5/18/2016","Misc":null,"City":"Val-d'Or"}}}},
{"Data":{"PartnerID":1999,"Auto":{"Color":"Teal","Model":"LS","Ticket":{"Date":"9/5/2015","Misc":null,"City":"Araguari"}}}},
{"Data":{"PartnerID":2003,"Auto":{"Color":"Aquamarine","Model":"S40","Ticket":{"Date":"11/21/2015","Misc":null,"City":"Akhmīm"}}}},
{"Data":{"PartnerID":2012,"Auto":{"Color":"Crimson","Model":"Impala","Ticket":{"Date":"3/23/2015","Misc":null,"City":"Megáli Khóra"}}}},
{"Data":{"PartnerID":1966,"Auto":{"Color":"Green","Model":"Corvette","Ticket":{"Date":"12/6/2016","Misc":null,"City":"Šuto Orizare"}}}},
{"Data":{"PartnerID":2002,"Auto":{"Color":"Crimson","Model":"Xterra","Ticket":{"Date":"10/19/2015","Misc":null,"City":"Saint-Denis"}}}},
{"Data":{"PartnerID":2010,"Auto":{"Color":"Green","Model":"Sportage","Ticket":{"Date":"6/8/2016","Misc":null,"City":"Xinzhou"}}}},
{"Data":{"PartnerID":2010,"Auto":{"Color":"Aquamarine","Model":"Sprinter","Ticket":{"Date":"12/14/2014","Misc":null,"City":"Gondang"}}}},
{"Data":{"PartnerID":2008,"Auto":{"Color":"Red","Model":"S40","Ticket":{"Date":"2/12/2015","Misc":null,"City":"Fengyang"}}}},
{"Data":{"PartnerID":1968,"Auto":{"Color":"Khaki","Model":"GT500","Ticket":{"Date":"1/7/2015","Misc":null,"City":"Sandweiler"}}}},
{"Data":{"PartnerID":2000,"Auto":{"Color":"Blue","Model":"Seville","Ticket":{"Date":"3/20/2017","Misc":null,"City":"Barkā’"}}}},
{"Data":{"PartnerID":2005,"Auto":{"Color":"Maroon","Model":"Mazda6","Ticket":{"Date":"4/27/2017","Misc":null,"City":"Djibo"}}}},
{"Data":{"PartnerID":1997,"Auto":{"Color":"Mauv","Model":"Hombre Space","Ticket":{"Date":"10/10/2016","Misc":null,"City":"Pasadena"}}}}
4. Create Rules.
Click Add Rule Set.
Paste the following Rules.
SEND TO "Internal Broker" TOPIC "SelectFields" JSON SiteSensor.Data.Auto.Color, SiteSensor.Data.Auto.Model;
SEND TO "PartnerData" TOPIC "Partner" JSON SiteSensor.Data.Auto.Color;
SEND TO "VendorData" TOPIC "Partner" JSON SiteSensor.Data.Auto.Model;
5. Create a Policy that uses this Rule Set.
DO NOT SELECT DESTINATIONS. Then you will see filtered and unfiltered data show up at those destinations.
Rule SEND TO will take care of sending it out.
6. Check your RabbitMQ output in the queues
Comments
0 comments
Please sign in to leave a comment.