Skip to content

API Docs - v1.0.16

Sinkmapper

text (Sink Mapper)

This extension is a Text to Event input mapper. Transports that accept text messages can utilize this extension to convert the incoming text messages to Siddhi events. Users can use a pre-defined text format where event conversion is carried out without any additional configurations, or use placeholders to map from a custom text message.

Syntax

@sink(..., @map(type="text", event.grouping.enabled="<BOOL>", delimiter="<STRING>", new.line.character="<STRING>")

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
event.grouping.enabled If this parameter is set to true, events are grouped via a delimiter when multiple events are received. It is required to specify a value for the delimiter parameter when the value for this parameter is true. false BOOL Yes No
delimiter This parameter specifies how events are separated when a grouped event is received. This must be a whole line and not a single character. ~~~~~~~~~~ STRING Yes No
new.line.character This attribute indicates the new line character of the event that is expected to be received. This is used mostly when communication between 2 types of operating systems is expected. For example, Linux uses '
' whereas Windows uses '
'as the end of line character.
STRING Yes No

Examples EXAMPLE 1

@sink(type='inMemory', topic='stock', @map(type='text'))
define stream FooStream (symbol string, price float, volume long);

This query performs a default text input mapping. The expected output is as follows:symbol:"WSO2",
price:55.6,
volume:100orsymbol:'WSO2',
price:55.6,
volume:100If event grouping is enabled, then the output is as follows:symbol:'WSO2',
price:55.6,
volume:100
~~~~~~~~~~
symbol:'WSO2',
price:55.6,
volume:100

EXAMPLE 2

@sink(type='inMemory', topic='stock', @map(type='text',  @payload(SensorID : {{symbol}}/{{Volume}},
SensorPrice : Rs{{price}}/=,
Value : {{Volume}}ml?)))

This query performs a custom text mapping. The output is as follows:SensorID : wso2/100,
SensorPrice : Rs1000/=,
Value : 100mlfor the following siddhi event.{wso2,1000,100}

Sourcemapper

text (Source Mapper)

This extension is a text to Siddhi event source mapper. Transports that publish text messages can utilize this extension to convert the incoming text message to Siddhi events. Users can either use the onEventHandlerwhich is a pre-defined text format where event conversion happens without any additional configurations, or specify a regex to map a text message using custom configurations.

Syntax

@source(..., @map(type="text", regex.groupid="<STRING>", fail.on.missing.attribute="<BOOL>", event.grouping.enabled="<BOOL>", delimiter="<STRING>", new.line.character="<STRING>")

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
regex.groupid This parameter specifies a regular expression group. The groupid can be any capital letter (e.g., regex.A,regex.B .. etc). You can specify any number of regular expression groups. In the attribute annotation, you need to map all attributes to the regular expression group with the matching group index. If you need to to enable custom mapping, it is required to specifythe matching group for each and every attribute. STRING No No
fail.on.missing.attribute This parameter specifies how unknown attributes should be handled. If it is set totrue a message is dropped if its execution fails, or if one or more attributes do not have values. If this parameter is set to false, null values are assigned to attributes with missing values, and messages with such attributes are not dropped. true BOOL Yes No
event.grouping.enabled This parameter specifies whether event grouping is enabled or not. To receive a group of events together and generate multiple events, this parameter must be set to true. false BOOL Yes No
delimiter This parameter specifies how events must be separated when multiple events are received. This must be whole line and not a single character. ~~~~~~~~~~ STRING Yes No
new.line.character This attribute indicates the new line character of the event that is expected to be received. This is used mostly when communication between 2 types of operating systems is expected. For example, Linux uses '
' as the end of line character whereas windows uses '
'.
STRING Yes No

Examples EXAMPLE 1

@source(type='inMemory', topic='stock', @map(type='text'))
define stream FooStream (symbol string, price float, volume long);

This query performs a default text input mapping. The expected input is as follows:symbol:"WSO2",
price:55.6,
volume:100ORsymbol:'WSO2',
price:55.6,
volume:100If group events is enabled then input should be as follows,symbol:'WSO2',
price:55.6,
volume:100
~~~~~~~~~~
symbol:'WSO2',
price:55.6,
volume:100

EXAMPLE 2

@source(type='inMemory', topic='stock', @map(type='text', fail.on.unknown.attribute = 'true', regex.A='(\w+)\s([-0-9]+)',regex.B='volume\s([-0-9]+)', @attributes(symbol = 'A[1]',price = 'A[2]',volume = 'B' )

This query performs a custom text mapping. The expected output is as follows:wos2 550 volume 100