Skip to content

Issues with expiry conversion in DefaultStreamMessageConverter #3174

@cprutle

Description

@cprutle

In what version(s) of Spring AMQP are you seeing this issue?

3.2.5

Describe the bug

Using the DefaultStreamMessageConverter the conversion between com.rabbitmq.stream.Message and org.springframework.amqp.core.Message causes problems with the expiry field.

  1. In the method toMessageProperties, in the following line
.acceptIfNotNull(properties.getAbsoluteExpiryTime(),
		                            exp -> mProps.setExpiration(Long.toString(exp))

You would expect that if the time is null that this would not be set. The issue is that the properties are of type QPidProtonProperties, which will never return null, instead if it is null it returns 0. This would set the expiration to "0". Which then if you send that message it will expire immediately instead of never. This is particularly problematic as when consuming from a stream a message is always converted to an amqp core message.

The QPidProtonProperties class seems to be pulled in via the rabbit streams library.

  1. The conversion between the two types sets the expiry to the same Long. As one is epoch and one is relative these will not be correct after conversion. I.e. If you set a message to expire tomorrow in streams then converted to amqp.core the message would not expire for ~55 years.

To Reproduce

To reproduce null -> 0 expiry error, create a flow that reads in from a stream with null expiry using RabbitmqStream.inboundAdapter and writes out to a non stream exchange with bound queue using Amqp.outboundAdapter.

To reproduce incorrect conversion, with the same stream -> non stream flow (or reverse it), add an expiry to the message and view that after conversion the expiry is incorrect.

Expected behavior

Expected behaviour would be that a stream message with a null expiry would be converted to an amqp message with a null expiry.

Expected behaviour would be that a stream message with an expiry of a set time would still have the same relative expiry when converted to an amqp core message.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions