DevLost

A developer lost in the mountains

Cygnus and the multitenant option of Orion context Broker: how to make it work

Some time ago I posted this question on Stackoverflow:

how to make the multitenant option of Orion context Broker working with Cygnus connector?

Since I was not receiving any answer and I was getting impatient :-) I squezeed my brain to look for a solution on my own and when I found out the solution I answered to the question on Stackoverflow.

All done? Yes, but I think it's worthwhile to add more pieces of the puzzle and share more of our experience with FIWARE GEs.

The fact is that, for our Smart Attention Project, we need to save historical data whereas Orion Context Broker keeps just the last data received. One of the suggested methods is to persist data into a mySql instance using the Cygnus connector bundled with Orion.

As we have to manage several mesh networks (from 1 to 10 or even more) that use the same entities/attributes/subscriptions definitions we wanted to leverage the multitenant option of Orion Context Broker in order separate data coming from different networks. According to the user and programmers guide of Orion, a specific HTTP header "Fiware-Service" should be added to each HTTP Request coming from the gateways of the mesh networks in order to persist data into different databases.

Furthermore, if you want to store the information for each entity in a different table, you need an additional header: "'Fiware-ServicePath".

In brief, if you want different DBs for different scenarios and different tables for different NGSI entities you should add these headers:

'Fiware-Service: DB_name'

'Fiware-ServicePath: table_prefix'

then, you should obtain:

dbName=DB_name
tableName=table_prefix_<entityId>_<entityType
>

But, if you do so, probably you won't be able to get it work. Why? Just because Orion documentation does not clarify that you have to include these headers in all the NGSI REST call to Orion Context Broker, not just once or just for the registration of an entity.

If you already have your entities registered, simply delete them (delete also the subscriptions) and follow these steps to make things work:

1) Register your entity with a POST /NGSI10/updateContext call specifying "APPEND" updateAction in payload and including "fiware-service" and "fiware-servicepath" headers.

2) Make a subscription (/ngsi10/subscribeContext) to Orion including exactly the same headers above

3) Update your entity including always the headers above