【发布时间】:2019-06-29 17:37:53
【问题描述】:
我的任务是对十年前开发的 spring-integration 项目进行一些修改,我知道它是如何工作的,所以我查看了一些 spring-integration 教程,虽然我没有完全理解它 我对它有了一些基本的了解。现在我试图在进行更改之前了解spring.integration.version 2.2.4.RELEASE 的spring-integration 配置的以下sn-p
<!-- 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" />
以下是上述bean对应的类
INetSuiteCurrencyPullService
public interface INetSuiteCurrencyPullService {
List<Currency> getCurrencies(String in);
}
NetSuiteCurrencyPullService
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.然后实例化nsCurrencyPullService bean
3.然后调用nsCurrencyPullService的getCurrencies方法
4.并将输出传递给msSqlCurrencyPushService的saveCurrenciesToDB方法
请帮助我解决以下问题
那么上面的步骤只在spring应用启动的时候进行呢?
还是在应用程序启动后定期执行?
如果它定期执行,我在哪里可以检查nsCurrencyPullService 调用的轮询频率?
【问题讨论】:
标签: java spring spring-integration channel