HTTP

HTTP Source Connector

Configuration

Before using HTTP source connector, you need to configure the server.

  • Please configure sourceEnable to true in /resource/server-config.yml to enable source functionality.
  • Please configure the source connector in /resource/source-config.yml, only the configuration under connectorConfig is described here:
    • connectorName, name of the connector.
    • (required) path, path of the API.
    • (required) 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.

Startup

  1. start EventMesh Runtime
  2. start eventmesh-connector-http

When finished, the HTTP source connector will act as an HTTP server.

Sending messages

You can send messages to the source connector via HTTP.

  1. connectorConfig:
  2. connectorName: httpSource
  3. path: /test
  4. port: 3755
  5. 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:

  1. Sending a message in binary mode.
  1. curl --location --request POST 'http://localhost:3755/test' \
  2. --header 'ce-id: 1' \
  3. --header 'ce-specversion: 1.0' \
  4. --header 'ce-type: com.example.someevent' \
  5. --header 'ce-source: /mycontext' \
  6. --header 'ce-subject: test_topic' \
  7. --header 'Content-Type: text/plain' \
  8. --data-raw 'testdata'
  1. Sending a message in structured mode.
  1. curl --location --request POST 'http://localhost:3755/test' \
  2. --header 'Content-Type: application/cloudevents+json' \
  3. --data-raw '{
  4. "id": "1",
  5. "specversion": "1.0",
  6. "type": "com.example.someevent",
  7. "source": "/mycontext",
  8. "subject":"test_topic",
  9. "datacontenttype":"text/plain",
  10. "data": "testdata"
  11. }'