Skip to content

Possibility to set MessageProperties in the AMQP contract DSL #1310

@makkeess

Description

@makkeess

Is your feature request related to a problem? Please describe.

When defining a contract for AMQP messaging, we have a need to be able to specify message-properties other than headers to be enforced.

For example we'd like to have the MessageProperty "type" as a part of the contract. At the moment it seems like the header 'amqp_receivedRoutingKey' is interpreted and added as the 'receivedRoutingKey' property, but there's no way of injecting other properties.

Describe the solution you'd like

An extension to the contract DSL, enabling the option for outputMessage to have a field 'messageProperties' where properties can be added in a similar way as headers are today. Making the contract definition looking something like the following:

Contract.make {
    description('Description')
    label('some_label')
    input {
        triggeredBy('test()')
    }
    outputMessage {
        sentTo('exchange-name')
        headers {
          header 'contentType', applicationJson()
          header 'amqp_receivedRoutingKey', 'my-routingKey'
        }
        messageProperties {
          messageProperty 'type', 'TYPE'
          messageProperty 'messageId', 'MESSAGE-ID'
          messageProperty 'timestamp', 'TIMESTAMP'
        }
        body ([
          some: 'body'
        ])
    }
}

Resulting in the three properties: type, messageId & timestamp being populated in the message's org.springframework.amqp.core.MessageProperties and values enforced by generated tests and the contract verifier.

Describe alternatives you've considered

Another, inferior, option would be to support the other message properties the same way amqp_receivedRoutingKey.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions