Integrate Queue with Functions using Connector Hub.
This scenario involves creating a function and then referencing that function as a target in a connector (Connector Hub) to receive and process messages from queues.
The payload received by the function contains only messages from the queue.
If you're a member of the Administrators group, you already have the required access to execute this scenario. Otherwise, you need access to Functions.
The workflow for creating the connector includes a default policy when needed to provide permission for writing to the target service. If you're new to policies, see Getting Started with Policies and Common Policies.
Error Handling When Processing Queues 🔗
Note
In the context of queue messages sent to functions, partial failures during processing of messages within a batch aren't supported.
When a function that's processing a batch of messages from a queue encounters an error, all messages in that batch become visible in the queue again, including messages that the function processed successfully. Therefore, a message could be processed by the function several times. As with any target, the connector keeps retrying indefinitely until the function target succeeds. For more information, see Delivery Details.
If a failure occurs while processing a batch of messages, the delivery count for those messages is still increased. If the delivery count for a message reaches the maximum defined at the queue level, then the message is sent to the dead letter queue. For more information, see Delivery count.
To prevent reprocessing of messages, make your function idempotent.
Setting Up the Queue and Function 🔗
Before you can create the connector (Connector Hub) , you must set up a queue and a function to receive data from the queue.
On the Connectors list page, select Create connector. If you need help finding the list page, see Listing Connectors.
On the Create connector page, enter a user-friendly name for the new connector and an optional description. Avoid entering confidential information.
Select the compartment where you want to store the new connector.
Under Configure connector, for Source, select Queue.
For Target, select Functions.
Under Configure source connection, select the queue that contains the messages that you want:
Compartment: Select the compartment that contains the queue that you want.
Queue: Select the queue that contains the messages that you want.
Channel Filter (under Message filtering) (optional): To filter messages from channels in the queue, enter a value.
For example, to filter messages by channel ID, enter the channel ID.
For supported values, see channelFilter at GetMessages (Queue API).
Note
A message that has been transferred to the connector's target is considered "consumed." To meet requirements of the Queue service, the connector deletes transferred messages from the source queue. For more information, see Consuming Messages.
Under Configure target, configure the function to send the messages from the queue to.
Compartment: Select the compartment that contains the function that you want.
Function application: Select the name of the function application that contains the function that you want.
Function: Select the name of the function that you want to send the data to.
Show additional options: Select this link and specify limits for each batch of data sent to the function. To use manual settings, provide values for batch size limit (either KBs or number of messages) and batch time limit (seconds).
For example, limit batch size by selecting either 5,000 kilobytes or 10 messages. An example batch time limit is 5 seconds.
Considerations:
The connector flushes source data as a JSON list in batches. Maximum batch, or payload, size is 6 MB.
Functions are invoked synchronously with 6 MB of data per invocation. If data exceeds 6 MB, then the connector invokes the function again to move the data that's over the limit. Such invocations are handled sequentially.
Functions can execute for up to five minutes. See Delivery Details.
Don't return data from Functions targets to connectors. Connector Hub doesn't read data returned from Functions targets. If the function returns successfully without an error, the connector treats the messages in the batch as "consumed" and deletes those messages from the queue.
Accept default policies: Select the Create link provided for each default policy.
Select Create.
The creation process begins, and its progress is displayed. On completion, the connector's details page opens.
Define the Queue source for the connector: Save a file named source.json.