When stream event Join in WSO2 CEP each output event produsing two times - complex-event-processing

I am using WSO2 CEP embedded inside the WSO2 DAS
For the following Execution plan
#Import('RelatedStream:1.0.0')
define stream rs (ID string, product string, uc1 string, state string, brand string, model string, type string, tweet string, rtID string);
#Import('InputStream:1.0.0')
define stream ins (ID string, product string, uc1 string, state string, brand string, model string, type string, tweet string);
#Export('matchingStream:1.0.0')
define stream ms (rID string, rproduct string, ruc1 string, rstate string, rbrand string, rmodel string, rtype string, hID string, hproduct string, huc1 string, hstate string, hbrand string, hmodel string, htype string);
from ins#window.time(2 sec) as R
join rs#window.length(1) as H
on R.product == H.product and R.brand==H.brand and R.type==H.type and R.model==H.model and R.state!=H.state and R.ID==H.rtID
select R.ID as rID, R.product as rproduct , R.uc1 as ruc1 , R.state as rstate, R.brand as rbrand , R.model as rmodel , R.type as rtype ,H.ID as hID , H.product as hproduct , H.uc1 as huc1 , H.state as hstate , H.brand as hbrand, H.model as hmodel , H.type as htype
insert all events into ms;
Every output event producing two times with same values
The Event Message Tracer log is below
Stream one (InputStream)
08:23:21,845 [-] [DataBridge-Core-pool-1-thread-3] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : InputStream:1.0.0 (ins), before processing _Event{timestamp=1464144801440, data=[27, phone, g1, sell, samsung, galaxy note, type, Use UM10 to get 10% OFF #unlockyourphone Galaxy Note 6 will reportedly be the first Samsung phone to feature US... sell], isExpired=false} (Sanitized)
Stream two(RelatedStream)
08:23:21,974 [-] [DataBridge-Core-pool-1-thread-2] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801943, data=[5, phone, g1, sell, samsung, iphone 4s, type, White 3 USB Port Car Charger Adapter For iPhone 4S 5S 5C 6 6S iPad Samsung Phone - Bid Now? sell, 27], isExpired=false} (Sanitized)
08:23:21,998 [-] [DataBridge-Core-pool-1-thread-4] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801944, data=[11, phone, g1, buy, samsung, galaxy s4, type, #cellular #deals Samsung Galaxy S4 SCH-I545 16GB Verizon AT&T GSM UNLOCKED Cell Phone RF buy, 27], isExpired=false} (Sanitized)
08:23:22,030 [-] [DataBridge-Core-pool-1-thread-5] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801944, data=[13, phone, g1, sell, samsung, galaxy note, type, UNLOCKED T-Mobile Samsung Galaxy Note 3 SM-N900T 4G LTE GSM 32GB Smart Phone sell, 27], isExpired=false} (Sanitized)
08:23:22,031 [-] [DataBridge-Core-pool-1-thread-5] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801944, data=[18, phone, g1, sell, samsung, galaxy s6, type, Cell Phones : New Samsung Galaxy S6 Edge SM-G925F 5.1'' 16MP (FACTORY UNLOCKED) 32GB Phone sell, 27], isExpired=false} (Sanitized)
08:23:22,031 [-] [DataBridge-Core-pool-1-thread-5] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801944, data=[19, phone, g1, sell, samsung, galaxy s4, type, #cellular #deals Samsung i545 Galaxy S4 16GB Verizon 13MP Camera WiFi Cell Phone sell, 27], isExpired=false} (Sanitized)
08:23:22,031 [-] [DataBridge-Core-pool-1-thread-5] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801944, data=[1, phone, g1, sell, samsung, galaxy s6, type, Cell Phone USA : New Samsung Galaxy S6 Edge SM-G925F 5.1'' 16MP (FACTORY UNLOCKED) 32GB Ph? sell, 27], isExpired=false} (Sanitized)
08:23:22,033 [-] [DataBridge-Core-pool-1-thread-5] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801944, data=[14, phone, g1, sell, samsung, galaxy note, type, Galaxy Note 6 will reportedly be the first Samsung phone to feature USB-C - sell, 27], isExpired=false} (Sanitized)
08:23:22,034 [-] [DataBridge-Core-pool-1-thread-5] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801945, data=[16, phone, g1, buy, samsung, galaxy note, type, #unlocksquare Galaxy Note 6 will reportedly be the first Samsung phone to feature USB-C buy, 27], isExpired=false} (Sanitized)
08:23:22,035 [-] [DataBridge-Core-pool-1-thread-5] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801945, data=[17, phone, g1, buy, samsung, galaxy s5, type, Cell Phone USA : NEW T-Mobile Protective Cover/Holster For Samsung Galaxy S5 Case Kickstan? buy, 27], isExpired=false} (Sanitized)
08:23:22,035 [-] [DataBridge-Core-pool-1-thread-5] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : RelatedStream:1.0.0 (rs), before processing _Event{timestamp=1464144801945, data=[15, phone, g1, buy, samsung, galaxy s6, type, Cell Phone USA : Samsung Galaxy S6 SM-G920F 32GB Unlocked 16MP Smartphone #4422 buy, 27], isExpired=false} (Sanitized)
Output Stream (matchingStream)
08:23:22,041 [-] [Siddhi-R_H_Match-executor-thread-1] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : matchingStream:1.0.0 (ms), after processing _[Event{timestamp=1464144801945, data=[27, phone, g1, sell, samsung, galaxy note, type, 16, phone, g1, buy, samsung, galaxy note, type], isExpired=false}] (Sanitized)
08:23:22,120 [-] [Siddhi-R_H_Match-executor-thread-1] INFO TenantId : -1234, Event Processor : R_H_Match, Event Stream : matchingStream:1.0.0 (ms), after processing _[Event{timestamp=1464144802037, data=[27, phone, g1, sell, samsung, galaxy note, type, 16, phone, g1, buy, samsung, galaxy note, type], isExpired=false}] (Sanitized)

When you insert all events into the output event stream, it includes both current events (incoming events) and expired events (emitted by the windows after timing out or when window length is exceeded). Hence there is a possibility of getting duplicates.
If your requirement is to trigger an output using incoming events of 'rs' stream, you can try something like following: (with current events)
from ins#window.time(2 sec) as R
join rs#window.length(0) as H
on R.product == H.product and R.brand==H.brand and R.type==H.type and R.model==H.model and R.state!=H.state and R.ID==H.rtID
select R.ID as rID, R.product as rproduct , R.uc1 as ruc1 , R.state as rstate, R.brand as rbrand , R.model as rmodel , R.type as rtype ,H.ID as hID , H.product as hproduct , H.uc1 as huc1 , H.state as hstate , H.brand as hbrand, H.model as hmodel , H.type as htype
insert current events into ms;

Related

google.maps.places.Autocomplete not selecting country in phone

autocomplete[name] = new google.maps.places.Autocomplete(document.getElementById(name) ,
{
types: ['geocode'] ,
componentRestrictions: {country: 'SG'}
});
This code is working in laptop, but in mobile phone, it is not using componentRestrictions to SG or Singapore only. It is showing result for whole world.

Telemetry data (in array format) gets segragated into multiple individual messages by ThingsBoard's rule engine?

I have a BLE gateway which scans nearby BLE beacons and send the data to ThingsBoard via MQTT every n seconds.
That is, in the payload, it contains an array with data of each BLE beacons.
[{
id: 1001,
rssi: -50
}, {
id: 1002,
rssi: -60
}]
The problem is that ThingsBoard upon receiving this payload, it does not pass the whole thing to the rule engine's "INPUT", instead it separates the payload into 2 individual elements. That is, it appears that ThingsBoard has received 2 separate messages.
{
id: 1001,
rssi: -50
}
and
{
id: 1002,
rssi: -60
}
What I expect is that ThingsBoard does not separate the payload into individual elements.

Get card data with nfc_manager?

I'm using the nfc_manager package to scan my transportation card. I've found similar apps on the playstore that were able to get transaction history, card serial number and other details from the app. However, using the nfc_manager package, I've only been able to obtain isodep and nfcB data. Below is the printed outputs of the isodep and nfcb data.
{identifier: [123, 123,123,123], hiLayerResponse: [], historicalBytes: null, isExtendedLengthApduSupported: true, maxTransceiveLength: 12312, timeout: 123}
{identifier: [123,123,123,123], applicationData: [0, 0, 0, 0], maxTransceiveLength: 123, protocolInfo: [123,123,123]}
(the values were changed to 123 because I'm not sure if the data is sensitive)
How do I go about obtaining data such as transportation history and all that from the data I have here? Or is that a limitation of the package?
here is the code used:
NfcManager.instance.startSession(onDiscovered: (NfcTag tag) async {
print(tag.data['isodep']);
print(tag.data['nfcb']);
IsoDep isoDep = IsoDep.from(tag);
print(isoDep.historicalBytes);
});
Thank you for your help!

Set Modbus Register via CEP operation

I wanted to set the holding registers of a Modbus Relay to toggle devices.
I know the parameters, registers and values which have to be set, but the CEP operation is not working.
I have tried different methods of indicating the objects.
select
"PENDING" as status,
9716636 as deviceId,
{
"deviceName", "Modbus Relais",
"description", "Relais-Status auf CLOSE setzen",
"c8y_setRegister.input", "false",
"c8y_setRegister.address", "1",
"c8y_setRegister.startBit", "0",
"c8y_setRegister.noBits", "16",
"c8y_setRegister.ipAddress", "",
"c8y_setRegister.value", "256",
"c8y_setRegister.register", "2"
} as fragments
from MeasurementCreated e
where getNumber(e, "c8y_Temperaturecy.T.value") > 2
but the register is not being set
solved by myself: c8y_SetRegister --> s needs to be uppercase

How the check the order status in SL?

This is my code to place a baremetal server. The placeOrder function will return the order receipt. Then I check the order status from SL portal and it was changed to approved.
My question is do we have any API's to check when the baremetal server will be provisioned? We need to configure it after the baremetal server provisioned.
var sess = session.New(userName, apiKey, endpoint)
accountService := services.GetAccountService(sess)
order := datatypes.Container_Product_Order{
Quantity: sl.Int(1),
Hardware: []datatypes.Hardware{
{
Hostname: sl.String("test10g"),
Domain: sl.String("example.com"),
PrimaryBackendNetworkComponent: &datatypes.Network_Component{
NetworkVlan: &datatypes.Network_Vlan{Id: sl.Int(2288425)},
},
},
},
Location: sl.String("DALLAS10"),
PackageId: sl.Int(911), // Single E3-1270 v6
Prices: []datatypes.Product_Item_Price{
{Id : sl.Int(206249)}, // server
{Id : sl.Int(209427)}, // ram
{Id : sl.Int(175789)}, // os
{Id : sl.Int(32927)}, // disk controller
{Id : sl.Int(49761)}, // disk 0
{Id : sl.Int(50359)}, // bandwidth
{Id : sl.Int(35686)}, // portSpeed
{Id : sl.Int(34241)}, // monitoring
{Id : sl.Int(34996)}, // response
{Id : sl.Int(33483)}, // vpn management
{Id : sl.Int(35310)}, // vulnerabilityScanner
{Id : sl.Int(34807)}, // pri_ip_address
{Id : sl.Int(32500)}, // notification
{Id : sl.Int(25014)}, // remote_management
},
}
service := services.GetProductOrderService(sess)
receipt, err := service.PlaceOrder(&order, sl.Bool(false))
// Any functions to check the order status here?
// Need some code to waiting for the baremetal server to become ready.
You need to use the SoftLayer_Hardware::getObject method and make it query the server repeatedly until the "provisionDate" parameter is filled in, once it is filled then the provisioning completed.
Fore more information see the following:
How can I reliably track the status of a newly provisioned BareMetal server using the REST API
what is the API (REST) to find out whether bare metal server provisioned or not?
https://softlayer.github.io/reference/services/SoftLayer_Virtual_Guest/getLastTransaction/