- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
这是我的 spring 集成 xml:我用来学习的一个简单的东西......
<int-file:inbound-channel-adapter id="executionMessageFileInputChannel"
directory="file:${fpml.messages.input}"
prevent-duplicates="false" filename-pattern="*.xml">
<int:poller fixed-delay="20000" max-messages-per-poll="20"/>
</int-file:inbound-channel-adapter>
<int:service-activator input-channel="executionMessageFileInputChannel"
output-channel="executionMessageFileArchiveChannel"
ref="dummyService" method="myMethod"/>
<int-file:outbound-channel-adapter id="executionMessageFileArchiveChannel"
directory="file:${fpml.messages.archive}"
delete-source-files="true" auto-create-directory="true"/>
我真的找不到很好的教程..你能指点我吗集成 java dsl 的好教程?另外,请帮我把它从 xml 转换成 dsl。
更新:(在 Gary's Response 之后):
我设法翻译到这里。
@MessagingGateway
public interface Archive {
@Gateway(requestChannel = "archiveFile.input")
void archive();
}
@Bean
public IntegrationFlow archiveFile() {
return IntegrationFlows
.from(Files.inboundAdapter(new File(dirPath))
.patternFilter("*.xml")
.preventDuplicatesFilter(false),
e -> e.poller(Pollers.fixedDelay(20000)
.maxMessagesPerPoll(20)))
.handle("app","myMethod")
.handle(Files.outboundAdapter(new File(outDirPath)).deleteSourceFiles(true).autoCreateDirectory(true))
.get();
}
只是不确定我这样做是否正确。我一翻译就发布,我会测试一下。
测试了一下:出现以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'archiveFile' defined in si.jdsl.App: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'archiveFile' threw exception; nested exception is java.lang.IllegalArgumentException: The 'filter' (org.springframework.integration.file.filters.CompositeFileListFilter@48e64352) is already configured for the FileReadingMessageSource
有什么想法吗?
更新 2:
谢谢加里,这解决了过滤器问题:服务激活器出现问题。以下是我的服务激活器:
@Bean
@ServiceActivator(inputChannel = "archiveFile.input")
public Message<File> myMethod (File inputFile){
Map<String, Object> contextHeader = new HashMap<String, Object>();
return new GenericMessage<File>(inputFile, contextHeader);
}
Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myMethod' defined in si.jdsl.App: Unsatisfied dependency expressed through constructor argument with index 0 of type [java.io.File]: : No qualifying bean of type [java.io.File] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [java.io.File] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
请让我知道我缺少什么?
最佳答案
使用 Files
命名空间工厂。参见 the DSL reference manual .有通用教程here其中逐步介绍了咖啡馆示例应用程序的逐行转换。 (Java 6/7 版本 here )。
编辑:
这看起来像是一个错误,DSL 提示说您设置了两个过滤器,但它不允许这样做。
在这种情况下,你其实不需要这个
.preventDuplicatesFilter(false),
因为这是您提供另一个过滤器时的默认设置。
如果你确实需要编写一个过滤器,你可以使用
.filter(myFilter())
其中 myFilter
是一个带有模式过滤器等的 CompositeFileListFilter
bean。
编辑 2:
@Bean
是在初始化时构造的,显然这是一个运行时方法。
当一个@Bean
被@ServiceActivator
注解时,它的类型必须是MessageHandler
。要使用 POJO 消息传递,您需要一个 @MessageEndpoint
bean...
@Bean
public MyPojo myPojo() {
return new MyPojo();
}
@MessageEndpoint
public static class MyPojo {
@ServiceActivator(inputChannel = "archiveFile.input")
public Message<File> myMethod (File inputFile){
Map<String, Object> contextHeader = new HashMap<String, Object>();
return new GenericMessage<File>(inputFile, contextHeader);
}
}
您可以在 POJO 中有多个消息传递方法。
关于java - Spring Integration xml 到 java dsl - 如何定义入站/出站 channel 适配器、轮询器等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31715620/
我很好奇为什么以下不起作用。一般select用default:防止死锁,但在这种情况下不是: package main import "fmt" func main () { a := mak
我一生都无法弄清楚如何切换图像排序。图像以 (x,x,3) 格式读取,theano 要求它是 (3,x,x) 格式。我尝试更改顺序numpy.array([img[:,:,i] for i in ra
我正在向 libnl 发送单个 SSID 和频率进行扫描,但我得到了多个扫描结果以及我请求的 SSID 和频率,但我需要单个扫描结果(仅适用于请求的 SSID),如何实现这一点。请帮助我,我也发送了我
我是 Golang 的新手,但正在努力理解这门伟大的语言!请帮帮我.. 我有 2 个 channel 。 “进”和“出” channel in, out := make(chan Work),
例如我有这段代码: package main import ( "fmt" ) func main() { c1 := make(chan interface{}) close
我们使用以下调用来获取经过身份验证的用户的 ChannelID,它适用于大多数情况。一些 YouTube 用户将他们的 channel 连接到 Google+ 信息页,但在这种情况下,我们的一位用户无
case 'sinfo': const sinfo = new Discord.MessageEmbed() .addField('Server Name 🔎 :', message.guild.n
我需要让所有 channel 来创建一个 bunker 命令,这使得所有 channel 都是只读的。 最佳答案 他们变了Client.servers至 Client.guilds在 newer ve
为什么当第二个值通过另一个 go routine 发送并且没有收到发送的第一个值时, channel c 没有缓冲? package main import "fmt" func sum(s []in
据我所知,内置的 split 会将一个 3 channel Mat 拆分为三个 1 channel Mat。结果,这三个 Mat 只是具有一些不同强度的灰度。 我的意图是获得三个 3 channel
如何检测当前的 RAM 配置?我需要询问 Windows RAM 当前是在单 channel 、双 channel 还是四 channel 中运行。 我搜索了很多,并没有在这个网站或其他网站上找到任何
我需要拆分一个多 channel wav 文件并将每个 channel 编码为 mp3 文件。 我知道 gtresamer 的 deinterleave 插件,但我不确定如何将它用于 wav 文件以及
关闭。这个问题需要details or clarity .它目前不接受答案。 想要改进这个问题吗? 通过 editing this post 添加详细信息并澄清问题. 关闭 8 年前。 Improve
我正在尝试运行 Hyperledger Fabric 网络,它由单个订购者、单个对等节点和一个 cli 组成。为了学习启动 Hyperledger Fabric 网络的过程,从创建与加密相关的工件到将
我在 Laravel 中使用事件广播。我正在使用基于角色的通知访问权限。我有用于广播的自定义 auth guard。当用户连接到 channel 时,客户端将具有内部权限的 access_token
我正在编写一个使用 Elixir Channels 来处理实时事件的应用程序。我知道每个客户端将打开 1 个套接字,并且可以在其上多路复用多个 channel 。所以我的应用程序是一个聊天应用程序,其
我有一些 .wav 文件,我想转换它们的频率 (fs) 和 channel 数 (nchannels)。我在jupyter笔记本python3.6上使用ffmpeg。我使用了以下命令并且它有效。 cm
我有一个视频渲染器,它需要两个 H265 流(YUV420),我需要烘焙它们以使它们中的一个与另一个形成 alpha 蒙版。这一切都已解决并且效果很好,但是如果我按照此处的说明进行操作: ffmpeg
我运行此命令以便能够将 udp 直播流传输到可使用正在构建的移动应用程序播放的 http 直播流。 它只是一个只有音频流的流。 ffmpeg -i udp://@localhost:1111 -map
我在我的 discord.js 机器人中创建了 nuke 命令,它创建了具有相同名称、权限、主题等的 channel ,并删除了“原始” channel 。但是有一个问题,如何使 channel 与“
我是一名优秀的程序员,十分优秀!