java如何使用JMS API将NACK从Solace侦听器发送到Solace队列?
需要你的帮助才能找到解决方案。目前的实施细节:
SolConnectionFactory connectionFactory = SolJmsUtility.createConnectionFactory(); // for create connection factory using host , vpn,trust store,keystore with auth scheme AUTHENTICATION_SCHEME_CLIENT_CERTIFICATE
this.connection = connectionFactory.createConnection(); // connection creation
session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); // session creation using client acknowledge
使用MessageListener监听队列
public class MyListener implements MessageListener
public void onMessage(Message message) // receive the message and process
{
/* in this method validating the message (poison message)
* and publish to kafka, once receive the success message
* from kafka acknowledge the message
*/
message.acknowledge();
}
问题:如果卡夫卡经纪人倒台了,如何重试?我们与内部慰藉小组进行了讨论
我们假设如果客户机没有调用message.acknowledge()
Solace将进行重试,但Solace内部团队澄清,它正在使用窗口机制,因此如果后续消息被确认,那么之前的消息也将被确认并删除
他们的建议是将失败消息的NACK(否定确认)发回,然后Solace可以重试该消息。如何使用Java API发送NACK
Max_Un_Ack_Message
和Max_Redeliver_Count
的建议值是多少
Maven Dependence for Solace:
<dependency>
<groupId>com.solacesystems</groupId>
<artifactId>sol-jms</artifactId>
<version>10.0.0</version>
</dependency>
# 1 楼答案
如果您正在使用JMS API,并且希望触发重新交付,那么您有几个选项
你可以使用transacted session。当处理消息成功时,您确认消息并
commit()
确认javax.jms.Session
。处理不成功时,在javax.jms.Session
上调用rollback()
或者,您可以使用^{} 。以下是JavaDoc所说的:
当然,这是假设Solace JMS客户端实际上实现了这里指定的行为
# 2 楼答案
根据讨论here,
message.acknowledge()
与窗口无关。由于在示例中使用的是异步解决方案,因此如果不调用stop()
,传输窗口将关闭,消息将不会得到确认message.acknowledge()
仅用于确认消息已被接收和使用,其中消息已从Solace broker上的持久存储中删除。请注意,未确认的消息只会在下一个要连接的消费者上重新发送