ASB: Add support for ApplicationProperties in subscriptions (#3436)
Signed-off-by: Bernd Verst <github@bernd.dev>
This commit is contained in:
parent
f0be1a2d28
commit
f23794f69b
|
@ -15,6 +15,7 @@ package servicebus
|
|||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"github.com/spf13/cast"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
|
@ -58,6 +59,12 @@ func addMessageAttributesToMetadata(metadata map[string]string, asbMsg *azservic
|
|||
metadata = map[string]string{}
|
||||
}
|
||||
|
||||
for key, val := range asbMsg.ApplicationProperties {
|
||||
metadata["metadata."+key] = cast.ToString(val)
|
||||
}
|
||||
|
||||
// We are not concerned about key conflicts here as we do not allow custom properties that match well-known property names
|
||||
|
||||
if asbMsg.MessageID != "" {
|
||||
metadata["metadata."+MessageKeyMessageID] = asbMsg.MessageID
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ func TestAddMessageAttributesToMetadata(t *testing.T) {
|
|||
ScheduledEnqueueTime: &testSampleTime,
|
||||
PartitionKey: &testPartitionKey,
|
||||
LockedUntil: &testSampleTime,
|
||||
ApplicationProperties: map[string]interface{}{
|
||||
"hello": "world",
|
||||
"numeric": 1,
|
||||
},
|
||||
},
|
||||
expectedMetadata: map[string]string{
|
||||
"metadata." + MessageKeyMessageID: testMessageID,
|
||||
|
@ -60,6 +64,8 @@ func TestAddMessageAttributesToMetadata(t *testing.T) {
|
|||
"metadata." + MessageKeyScheduledEnqueueTimeUtc: testSampleTimeHTTPFormat,
|
||||
"metadata." + MessageKeyPartitionKey: testPartitionKey,
|
||||
"metadata." + MessageKeyLockedUntilUtc: testSampleTimeHTTPFormat,
|
||||
"metadata.hello": "world",
|
||||
"metadata.numeric": "1",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue