[英]How to use the channel in Spring Integration but Using just java config
I have been reading the Spring Documentation and forums on Internet. 我一直在阅读Spring文档和Internet上的论坛。 I did something very similar to this: sftp with java config in spring
我做了一些非常类似的事情: 在春季使用Java配置进行sftp
The point is I would like to use the channel to send a message, So I've created a method like this one
关键是我想使用该通道发送消息,所以我创建了一个像这样的方法
private void MethodToSendMessageUsingSftp(MessageChannel channel, File file){ final Message<File> message = MessageBuilder.withPayload(file).build(); channel.send(message); }
But I don't know how to get the channel in order to set it into the MethodToSendMessageUsingSftp method, and send the message. 但是我不知道如何获取通道以将其设置为MethodToSendMessageUsingSftp方法并发送消息。
By the way, I'm doing all these things just because I'm changing some stuff from xml to java config in my projects: 顺便说一句,我正在做所有这些事情,只是因为我正在将项目中的某些内容从xml更改为java config:
So, my old project looks like this: 因此,我的旧项目如下所示:
<bean id="uploadToSftpTasklet" class="someClass" scope="step">
<property name="sftpChannel" ref="sftpChannel"/>
</bean>
<int:channel id="sftpChannel"/>
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
channel="sftpChannel"
session-factory="sftpSessionFactory"
remote-directory-expression="whatever"
charset="UTF-8"
auto-create-directory="true"
use-temporary-file-name="false"
</int-sftp:outbound-channel-adapter>
If you see, in my uploadToSftpTasklet
I'm referencing to the sftpChannel
, and that is what I want to do using java config. 如果看到的话,在我的
uploadToSftpTasklet
我指的是sftpChannel
,这就是我想使用java config进行的操作。
Let me guess: that method is a part of some service in your application, managed bean. 让我猜测:该方法是应用程序中的某些服务(托管Bean)的一部分。 So, you can just
@Autowired
that channel into this service and go with the logic. 因此,您可以
@Autowired
将该通道连接到此服务中,并@Autowired
逻辑。
Although, to be honest, your question isn't clear. 虽然,老实说,您的问题尚不清楚。 Everything in Spring Integration is a bean and fully based on the Spring Framework.
Spring Integration中的所有内容都是一个bean,并且完全基于Spring Framework。 So, dependency injection rules and all the configuration tricks are applied here as well.
因此,这里也应用了依赖项注入规则和所有配置技巧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.