Java Reference
In-Depth Information
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.MessageHeaders;
import org.springframework.integration.file.FileHeaders;
// …
import java.io.File;
public class InboundFileMessageServiceActivator {
private static final Logger logger = Logger.getLogger(
InboundFileMessageServiceActivator.class);
@ServiceActivator
public void interrogateMessage(
@Header(MessageHeaders.ID) String uuid,
@Header(FileHeaders.FILENAME) String fileName,
File file
) {
logger.debug(String.format(
"the id of the message is %s, and name of the file payload is %s",
uuid, fileName));
}
}
You can also have Spring Integration simply pass the Map<String,Object> :
package com.apress.springenterpriserecipes.springintegration;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.MessageHeaders;
import org.springframework.integration.file.FileHeaders;
import java.io.File;
import java.util.Map;
public class InboundFileMessageServiceActivatorWithHeadersMap {
private static final Logger logger = Logger.getLogger(
InboundFileMessageServiceActivatorWithHeadersMap.class);
@ServiceActivator
public void interrogateMessage(@Headers Map<String, Object>
headers, File file) {
logger.debug(String.format(
"the id of the message is %s, and name of the file payload is %s",
headers.get(MessageHeaders.ID),
headers.get(FileHeaders.FILENAME)));
}
}
Search WWH ::




Custom Search