Skip to main content

passThrough (Source Mapper)

This input mapper allows you to convert protobuf messages into Events. To work with this input mapper you have to add auto-generated protobuf classes to the project classpath. When you use this input mapper, you can either define stream attributes as the same names as the protobuf message attributes or you can use custom mapping to map stream definition attributes with the protobuf attributes. When you use this mapper with streamprocessor-io-grpc you don't have to provide the protobuf message class in the class parameter.

Syntax

CREATE SOURCE <NAME> WITH (map.type="protobuf", class="<STRING>")

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
classThis specifies the class name of the protobuf message class, If sink type is grpc then it's not necessary to provide this field.-STRINGYesNo

Example 1

CREATE SOURCE FooStream WITH (type='inMemory', topic='test01', map.type='protobuf', map.class='io.streamprocessor.extension.map.protobuf.autogenerated.Request') (stringValue string, intValue int,longValue long,booleanValue bool,floatValue float,doubleValue double);

This will convert the io.streamprocessor.extension.map.protobuf.autogenerated.Request protobuf messages into stream processor events.

Example 2

CREATE SOURCE FooStream WITH (type='grpc', receiver.url = 'grpc://localhost:8084/org.gdn.grpc.test.MyService/process', map.type='protobuf') (stringValue string, intValue int,longValue long,booleanValue bool,floatValue float,doubleValue double);

This will convert the protobuf messages that are received to this source into stream processor events. Since this is grpc source we don't need to provide the class parameter

Example 3

CREATE SOURCE FooStream WITH (type='grpc', receiver.url = 'grpc://localhost:8084/org.gdn.grpc.test.MyService/process', map.type='protobuf', map.attributes="a = 'stringValue', b = 'intValue', c = 'longValue',d = 'booleanValue',' e = floatValue', f ='doubleValue'") (a string ,c long,b int, d bool,e float,f double);

This will convert the protobuf messages that are received to this source into stream processor events. since there's a mapping available for the stream, protobuf message object will be map like this, - stringValue of the protobuf message will be assign to the a attribute of the stream - intValue of the protobuf message will be assign to the b attribute of the stream - longValue of the protobuf message will be assign to the c attribute of the stream - booleanValue of the protobuf message will be assign to the d attribute of the stream - floatValue of the protobuf message will be assign to the e attribute of the stream - doubleValue of the protobuf message will be assign to the f attribute of the stream

Example 4

CREATE SOURCE FooStream WITH (type='inMemory', topic='test01', map.type='protobuf', map.class='io.streamprocessor.extension.map.protobuf.autogenerated.RequestWithList) (stringValue string ,intValue int,stringList object, intList object););

This will convert the io.streamprocessor.extension.map.protobuf.autogenerated.RequestWithList protobuf messages that are received to this source into stream processor events. If you want to map data types other than the scalar data types, you have to use object as the data type as shown in above(stringList object)