备份服务器不断向主服务器发送 keepAlive 消息。主服务器回复消息“嘿,我还在运行。”。如果没有回复,则备份服务器接管并启动一个新的消息驱动适配器。
- 如何在 Spring Integration 中有效地实现这一点?
- 如何从我的代码启动消息驱动适配器,而不是由 Spring ApplicationContext 自动启动。
更新:这是我目前的方法:
发件人:
<si:inbound-channel-adapter id="keepAlivePoller" channel="keepAliveChannel" method="sendMessage" >
<bean class="com.keepAlive.KeepAliveSender"/>
<si:poller fixed-rate="${keepalive.sendinterval}" max-messages-per-poll="1"></si:poller>
</si:inbound-channel-adapter>
这是我的接收器:
<si:channel id="pollKeepChannel">
<si:queue/>
</si:channel>
<int-jms:message-driven-channel-adapter id="keepAliveMessageAdapter"
channel="pollKeepChannel" destination="keepAlive" connection-factory="connectionFactory"
max-concurrent-consumers="2" auto-startup="true" acknowledge="transacted" extract-payload="true"/>
<si:service-activator id="keepAliveServiceActivator" input-channel="pollKeepChannel" ref="keepAliveService" method="process">
<int:poller />
</si:service-activator>
<bean id="keepAliveService" class="com.keepAlive.KeepAliveService"/>
<bean id="keepAlive"
class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="PREM_KEEPALIVE" />
</bean>
我想 1) 以某种方式接收来自发送服务器的回复。2)当回复没有到来时,以某种方式调用服务(?)。