Need to set the time stamp header using java client

224 views
Skip to first unread message

jithendra vijay kumar

unread,
Jan 27, 2016, 12:36:55 AM1/27/16
to rabbitmq-users, jk001...@techmahindra.com
Hi Team,

I am using the java client for sending the messages to Rabbit MQ.
I need to send the time stamp header in seconds as shown in the below format.

props.Timestamp = new RabbitMQ.Client.AmqpTimestamp((long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds); (THis bit of code is from c# client)

Can you please help me to do the same using the java client.


Thanks in advance.

//Jitendra.

Michael Klishin

unread,
Jan 27, 2016, 6:40:52 AM1/27/16
to rabbitm...@googlegroups.com, jithendra vijay kumar, jk001...@techmahindra.com
On 27 January 2016 at 08:36:59, jithendra vijay kumar (ajvk...@gmail.com) wrote:
> props.Timestamp = new RabbitMQ.Client.AmqpTimestamp((long)(DateTime.Now
> - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds); (THis bit
> of code is from c# client)

See AMQP.BasicProperties.builder(). You want to set headers, which accepts a
Java map.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ


Michael Klishin

unread,
Jan 27, 2016, 6:42:24 AM1/27/16
to rabbitm...@googlegroups.com, jithendra vijay kumar, jk001...@techmahindra.com
 On 27 January 2016 at 14:40:49, Michael Klishin (mkli...@pivotal.io) wrote:
> See AMQP.BasicProperties.builder(). You want to set headers,
> which accepts a
> Java map.

There's also a slight shortcut:
https://github.com/rabbitmq/rabbitmq-java-client/blob/master/src/test/java/com/rabbitmq/client/test/functional/PerMessageTTL.java#L66

Michael Klishin

unread,
Jan 27, 2016, 6:45:28 AM1/27/16
to rabbitm...@googlegroups.com, jithendra vijay kumar, jk001...@techmahindra.com
On 27 January 2016 at 08:36:59, jithendra vijay kumar (ajvk...@gmail.com) wrote:
> You want to set headers, which accepts a
> Java map.

Sorry, you want timestamp, not headers. I was thinking of TTL. 
Reply all
Reply to author
Forward
0 new messages