components-contrib icon indicating copy to clipboard operation
components-contrib copied to clipboard

Event Hub binding should allow transforming ALL custom properties as headers, not just iot-hub systemproperties

Open oising opened this issue 1 year ago • 0 comments

Describe the feature

Currently only a fixed set of system properties from Azure IoT Hub are forwarded as headers when delivered to a subscriber. The Azure Event Hubs binding should expose a getAllProperties property (false by default) to forward all user/app/custom properties from the Event Hub message as headers to the subscriber.

It seems that is 90% supported already in the DAPR codebase, but it stops short at exposing the setting in the manifest. i.e.

// GetBindingsHandlerFunc returns the handler function for bindings messages
func (aeh *AzureEventHubs) GetBindingsHandlerFunc(topic string, getAllProperties bool, handler bindings.Handler) HandlerFn {
	return func(ctx context.Context, messages []*azeventhubs.ReceivedEventData) ([]HandlerResponseItem, error) {
		if len(messages) != 1 {
			return nil, fmt.Errorf("expected 1 message, got %d", len(messages))
		}

		bindingsMsg, err := NewBindingsReadResponseFromEventData(messages[0], topic, getAllProperties)
		if err != nil {
			return nil, fmt.Errorf("failed to get bindings read response from azure eventhubs message: %w", err)
		}

		aeh.logger.Debugf("Calling app's handler for message %s on topic %s", messages[0].SequenceNumber, topic)
		_, err = handler(ctx, bindingsMsg)
		return nil, err
	}
}

Release Note

RELEASE NOTE:

oising avatar Oct 16 '24 14:10 oising