我得到了一个任务来作一些修改这是十年前开发的spring-integration
项目,我知道它是如何工作的,所以我已经看了一些spring-integration
教程的线索,虽然我没有完全理解我得到了一些基本的它的知识。现在想了解spring-integration
的spring.integration.version 2.2.4.RELEASE
配置的以下片断进行更改之前
<!-- Currency Pull from NetSuite -->
<int:gateway id="currencySyncGateway" service-interface="com.integration.service.INetSuiteCurrencyPullService" default-request-channel="currenciesFromNetSuite" />
<bean id="nsCurrencyPullService" class="com.integration.service.impl.NetSuiteCurrencyPullService" />
<int:channel id="currenciesFromNetSuite" />
<int:service-activator input-channel="currenciesFromNetSuite" ref="nsCurrencyPullService" method="getCurrencies" output-channel="pushCurrenciesToDB" />
<bean id="msSqlCurrencyPushService" class="com.integration.service.impl.MSSQLCurrencyPushService" />
<int:channel id="pushCurrenciesToDB" />
<int:service-activator input-channel="pushCurrenciesToDB" ref="msSqlCurrencyPushService" method="saveCurrenciesToDB" />
以下是在对应的类于上述豆
INetSuiteCurrencyPullService
public interface INetSuiteCurrencyPullService {
List<Currency> getCurrencies(String in);
}
热情Kurren CY推左至右虎钳
public class NetSuiteCurrencyPullService implements INetSuiteCurrencyPullService {
@Autowired
INetSuiteClient restletClient;
@Override
public List<Currency> getCurrencies(String in) {
LOGGER.info("Retrieving currencies from NetSuite...");
PullCurrenciesRestletResponse response = restletClient.pullCurrencies();
LOGGER.debug("Restlet response: {}", response);
if ("SUCCESS".equals(response.getError().getCode())) {
LOGGER.info("Received restlet response: executionTimeMillis=" + response.getExecutionTimeMillis() + ", count=" + response.getCurrencies().size());
return response.getCurrencies();
} else {
String msg = "Error retrieving currencies from NetSuite: " + response.getError().getMessage();
LOGGER.error(msg);
throw new RuntimeException(msg);
}
}
}
MSSQLCurrencyPushService
public class MSSQLCurrencyPushService implements IMSSQLCurrencyPushService {
@Autowired
CurrencyConversionRepository currencyConversionRepository;
@Override
public List<Currency> saveCurrenciesToDB(List<Currency> in) {
// logic to save Currency in DB
return in;
}
}
所以,下面是我的理解,一旦应用程序启动上述spring-integration
配置(请纠正如果错)
1. Spring为INetSuiteCurrencyPullService
首先初始化一个代理对象
2.然后instatiates nsCurrencyPullService
豆
3.然后调用getCurrencies
的nsCurrencyPullService
方法
4.并传递输出到saveCurrenciesToDB
的msSqlCurrencyPushService
方法
请帮我看看我下面的问题
所以上面的步骤Spring应用程序启动时,才执行?
或者是它定期做一次申请是吗?
如果其对定期在哪里可以检查nsCurrencyPullService
invokation的轮询频率进行?
所以上面的步骤Spring应用程序启动时,才执行?
应用程序上下文初始化过程中进行的基础设施(豆)创建一次。的组件使用有线MessageChannel
s一起。当网关被调用时,有效载荷被包裹在一个消息中发送给该信道。默认情况下,通道DirectChannel
s,这意味着该服务直接调用的调用者的线程上。
所述第一服务的输出通过信道向第二服务发送;再次调用程序的线程。该服务的结果返回给调用者的方法调用的结果。
轮询频率
有一个在这种情况下没有轮询;消息被发送到由网关的呼叫者的集成信息流。
现代的方式做同样将与DSL。
@Bean
public IntegrationFlow() {
return IntegrationFlows.from(INetSuiteCurrencyPullService.class)
.handle("bean1", "method1")
.handle("bean2", "method2")
.get();
}