Streams and streampools can be created from the GUI or from the oci-cli command line.
Once created:
To publish a message, using oci-cli:
export COMPARTMENT_OCID=ocid1.compartment.oc1..xxx
export STREAM_POOL_OCID=ocid1.streampool.oc1.me-dubai-1.xxx
export STREAM_OCID=ocid1.stream.oc1.me-dubai-1.xxx
export ENDPOINT=https://xxx.streaming.me-dubai-1.oci.oraclecloud.com
oci streaming stream message put --stream-id $STREAM_OCID --messages '[ { "key": "a2V5MQ==", "value": "dmFsdWUx" }, { "key": "a2V5Mg==", "value": "dmFsdWUy" } ]' --endpoint $ENDPOINT
{
"data": {
"entries": [
{
"error": null,
"error-message": null,
"offset": 2,
"partition": "0",
"timestamp": "2023-10-12T13:29:41.403000+00:00"
},
{
"error": null,
"error-message": null,
"offset": 3,
"partition": "0",
"timestamp": "2023-10-12T13:29:41.403000+00:00"
}
],
"failures": 0
}
}
To read a message, using oci-cli:
export COMPARTMENT_OCID=ocid1.compartment.oc1..xxx
export STREAM_POOL_OCID=ocid1.streampool.oc1.me-dubai-1.xxx
export STREAM_OCID=ocid1.stream.oc1.me-dubai-1.xxx
export ENDPOINT=https://xxx.streaming.me-dubai-1.oci.oraclecloud.com
echo ""
echo "Extracting the cursor id"
export CURSOR=`oci streaming stream cursor create-cursor --partition 0 --stream-id $STREAM_OCID --type TRIM_HORIZON --endpoint $ENDPOINT --query 'data.value' --raw-output`
echo ""
echo "Extracting the messages"
oci streaming stream message get --cursor $CURSOR --stream-id "$STREAM_OCID" --endpoint $ENDPOINT
Extracting the cursor id
Extracting the messages
{
"data": [
{
"key": "a2V5MQ==",
"offset": 0,
"partition": "0",
"stream": "xxx-streams",
"timestamp": "2023-10-12T10:41:19.851000+00:00",
"value": "dmFsdWUx"
},
{
"key": "a2V5Mg==",
"offset": 1,
"partition": "0",
"stream": "xxx-streams",
"timestamp": "2023-10-12T10:41:19.851000+00:00",
"value": "dmFsdWUy"
}
],
"opc-next-cursor": "eyJjdXJzb3JUeXBlIjoicGFydGl0aW9uIiwidHlwZSI6IkFmdGVyT2Zmc2V0Iiwib2Zmc2V0IjoxLCJ0aW1lIjpudWxsLCJwYXJ0aXRpb24iOiIwIiwic3RyZWFtSWQiOiJvY2lkMS5zdHJlYW0ub2MxLm1lLWR1YmFpLTEuYW1hYWFhYWFnYWtyeG15YWZ2cnFzcmNqZWlzcXc1eGZpMnNndzJwdHpnZTVqcHJxaG9qZHJobGZzNXphIiwiZXhwaXJhdGlvbiI6MTY5NzExNzU1MDI0NCwiY3Vyc29yVHlwZSI6InBhcnRpdGlvbiJ9"
}