消息传送异常:org.springframework.messaging.MessageDeliveryException in sftp outbound-channel-adapter
Messaging exception: org.springframework.messaging.MessageDeliveryException in sftp outbound-channel-adapter
消息传递异常:org.springframework.messaging.MessageDeliveryException:Dispatcher 没有频道 'org.springframework.web.context.WebApplicationContext:/.sftpChannel' 的订阅者。嵌套异常是 org.springframework.integration.MessageDispatchingException:调度程序没有订阅者
我正在尝试将文件从本地发送到远程服务器。
我的应用上下文如下
<bean id="startupBean" class="com.SchedulerImpl" init-method="run"/>
<bean id="applicationContextProvider" class="com.ApplicationContextProvider"></bean>
<bean id="sftpSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="defaultSftpSessionFactory" />
</bean>
<bean id="defaultSftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="${destination.host}"/>
<property name="privateKey" value="${destination.privateKey}"/>
<property name="privateKeyPassphrase" value="${destination.privateKeyPassphrase}"/>
<property name="port" value="${destination.port}"/>
<property name="user" value="${destination.user}"/>
<property name="sessionConfig" ref="props"/>
</bean>
<util:properties id="props">
<prop key="PreferredAuthentications">publickey</prop>
</util:properties>
<int:channel id="sftpChannel"/>
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
session-factory="sftpSessionFactory"
channel="sftpChannel"
auto-startup ="false"
charset="UTF-8"
remote-directory="/destinationFolder/"
remote-file-separator="/">
</int-sftp:outbound-channel-adapter>
<int:publish-subscribe-channel id="contextRefreshEvents"/>
<int:outbound-channel-adapter channel="contextRefreshEvents"
expression="sftpOutboundAdapter.start()" />
所以我在 sftp class 的代码中得到相同的 applicationContext 实例:
ApplicationContext 上下文 = appContext.getApplicationContext();
MessageChannel sftpChannel = (MessageChannel)context.getBean("sftpChannel");
和@Autowired private ApplicationContextProvider appContext;
在同一个 sftp class.
还有另一个 class ApplicationContextProvider 实现了 ApplicationContextAware,它帮助我获取当前的 ApplicaitonContext。
我不明白为什么我会收到未找到订阅者。
我设置了 auto-startup=false。
获取当前 sftpChannel bean 的正确方法是什么,它给我相同的 applicationContext 实例。
如果我做 appContext = new classpathxmlapplicationcontext(applicationcontext.xml )
我在 startupBean 中遇到错误,所以我不想那样做。
现在我正在实施 ApplicationContextAware,但我收到消息传递异常。
谁能帮帮我?
我正在使用 spring 3
你脑子里分享了很多,最后你的问题变得一团糟。
让我从另一边解释一下是怎么回事。
因为您在 <int-sftp:outbound-channel-adapter>
上有 auto-startup ="false"
,任何 send
到 sftpChannel
都会导致该异常,直到您启动该适配器。
从另一边我看到你这样做了,虽然我们看不到是谁发起了 contextRefreshEvents
消息,但我们相信你是 <int-event:inbound-channel-adapter>
。
这里还有一点,您没有向我们展示 file from local
。好的,我猜是 <int-file:inbound-channel-adapter>
。这是可轮询的,并在应用程序启动后立即开始轮询本地主管。所以,这可能会导致 Dispatcher has no subscribers
,因为 sftpOutboundAdapter
还没有开始。
如果我的推理有误,请告诉我,但您的预期有所不同。
更新
要以编程方式启动端点(或任何其他 Lifecycle
组件),您应该 inject
它到您的服务:
@Autowired
@Qualifier("sftpOutboundAdapter")
private Lifecycle sftpOutboundAdapter;
....
sftpOutboundAdapter.start();
消息传递异常:org.springframework.messaging.MessageDeliveryException:Dispatcher 没有频道 'org.springframework.web.context.WebApplicationContext:/.sftpChannel' 的订阅者。嵌套异常是 org.springframework.integration.MessageDispatchingException:调度程序没有订阅者
我正在尝试将文件从本地发送到远程服务器。
我的应用上下文如下
<bean id="startupBean" class="com.SchedulerImpl" init-method="run"/>
<bean id="applicationContextProvider" class="com.ApplicationContextProvider"></bean>
<bean id="sftpSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="defaultSftpSessionFactory" />
</bean>
<bean id="defaultSftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="${destination.host}"/>
<property name="privateKey" value="${destination.privateKey}"/>
<property name="privateKeyPassphrase" value="${destination.privateKeyPassphrase}"/>
<property name="port" value="${destination.port}"/>
<property name="user" value="${destination.user}"/>
<property name="sessionConfig" ref="props"/>
</bean>
<util:properties id="props">
<prop key="PreferredAuthentications">publickey</prop>
</util:properties>
<int:channel id="sftpChannel"/>
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
session-factory="sftpSessionFactory"
channel="sftpChannel"
auto-startup ="false"
charset="UTF-8"
remote-directory="/destinationFolder/"
remote-file-separator="/">
</int-sftp:outbound-channel-adapter>
<int:publish-subscribe-channel id="contextRefreshEvents"/>
<int:outbound-channel-adapter channel="contextRefreshEvents"
expression="sftpOutboundAdapter.start()" />
所以我在 sftp class 的代码中得到相同的 applicationContext 实例:
ApplicationContext 上下文 = appContext.getApplicationContext();
MessageChannel sftpChannel = (MessageChannel)context.getBean("sftpChannel");
和@Autowired private ApplicationContextProvider appContext; 在同一个 sftp class.
还有另一个 class ApplicationContextProvider 实现了 ApplicationContextAware,它帮助我获取当前的 ApplicaitonContext。
我不明白为什么我会收到未找到订阅者。 我设置了 auto-startup=false。 获取当前 sftpChannel bean 的正确方法是什么,它给我相同的 applicationContext 实例。
如果我做 appContext = new classpathxmlapplicationcontext(applicationcontext.xml ) 我在 startupBean 中遇到错误,所以我不想那样做。
现在我正在实施 ApplicationContextAware,但我收到消息传递异常。
谁能帮帮我?
我正在使用 spring 3
你脑子里分享了很多,最后你的问题变得一团糟。
让我从另一边解释一下是怎么回事。
因为您在 <int-sftp:outbound-channel-adapter>
上有 auto-startup ="false"
,任何 send
到 sftpChannel
都会导致该异常,直到您启动该适配器。
从另一边我看到你这样做了,虽然我们看不到是谁发起了 contextRefreshEvents
消息,但我们相信你是 <int-event:inbound-channel-adapter>
。
这里还有一点,您没有向我们展示 file from local
。好的,我猜是 <int-file:inbound-channel-adapter>
。这是可轮询的,并在应用程序启动后立即开始轮询本地主管。所以,这可能会导致 Dispatcher has no subscribers
,因为 sftpOutboundAdapter
还没有开始。
如果我的推理有误,请告诉我,但您的预期有所不同。
更新
要以编程方式启动端点(或任何其他 Lifecycle
组件),您应该 inject
它到您的服务:
@Autowired
@Qualifier("sftpOutboundAdapter")
private Lifecycle sftpOutboundAdapter;
....
sftpOutboundAdapter.start();