CoAP Client

Constrained Application Protocol (CoAP) is a web transfer protocol designed for machine-to-machine devices. The CoAP Client destination writes data to a CoAP endpoint. Use the destination to send requests to a CoAP resource URL.

The CoAP Client destination generates one request for each record. When you configure the destination, you define the resource URL and method to use for the requests. You configure whether each request is confirmable or non-confirmable. You can also configure a connection timeout for each request.

Data Formats

CoAP Client writes data to CoAP endpoints based on the data format that you select. You can use the following data formats:

Binary
The destination writes binary data from a single field in the record.
JSON
The destination writes records as JSON data. You can use one of the following formats:
  • Array - Each file includes a single array. In the array, each element is a JSON representation of each record.
  • Multiple objects - Each file includes multiple JSON objects. Each object is a JSON representation of a record.
SDC Record
The destination writes records in the SDC Record data format.
Text
The destination writes data from a single text field to the destination system. When you configure the stage, you select the field to use. When necessary, merge record data into the field earlier in the pipeline.
You can configure the characters to use as record separators. By default, the destination uses a Unix-style line ending (\n) to separate records.
When a record contains no data in the text field, you can configure the destination to write the record separator characters, creating an empty line. By default, the destination discards the record.

Configuring a CoAP Client Destination

Configure a CoAP Client destination to write data to a CoAP endpoint.

  1. In the Properties panel, on the General tab, configure the following properties:
    General Property Description
    Name Stage name.
    Description Optional description.
    Required Fields Fields that must include data for the record to be passed into the stage.
    Tip: You might include fields that the stage uses.

    Records that do not include all required fields are processed based on the error handling configured for the pipeline.

    Preconditions Conditions that must evaluate to TRUE to allow a record to enter the stage for processing. Click Add to create additional preconditions.

    Records that do not meet all preconditions are processed based on the error handling configured for the stage.

    On Record Error Error record handling for the stage:
    • Discard - Discards the record.
    • Send to Error - Sends the record to the pipeline for error handling.
    • Stop Pipeline - Stops the pipeline. Not valid for cluster pipelines.
  2. On the CoAP tab, configure the following properties:
    CoAP Property Description
    Resource URL CoAP resource URL. Enter in the following format:
    coap://<hostname>:<listening_port>/<resource_name>
    For example:
    coap://localhost:5683/sdc
    CoAP Method CoAP request method to send for each record: GET, POST, PUT, or DELETE.
    Request Type Type of CoAP request to send:
    • Confirmable - The CoAP server must return an acknowledgement message before the destination can send the next request. Use to guarantee that each request is successfully delivered.
    • Nonconfirmable - The CoAP server does not need to acknowledge each request. Use for faster performance.
    Connect Timeout Maximum number of milliseconds to wait for a connection to the CoAP server for each request. If the timeout is exceeded, the record is handled based on the error handling configured for the stage. The destination then attempts to send the next request.

    Use 0 to wait indefinitely.

  3. On the Data Format tab, configure the following property:
    Data Format Property Description
    Data Format Data format for messages:
    • Binary
    • JSON
    • SDC Record
    • Text
  4. For binary data, on the Data Format tab, configure the following property:
    Binary Property Description
    Binary Field Path Field that contains the binary data.
  5. For JSON data, on the Data Format tab, configure the following property:
    JSON Property Description
    JSON Content Determines how JSON data is written:
    • JSON Array of Objects - Each file includes a single array. In the array, each element is a JSON representation of each record.
    • Multiple JSON Objects - Each file includes multiple JSON objects. Each object is a JSON representation of a record.
    Charset Character set to use when writing data.
  6. For text data, on the Data Format tab, configure the following properties:
    Text Property Description
    Text Field Path Field that contains the text data to be written. All data must be incorporated into the specified field.
    Record Separator Characters to use to separate records. Use any valid Java string literal. For example, when writing to Windows, you might use \r\n to separate records.

    By default, the destination uses \n.

    Insert Record Separator if No Text When a record does not include the text field, inserts the configured record separator string to create an empty line.

    When not selected, records without the text field are discarded.

    Charset Character set to use when writing data.