x-stream-offset on stream timestamp in 0.9.1 .NET Client

54 views
Skip to first unread message

Lars Riis Olsen

unread,
Sep 2, 2021, 5:59:41 AM9/2/21
to rabbitmq-users

Hi,

I am trying to connect to a stream using the AMQP .NET client. In the example in the doc (https://rabbitmq.com/streams.html)  I can see that I should be able to consume from a specific point in time by setting x-stream-offset to the number of seconds since epoch. However, if I do that it seems to use it as an offset on the index in the queue instead.

Am I misunderstanding something?. How do I get it to use it as a time offset instead of a index offset?

The exact code I use is as follows:
            var fiveMinAgo = DateTimeOffset.UtcNow.AddMinutes(-5).ToUnixTimeSeconds();
            var ff = model.BasicConsume("test-stream", false, "myconsumerTag", new Dictionary<string, object>() {{ "x-stream-offset", fiveMinAgo}}, consumer);

Regards, Lars

Karl Nilsson

unread,
Sep 2, 2021, 7:19:04 AM9/2/21
to rabbitm...@googlegroups.com
What type is fiveMinAgo? If it’s int then that makes sense as all ints are assumed to be offsets. Yeah you pass a DateTike type it may resolve it as an amqp time stamp which is what is expected. You can also try the string “5m”

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/f73dc351-bc3c-4f37-a51c-85bd0cf8076an%40googlegroups.com.
--
Karl Nilsson

Lars Riis Olsen

unread,
Sep 2, 2021, 7:28:51 AM9/2/21
to rabbitmq-users
fiveMinAgo is an int. I also tried just passing a datetime. In that case I get a "Value of type 'DateTime' cannot appear as table value" error.

However, I tried 5m. That works.

Thanks
Reply all
Reply to author
Forward
0 new messages