siddhi

[siddhi]How Can I use siddhi stream in multi files


I met a problem when I use siddhi, the problem is that I have too much streams in one .siddhi file.The siddhql looks terrible and it's hard to mainten. Does Anyone know how can I put siddhi streams in diffrent siddhi files? And these streams in diffrent files still can send info to stream in other file.Please help. Thanks for your time


Solution

  • Yes, you can use Inmemory source and sinks to send events between two different siddhi files i.e two different siddhi app runtimes, https://siddhi.io/en/v5.1/docs/api/latest/#inmemory-source

    @sink(type='inMemory', topic='Stocks', @map(type='passThrough'))
    define stream StocksStream (symbol string, price float, volume long);
    

    The above sends out to the specific topic

    @source(type='inMemory', topic='Stocks', @map(type='passThrough'))
    define stream StocksStream (symbol string, price float, volume long);
    

    The above receives from specific topic