小编ame*_*ste的帖子

Spring集成应用程序和缓存

具有入站http网关和出站http网关的Spring集成应用程序,在我想拥有缓存之间,以避免不必要的请求.我唯一的解决方案是添加拦截器缓存和路由器后,它将cahced结果路由回到回复通道,并且非缓存到出站,但这个解决方案对我来说似乎很棘手和丑陋.当入站网关具有相同的请求和回复通道时,具有缓存的拦截器也很有效(当返回具有相同标头但具有不同有效负载的新消息时,它被视为回复)但不是我可以使用的情况.

对此更好的想法?

java spring spring-integration

3
推荐指数
1
解决办法
1588
查看次数

初始化和弹簧集成通道

我需要在Spring初始化后立即加载一堆数据,只需一次.在我的方案中,我有服务激活器,它与控制总线一起工作(发送消息到控制总线通道).创建在初始化后发送这一堆数据的服务没有帮助,这个96221-jdbc-inbound-channel-adapter-for-doing-only-a-single-query-at-runtime也没有帮助 - 我得到了org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers.试了几种方法,其中包括BeanPostProcessor,MethodInvokingFactoryBean但还是有感觉通道的arent在方法调用的时刻尚未initilized.有什么方法可以解决这个问题?

upd:ApplicationListener<ContextRefreshedEvent>像魔术一样工作.感谢您的建议

upd2:
下面问题部分的配置.诀窍在于cbManager,它向controlBus发送消息,调用providerManager bean的方法.("@providerManager.add(headers.providerConfig)").适用于http-inbound部分,但jdbcPoller任务在初始化时也是如此.ApplicationListener解决了我的问题,但如果有什么我不知道或替代品,我很高兴知道

    <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 …
Run Code Online (Sandbox Code Playgroud)

java spring-integration

2
推荐指数
1
解决办法
2807
查看次数

标签 统计

java ×2

spring-integration ×2

spring ×1