Сценарий: опросить базу данных каждые «n» секунд и получить список. Сделайте некоторые внутренние проверки бизнеса. Если проверки являются только успешными, отправьте извлеченный список во внешнюю систему. Получите ответ подтверждения от этой системы (после получения этого poller должен отправить следующий список). Затем выполните некоторые бизнес-операции, такие как вызов других систем, опрос не нужен. может ли кто-нибудь рассказать мне, как можно использовать этот сценарий?Весенний опрос + Спящий режим
poller.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
\t xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
\t xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
\t xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
\t xmlns:task="http://www.springframework.org/schema/task" xmlns:int-http="http://www.springframework.org/schema/integration/http"
\t xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-4.1.xsd
http://www.springframework.org/schema/integration/http
http://www.springframework.org/schema/integration/http/spring-integration-http-4.1.xsd
http://www.springframework.org/schema/integration/jdbc
http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc-4.1.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd">
\t <import resource="persistence-config.xml" />
\t <int:channel id="inchannel">
\t </int:channel>
\t <int:channel id="outchannel">
\t <int:dispatcher task-executor="taskExecutor"/>
\t \t </int:channel>
\t \t
\t <task:executor id="taskExecutor" pool-size="2"/>
\t <bean id="poller" class="main.java.com.as.poller.PollerService" />
\t <int:service-activator input-channel="inchannel"
\t \t output-channel="outchannel" ref="poller" method="sendMessage" />
\t <int-jdbc:inbound-channel-adapter
\t \t query="select loyalty_id from TBL_RECEIPT where receipt_status=0"
\t \t channel="inchannel" data-source="dataSource" max-rows-per-poll="1">
\t \t <int:poller fixed-rate="5000">
\t \t </int:poller>
\t </int-jdbc:inbound-channel-adapter>
</beans>
ackage main.java.com.as.poller;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.stereotype.Component;
@Component
public class PollerService{
public void sendMessage()
{
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"AS-servlet.xml");
\t DirectChannel directChannel = (DirectChannel) context.getBean("inchannel");
}
}
Я добавил прямой канал для опроса DB.Also добавил channel..But исполнителем я получаю исключение
Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#0': Cannot resolve reference to bean 'executerChannel' while setting bean property 'outputChannel'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'executerChannel' is defined
rg.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
\t at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
\t at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1477)
\t at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222)
\t at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
\t at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
Может кто-нибудь, пожалуйста, помогите с этим ... Я создал только PollerService.java и не имеют ни малейшего представления, чтобы реализовать Исполнитель канала и задачи Исполнитель
Этот вопрос действительно слишком широк; прочитайте [Справочное руководство по интеграции Spring] (http://docs.spring.io/spring-integration/reference/html/). Когда вы понимаете основные понятия; прочитайте раздел о поддержке JPA. Существует [множество образцов] (https://github.com/spring-projects/spring-integration-samples), включая, по меньшей мере, один, который использует JPA с гибернацией. Когда вы все это сделали, вернитесь сюда, если у вас есть _специфические вопросы. –