I need to load bunch of data right after spring initialization, just once.
In my scheme i have service activator that works with control bus (sends messages to control bus channel).
Creating service that sends this bunch of data after initialization doesnt help, this 96221-jdbc-inbound-channel-adapter-for-doing-only-a-single-query-at-runtime doesnt help also - Im getting org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
. Tried several ways, including BeanPostProcessor
, MethodInvokingFactoryBean
but still have feeling channels arent initilized yet at moment of method call.
Any ways to solve this problem?
upd: ApplicationListener<ContextRefreshedEvent>
worked as magic. Thx for advice
upd2:
config of problem part below. The trick is in cbManager, that sends message to controlBus, calling method of providerManager bean. ("@providerManager.add(headers.providerConfig)"
).
Works good with http-inbound part, but jdbcPoller task is to do same in initialization. ApplicationListener
solved my problem but if there is something i dont know or alternatives, Id be glad to know
<int:control-bus input-channel="controlBusMainChannel"/>
<int:channel id="controlBusMainChannel" />
<int:channel id="cbRequests" />
<int:channel id="cbReplies" />
<int:channel id="postRequests" />
<bean id="cbManager" class ="com.dph.hlss.bus.ViaBusProviderManager">
<constructor-arg name="channel" ref="controlBusMainChannel" />
</bean>
<int-http:inbound-gateway id="cbPostController"
request-channel="cbRequests"
reply-channel="cbReplies"
path="/controlbus/providers"
request-payload-type="com.dph.hlss.bus.providermanager.model.ProviderAddDTO"
supported-methods="POST"
payload-expression="body"
>
<int-http:header name="requestId" expression="T(java.util.UUID).randomUUID().toString()"/>
</int-http:inbound-gateway>
<int:service-activator input-channel="cbRequests" ref="cbInbound"/>
<int:gateway id="cbInbound" default-request-channel="cbInbRequests" error-channel="cbErrorHandleMessages" />
<int:transformer input-channel="cbErrorHandleMessages" output-channel="cbReplies" ref="errorTransformer" method="transform"/>
<int:payload-type-router input-channel="cbInbRequests" >
<int:mapping type="com.dph.hlss.bus.providermanager.model.ProviderAddDTO" channel="postRequests"/>
</int:payload-type-router>
<int:service-activator id="addProvider" input-channel="postRequests" output-channel="cbReplies" ref="cbManager" method="add" />
<bean id="providerManager" class="com.dph.hlss.bus.ProviderCommandManagment" >
<property name="providerManager" ref="searchProviderManager"/>
<property name="factory" ref="abstractProvidersFactory" />
</bean>
<bean id="jdbcPoller" class="com.dph.hlss.bus.JDBCPoller" >
<property name="accepter" ref="cbManager" />
</bean>
<bean class="com.dph.interfaces.spring.SpringBeanLauncher">
<property name="launchableBean" ref="jdbcPoller" />
<property name="contextId" value="/search-facade" />
<property name="rootContextId" value="org.springframework.web.context.WebApplicationContext:" />
</bean>