Main Content

isProperty

Determine if Kafka stream provider property is set

    This function requires Streaming Data Framework for MATLAB® Production Server™.

    Description

    example

    tf = isProperty(ks,name) returns a logical 1 (true) if the Kafka® stream provider property name is set in the stream connector object ks. Otherwise, it returns logical 0 (false). The getProviderProperties function returns nonempty property data only for properties for which isProperty returns true.

    You can specify multiple property names in name. The length of tf equals the number of string property names in name.

    example

    tf = isProperty(ks,name,cat) restricts the search for a property to within Kafka stream provider category cat.

    [tf,prop] = isProperty(___) also returns the property names and categories, prop. Because properties can belong to multiple categories or be unset, prop might not be the same size as tf. You can return prop using any of the preceding syntaxes.

    example

    [tf,prop,type] = isProperty(___) also returns the data type of the property values, type. The prop and type arguments are always the same size.

    Examples

    collapse all

    Assume that you have a Kafka server running at the network address kafka.host.com:9092 that has a topic CoolingFan.

    Create a KafkaStream object connected to the Kafka host and also specify Kafka provider properties during object creation.

    ks = kafkaStream("kafka.host.com",9092,"CoolingFan", ...
    "security.protocol","SSL","ssl.truststore.type","PEM", ...
    "ssl.truststore.location","kafka-boston.pem","retention.ms",500);
    

    Check if the security.protocol and retention.ms properties are set.

    isProperty(ks,["security.protocol","retention.ms"])
    ans =
    
      1×2 logical array
    
       1   1

    Assume that you have a Kafka server running at the network address kafka.host.com:9092 that has a topic CoolingFan.

    Create a KafkaStream object connected to the Kafka host and also specify Kafka provider properties during object creation.

    ks = kafkaStream("kafka.host.com",9092,"CoolingFan", ...
    "security.protocol","SSL","ssl.truststore.type","PEM", ...
    "ssl.truststore.location","kafka-boston.pem","retention.ms",500);
    

    Check if the security.protocol and retention.ms properties belong to the CreateTopic category.

    isProperty(ks,["security.protocol" "retention.ms"],"CreateTopic")
    ans =
    
      1×2 logical array
    
       0   1

    Assume that you have a Kafka server running at the network address kafka.host.com:9092 that has a topic CoolingFan.

    Create a KafkaStream object connected to the Kafka host and also specify Kafka provider properties during object creation.

    ks = kafkaStream("kafka.host.com",9092,"CoolingFan", ...
    "security.protocol","SSL","ssl.truststore.type","PEM", ...
    "ssl.truststore.location","kafka-boston.pem","retention.ms",500);
    

    Check if the security.protocol and retention.ms properties belong to the CreateTopic category and return the property names, categories, and data types. Because security.protocol is set in two different categories, it appears twice in the prop and type outputs.

    [tf,prop,type] = isProperty(ks,["security.protocol" "retention.ms"]);
    tf
    name = {prop.name}
    cat = {prop.category}
    type
    tf =
    
      1×2 logical array
    
       1   1
    
    
    name =
    
      1×3 cell array
    
        {["security.protocol"]}    {["security.protocol"]}    {["retention.ms"]}
    
    
    cat =
    
      1×3 cell array
    
        {["Consumer"]}    {["Producer"]}    {["CreateTopic"]}
    
    
    type = 
    
      1×3 string array
    
        "string"    "string"    "string"

    Input Arguments

    collapse all

    Object connected to a Kafka stream topic, specified as a KafkaStream object.

    Kafka stream provider property names, specified as a string scalar, character vector, string array, or cell array of character vectors. If a property is not set in ks, then isProperty returns a logical 0 (false) for that property in tf, and the optional prop and type arguments do not return data for this property.

    Example: tf = isProperty(ks,"retention.ms") returns whether the retention.ms property is set in ks.

    Data Types: char | string | cell

    Kafka stream provider category names, specified as a string scalar, character vector, string array, or cell array of character vectors.

    The specified categories must be present in ks. To get a list of valid categories, use the ks.PropertyCategories property.

    Data Types: char | string | cell

    Output Arguments

    collapse all

    Provider property set indicator, returned as a logical array of these values:

    • 1 — The property in the corresponding position of name is set in ks.

    • 0 — The property in the corresponding position of name is not set in ks.

    Kafka stream provider property names and categories, returned as a structure array. Each structure corresponds to a provider property in ks and has these fields:

    • name — Provider property name, returned as a string

    • category — Category that the provider property belongs to, returned as a string

    Because properties can belong to more than one category, the category and name uniquely identity a property.

    Data types of Kafka stream provider property values, returned as a string scalar or string array. Each string in type specifies the data type of a set property returned in the corresponding position of prop.

    Version History

    Introduced in R2022b