org.springframework.messaging.support

## Class IdTimestampMessageHeaderInitializer

- java.lang.Object
- - org.springframework.messaging.support.IdTimestampMessageHeaderInitializer

All Implemented Interfaces:
  MessageHeaderInitializer

    public class IdTimestampMessageHeaderInitializer
    extends Object
    implements MessageHeaderInitializer

A `MessageHeaderInitializer` to customize the strategy for ID and TIMESTAMP message header generation.

Since:
  4.1
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
Constructor and Description
`IdTimestampMessageHeaderInitializer()`

### Method Summary

All Methods Instance Methods Concrete Methods
`org.springframework.util.IdGenerator` `getIdGenerator()` Return the configured `IdGenerator`, if any.
`void` `initHeaders(MessageHeaderAccessor headerAccessor)` Initialize the given `MessageHeaderAccessor`.
`boolean` `isEnableTimestamp()` Return whether the timestamp header is enabled or not.
`void` `setDisableIdGeneration()` A shortcut for calling `setIdGenerator(org.springframework.util.IdGenerator)` with an id generation strategy to disable id generation completely.
`void` `setEnableTimestamp(boolean enableTimestamp)` Whether to enable the automatic addition of the `MessageHeaders.TIMESTAMP` header on `MessageHeaderAccessor` instances being initialized.
`void` `setIdGenerator(org.springframework.util.IdGenerator idGenerator)` Configure the IdGenerator strategy to initialize `MessageHeaderAccessor` instances with.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### IdTimestampMessageHeaderInitializer

    public IdTimestampMessageHeaderInitializer()

### Method Detail

#### setIdGenerator

    public void setIdGenerator(@Nullable
                               org.springframework.util.IdGenerator idGenerator)

Configure the IdGenerator strategy to initialize `MessageHeaderAccessor` instances with.

By default this property is set to `null` in which case the default IdGenerator of `MessageHeaders` is used.

To have no ids generated at all, see `setDisableIdGeneration()`.

#### getIdGenerator

    @Nullable
    public org.springframework.util.IdGenerator getIdGenerator()

Return the configured `IdGenerator`, if any.

#### setDisableIdGeneration

    public void setDisableIdGeneration()

A shortcut for calling `setIdGenerator(org.springframework.util.IdGenerator)` with an id generation strategy to disable id generation completely.

#### setEnableTimestamp

    public void setEnableTimestamp(boolean enableTimestamp)

Whether to enable the automatic addition of the `MessageHeaders.TIMESTAMP` header on `MessageHeaderAccessor` instances being initialized.

By default this property is set to false.

#### isEnableTimestamp

    public boolean isEnableTimestamp()

Return whether the timestamp header is enabled or not.

#### initHeaders

    public void initHeaders(MessageHeaderAccessor headerAccessor)

Description copied from interface: `MessageHeaderInitializer`
Initialize the given `MessageHeaderAccessor`.

Specified by:
  `initHeaders` in interface `MessageHeaderInitializer`
Parameters:
  `headerAccessor` - the MessageHeaderAccessor to initialize