Example usage for org.springframework.messaging MessageHeaders MessageHeaders

List of usage examples for org.springframework.messaging MessageHeaders MessageHeaders

Introduction

In this page you can find the example usage for org.springframework.messaging MessageHeaders MessageHeaders.

Prototype

private MessageHeaders(MessageHeaders original, Set<String> keysToIgnore) 

Source Link

Document

Copy constructor which allows for ignoring certain entries.

Usage

From source file:org.springframework.messaging.MessageHeaders.java

private void writeObject(ObjectOutputStream out) throws IOException {
    Set<String> keysToIgnore = new HashSet<>();
    this.headers.forEach((key, value) -> {
        if (!(value instanceof Serializable)) {
            keysToIgnore.add(key);//from w ww .jav  a2  s.c  o  m
        }
    });

    if (keysToIgnore.isEmpty()) {
        // All entries are serializable -> serialize the regular MessageHeaders instance
        out.defaultWriteObject();
    } else {
        // Some non-serializable entries -> serialize a temporary MessageHeaders copy
        if (logger.isDebugEnabled()) {
            logger.debug("Ignoring non-serializable message headers: " + keysToIgnore);
        }
        out.writeObject(new MessageHeaders(this, keysToIgnore));
    }
}