Spring 集成存储过程入站通道适配器

Spring Integration stored-proc-inbound-channel-adapter

我有以下要求。

基于

1.One Spring 的应用程序在一个 Unix 机器上运行,它在一个名为 created_on 的 table.1 列上创建条目,它在创建时保持时间。

2.Another spring 基于集成 的应用程序有 30 个实例 运行 在 3 个不同的 Unix 机器上,每个机器有 10 个实例( 10 个不同的 PID)。所有这些应用程序都配置了 stored-proc-inbound-channel-adapter,它以 1 秒的间隔从上面 table.

中提取数据

table 有一个状态列,一旦记录被存储过程选中,它就会标记为 Y。

存储过程根据创建于且未标记 Y 来选择记录。

我不想使用外部队列在 2 个应用程序之间进行通信。

疑惑:- 1.Is 是否有机会获得多个节点选择的相同记录?

  1. 当 30 个节点尝试访问相同的 table 记录并抛出相同的存储过程时,是否会出现任何性能问题?

1.Is there any chance of getting same record has picked by multiple nodes?

我不知道如何从这里帮助你,但如果所有的逻辑都封装在那个存储过程中,你应该不会有任何问题:只要更新和 select 逻辑是正确的。

2.Is it possible to return the result based on a specific no?

完全不清楚你的问题中 no 是什么,但存储过程确实可以 return 结果 - 原始集或普通 OUT 参数。这已经完全超出了本线程和 Spring 集成责任的范围。

3.How to pass the node name to the spring context(stored-proc-inbound-channel-adapter)?

请研究 Spring 框架中的 Environment 及其相关的 @Value 和属性占位符:https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-environment。因此,您确实可以将一些 属性 传播到存储过程参数中。

  1. Is there going to be any performance issue when 30 nodes try to access same table records threw a same store procedure?

不,那不是。只要您的 RDBMS 供应商支持对数据库的并发访问。

5.How to deal stored-proc-inbound-channel-adapter when no data has been return by the store procedure?

您可以将 AbstractMessageSourceAdvice 之类的东西应用到 stored-proc-inbound-channel-adapterpoller 中,并检查 result 的实现:

/**
 * Subclasses can take actions based on the result of the poll; e.g.
 * adjust the {@code trigger}. The message can also be replaced with a new one.
 * @param result the received message.
 * @param source the message source.
 * @return a message to continue to process the result, null to discard whatever the poll returned.
 */
Message<?> afterReceive(Message<?> result, MessageSource<?> source);