Solace Go API - Setting custom headers on outbound messages

jan_maretzki
jan_maretzki Member Posts: 2
edited September 2022 in Early Access API #1

Hey,

I have started, looking into the der Solace Go API 1.1

solace.dev/go/messaging v1.0.1

I started looking into the processing of incoming messages and then pass them on onto a next channel/topic.

But as far as I can see in the API, there is no way to set custom properties/headers in an outbound message. The OutboundMessageBuilder has a

MessagePropertiesConfigurationProvider

that only exposes a map with already defined constants as keys.

Am I missing a property call here or is this a gap in the API?

Best Answer

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 541 admin
    #2 Answer ✓

    Hey @jan_maretzki ! You can for sure add additional properties to your message when building the outbound message. When you process your incoming message and start building your other message, you can add a .WithPropoerty to your MessageBuilder as follows

      messageBuilder := messagingService.MessageBuilder().
        WithProperty("Key", "Value").
        WithProperty("Key", "Value")
    

    And on the receiving end you can use message.GetProperties() which returns an sdt.Map of properties

    You can see an example here

    https://github.com/SolaceSamples/solace-samples-go/blob/main/patterns/direct_publisher.go#L67-L71

Answers