0

I'm new on Stackoverflow even if I solved a lot of problems with your hints. Now I have a problem I have not found the solution. I'm developing a pushing service using the WSO2 CEP and the GCM. CEP handles the subscribe/unsubscribe requests and the push events. The subscriptions keys are stored on my own server using MySQL together with other info. My problems come with the subscribe step. This step has to handle either the new subscriptions (insert) and existing subscription (update). To make the operation easier, I decided to normalise the two operations by deleting and inserting the records (even if the record could be already on the DB). To handle this, I developed an execution plan using Siddhi. The plan defines 2 streams: an event stream and a table stream linked to a MySQL table. In the Execution Plan, first a delete is done using the key taken from the event and after a new record is inserted using the info contained into the event. But it seems that the sequence of the operations (delete and insert) differs, so sometimes I found two or more records with the same GCM key on my server. I applied a workaround by adding a unique constraint on the table, but I'd like to know if there is a way to fix a deterministic order on the Siddhi operations.

Regards

Michele de Rosa

Community
  • 1
  • 1
  • Welcome to SO.com you might want to read this topic on [meta.SE.com](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – martijnn2008 Feb 25 '16 at 12:37

1 Answers1

0

Since you are using same stream to update and insert to table there is no guarantee that delete query will execute earlier. All queries which are receiving from same stream will execute in parallel and we do not have any control over order. Only way we can enforce order is by either introducing a query pipeline or using a pattern query to delay events.

However your requirement you can use newly added insert overwrite functionality in event tables. This will automatically handle your requirement of updating if exists and inserting otherwise.

Hope this helps!!

Thanks Tishan

Tishan
  • 890
  • 6
  • 11
  • Thank you very much for your hint. Actually I'm using CEP 4.0.0 and I saw that the insert overwrite comes with CEP 4.1.0, so I probably will use it in the near future. At the moment I have some problems (not solved yet) with the import of trusted certificate configuration to work in HTTPS. Very boring issue!!! – Michele de Rosa Mar 08 '16 at 09:26
  • Set your client-truststore to /repository/resources/security/client-truststore.jks which is the default truststore for WSO2 products. If you are having trouble importing your own certificate, try https://docs.wso2.com/display/Carbon444/Creating+New+Keystores#CreatingNewKeystores-Addingthepublickeytoclient-truststore.jks – Tishan Mar 09 '16 at 11:30
  • I tried the "insert overwrite" operation but it seems not working in my case. I use only one stream attribute to decide wether applying insert nor update. The "insert overwrite" seems to work if you use the whole set of stream attributes. Please, let me know if it is correct. – Michele de Rosa Mar 21 '16 at 16:01