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 (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"github.com/spf13/cast"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
@ -58,6 +59,12 @@ func addMessageAttributesToMetadata(metadata map[string]string, asbMsg *azservic
|
||||||
metadata = map[string]string{}
|
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 != "" {
|
if asbMsg.MessageID != "" {
|
||||||
metadata["metadata."+MessageKeyMessageID] = asbMsg.MessageID
|
metadata["metadata."+MessageKeyMessageID] = asbMsg.MessageID
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,10 @@ func TestAddMessageAttributesToMetadata(t *testing.T) {
|
||||||
ScheduledEnqueueTime: &testSampleTime,
|
ScheduledEnqueueTime: &testSampleTime,
|
||||||
PartitionKey: &testPartitionKey,
|
PartitionKey: &testPartitionKey,
|
||||||
LockedUntil: &testSampleTime,
|
LockedUntil: &testSampleTime,
|
||||||
|
ApplicationProperties: map[string]interface{}{
|
||||||
|
"hello": "world",
|
||||||
|
"numeric": 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
expectedMetadata: map[string]string{
|
expectedMetadata: map[string]string{
|
||||||
"metadata." + MessageKeyMessageID: testMessageID,
|
"metadata." + MessageKeyMessageID: testMessageID,
|
||||||
|
@ -60,6 +64,8 @@ func TestAddMessageAttributesToMetadata(t *testing.T) {
|
||||||
"metadata." + MessageKeyScheduledEnqueueTimeUtc: testSampleTimeHTTPFormat,
|
"metadata." + MessageKeyScheduledEnqueueTimeUtc: testSampleTimeHTTPFormat,
|
||||||
"metadata." + MessageKeyPartitionKey: testPartitionKey,
|
"metadata." + MessageKeyPartitionKey: testPartitionKey,
|
||||||
"metadata." + MessageKeyLockedUntilUtc: testSampleTimeHTTPFormat,
|
"metadata." + MessageKeyLockedUntilUtc: testSampleTimeHTTPFormat,
|
||||||
|
"metadata.hello": "world",
|
||||||
|
"metadata.numeric": "1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue