Before using HTTP source connector, you need to configure the server.
sourceEnable
to true
in /resource/server-config.yml
to enable source functionality./resource/source-config.yml
, only the configuration under connectorConfig
is described here:connectorName
, name of the connector.path
, path of the API.port
, port of the API.idleTimeout
, idle TCP connection timeout in seconds. A connection will timeout and be closed if no data is received nor sent within the idleTimeout
seconds. The default is 0, which means don't timeout.When finished, the HTTP source connector will act as an HTTP server.
You can send messages to the source connector via HTTP.
connectorConfig: connectorName: httpSource path: /test port: 3755 idleTimeout: 5
The above example configures a URL http://localhost:3755/test
in source-config.yml
.
You can send messages in binary
mode or structured
mode as specified in cloudevent-spec.
Here are two examples:
binary
mode.curl --location --request POST 'http://localhost:3755/test' \ --header 'ce-id: 1' \ --header 'ce-specversion: 1.0' \ --header 'ce-type: com.example.someevent' \ --header 'ce-source: /mycontext' \ --header 'ce-subject: test_topic' \ --header 'Content-Type: text/plain' \ --data-raw 'testdata'
structured
mode.curl --location --request POST 'http://localhost:3755/test' \ --header 'Content-Type: application/cloudevents+json' \ --data-raw '{ "id": "1", "specversion": "1.0", "type": "com.example.someevent", "source": "/mycontext", "subject":"test_topic", "datacontenttype":"text/plain", "data": "testdata" }'