Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring集成:转换器:文件到对象_Java_Spring_Spring Integration - Fatal编程技术网

Java Spring集成:转换器:文件到对象

Java Spring集成:转换器:文件到对象,java,spring,spring-integration,Java,Spring,Spring Integration,我是Spring集成的新手,我正在尝试读取一个文件,并将其转换为一个自定义对象,该对象必须发送到jms.Message中包装的jms队列。 这一切都必须使用注释来完成 我正在使用下面的命令从目录中读取文件 @Bean @InboundChannelAdapter(value = "filesChannel", poller = @Poller(fixedRate = "5000", maxMessagesPerPoll = "1")) public MessageSource<File&g

我是Spring集成的新手,我正在尝试读取一个文件,并将其转换为一个自定义对象,该对象必须发送到jms.Message中包装的jms队列。 这一切都必须使用注释来完成

我正在使用下面的命令从目录中读取文件

@Bean
@InboundChannelAdapter(value = "filesChannel", poller = @Poller(fixedRate = "5000", maxMessagesPerPoll = "1"))
public MessageSource<File> fileReadingMessageSource() {
    FileReadingMessageSource source = new FileReadingMessageSource();
    source.setDirectory(new File(INBOUND_PATH));
    source.setAutoCreateDirectory(false);
    /*source.setFilter(new AcceptOnceFileListFilter());*/
    source.setFilter(new CompositeFileListFilter<File>(getFileFilters()));
    return source;
}

有效负载是一个
文件(
java.io.File

您可以读取文件并输出所需的任何内容(
String
byte[]
Invoice
等)

或者您可以使用一些标准变压器(例如
FileToStringTransformer
jsontObjectTransformer
等)

JMS适配器将对象转换为
TextMessage
ObjectMessage

@Transformer(inputChannel = "filesChannel", outputChannel = "jmsOutBoundChannel")
public ? convertFiletoInvoice(? fileMessage){

    }