Skip to content

Progress events

The user is able to publish events to the DHI Cloud Platform event bus using the job service infrastructure. There is a process running next to each job and the user provided container can push event data to this process using various channels. The monitoring process will take this data and publish it into the event bus on behalf of the user.

Setting up communication channels

The interface for creating a job allows for specifying a collection of so called channels that let the monitoring process know how will the user container publish progress information.

body
{
    ...
    "progressReporting": {
        "channels": [
            <collection of channel definitions here>
        ]
    },
    ...
}

File reporting channel

This is a type of channel that is based on a file. The channel has a format property that defines how the data is formatted in the file, so that the monitoring process can parse it correctly. The monitoring process will watch the file and periodically check for new content. When new content is detected, it will be parsed and each message will be published to the event bus.

Object properties: - type: required property, has to have string value of "FileReportingChannel" - format: required property, determines the format with which the messages are stored in the file. Allowed values are: - "text": the file is expected to be a text file, and each line in the file represents one message. If the line is a simple text, then this text will be included in the event as a "message" property. Alternativelly the line can contain a json object. In that case the object is parsed, and two properties are included in the event - "message" and "payload" ("message" is a string property, "payload" is an arbitrary object) - "spi": the file is expected to be a "spi" file that is produced e.g. by Mike engines. - filePath: indicates the file path where the message will be published. It is either absolute, or relative. In case of relative path then it is expected to be located within the default /work folder of the job.

Example that will produce three messages from a text file:

body
{
    "runtime": {
        "type": "ContainerRuntimeSpec",
        "containers": [
            { 
                "Image": "busybox",
                "Command": ["/bin/sh", "-c", "cd /work/; echo 'hello' >> messages.txt; echo 'world' >> messages.txt; echo '{ \"message\": \"I am  Jason\", \"payload\": {\"timestep\":\"0\"} }' >> messages.txt"]
            }
        ]
    },
    "progressReporting": {
        "channels": [
            { 
                "type": "FileReportingChannel",
                "format": "text",
                "filePath": "messages.txt"
            }
        ]
    }
}