SMPP连接池和SmppSessionFactoryBean

时间:2015-11-12 09:56:28

标签: spring spring-integration smpp

我正在使用int-smpp:outbound-gateway并提供SmppSessionFactoryBean。 到目前为止,这是一个单一的租户系统,但我被要求使这个多租户。所以我认为我需要为不同的租户smpp连接创建一个连接池。这是smpp出站网关可能的吗?

我想我可以创建一个SmppSessionBeanFactory来接收SmppSessionFactoryBean,如果它不存在则创建一个Smpp会话,如果它存在则从池中获取它。

有更好的方法吗?

#更新

这基本上就是我想做的事情

<int:channel id="smppSessionFactoryChannel"/>

<int:header-enricher id=""
    input-channel="smppSessionFactoryChannel" output-channel="smppOutBoundGatewayChannel">
    <int:header name="smppSession" ref="SmppSessionFactoryBeanFactory" method="getObject"/>
</int:header-enricher>

<int:channel id="smppOutBoundGatewayChannel"/>

<int-smpp:outbound-gateway id="smppOutBoundGateway"
    reply-channel="nullChannel" source-address=""
    request-channel="smppOutBoundGatewayChannel">
    <int-smpp:session value="#{headers[smppSession]}"/>
</int-smpp:outbound-gateway>

1 个答案:

答案 0 :(得分:0)

使用会话工厂可能更容易使用ThreadLocal来确定用于消息的会话(基于租户) - 在适配器的上游设置线程本地,使用它来获取/创建会话,完成后将其删除。

这不需要对网关本身进行任何更改。

使用dynamic ftp sample中的技术也可能更容易实现。

该机制为每个租户提供一个小的从属上下文,并使用动态路由器来选择将请求发送到哪个。