简体   繁体   English

WSO2 2.2.0 Message Broker中的消息重试和死信队列

[英]Message retry and Dead Letter Queue in WSO2 2.2.0 Message Broker

We are evaluating the WSO2 stack and in particular the Message Broker v 2.2.0 and are not able to make the message retry limit work. 我们正在评估WSO2堆栈,尤其是Message Broker v 2.2.0,并且无法使消息重试限制起作用。

According to this documentation page, once the client has rejected a message 10 times it will be removed from the queue and placed on the dead letter queue. 根据此文档页面,一旦客户端拒绝一条消息10次,它将被从队列中删除并放置在死信队列中。

https://docs.wso2.com/display/MB220/Maximum+Delivery+Attempts https://docs.wso2.com/display/MB220/Maximum+Delivery+Attempts

Out definition of rejection is either: 拒绝的明确定义是:
a) Not sending acknowledgement in the case of using Session.CLIENT_ACKNOWLEDGE or a)在使用Session.CLIENT_ACKNOWLEDGE或的情况下不发送确认
b) Rolling back the transaction in the case of using a transacted session. b)在使用事务处理会话的情况下回滚事务。

Using the WSO2 example client code we are unable to observe this behaviour using any combination of client acknowledgement modes or induced failures. 使用WSO2示例客户端代码,我们无法使用客户端确认模式或诱发故障的任何组合来观察此行为。 The message remains active in the queue and can be taken from it any number of times. 该消息在队列中保持活动状态,并且可以从其中多次获取。 Acknowledging it or committing the session removes it from the queue as you would expect. 确认它或提交会话将其从队列中删除,正如您所期望的那样。

Can anyone confirm if this feature actually works and if so, show us what a client has to do to trigger it. 任何人都可以确认此功能是否确实有效,如果可以,请告诉我们客户必须做些什么才能触发它。 We have been testing using the WSO2 provided sample client code and an unmodified out-of-the-box server config: 我们一直在使用WSO2提供的示例客户端代码和未修改的现成服务器配置进行测试:

https://docs.wso2.com/display/MB220/Sending+and+Receiving+Messages+Using+Queues https://docs.wso2.com/display/MB220/Sending+and+Receiving+Messages+Using+Queues

Any help would be appreciated as we are unable to continue with WSO2 without understanding exactly how this aspect of the system works. 我们将无法继续使用WSO2,而不能完全了解系统的这一方面如何工作,因此将不胜感激。

This feature is working as expected. 此功能按预期工作。 In order to test that you need to do some modification to the provided receiver client in the sample code. 为了测试您需要对示例代码中提供的接收器客户端进行一些修改。

  1. Add the given system property 添加给定的系统属性
  2. Change the abknlowdgment mode to CLIENT_ACK 将取消模式更改为CLIENT_ACK
  3. Get the message for 10 times without sending the ACK to server 获取消息10次,而无需将ACK发送到服务器

With these changes you can cater your requirement. 通过这些更改,您可以满足您的要求。

Here I am posting the modified method in the QueueReceiver class 在这里,我将修改后的方法发布到QueueReceiver类中

public void receiveMessages() throws NamingException, JMSException {
    Properties properties = new Properties();
    System.setProperty("AndesAckWaitTimeOut", "30000");
    properties.put(Context.INITIAL_CONTEXT_FACTORY, QPID_ICF);
    properties.put(CF_NAME_PREFIX + CF_NAME, getTCPConnectionURL(userName, password));
    System.out.println("getTCPConnectionURL(userName,password) = " + getTCPConnectionURL(userName, password));
    InitialContext ctx = new InitialContext(properties);
    // Lookup connection factory
    QueueConnectionFactory connFactory = (QueueConnectionFactory) ctx.lookup(CF_NAME);
    QueueConnection queueConnection = connFactory.createQueueConnection();
    queueConnection.start();
    QueueSession queueSession =
            queueConnection.createQueueSession(false, QueueSession.CLIENT_ACKNOWLEDGE);
    //Receive message
    Queue queue =  queueSession.createQueue(queueName);
    MessageConsumer queueReceiver = queueSession.createConsumer(queue);
    int count =0;
    while (count < 12) {
        TextMessage message = (TextMessage) queueReceiver.receive();
        System.out.println("Got message ==>" + message.getText());
        count++;
    }
    queueReceiver.close();
    queueSession.close();
    queueConnection.stop();
    queueConnection.close();
}

Please note that this modification is done for just proofing that the feature is working. 请注意,完成此修改只是为了证明该功能正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM