简体   繁体   English

Solace Queue - 消息应在异常时自动重新传递而无需重新连接会话

[英]Solace Queue - Message should automatically redeliver on exception without reconnecting session

We are planning to use Solace Queue Management.我们计划使用 Solace 队列管理。 One of the usecase is, After receiving message on consumer, if any exception while processing message, Message should be redeliver automatically.用例之一是,在消费者收到消息后,如果在处理消息时出现任何异常,则应自动重新传递消息。

As of now, I am not sending ack to Queue so message will not removed from Queue but unfortunately it's not able to redeliver automatically.到目前为止,我没有向 Queue 发送 ack,因此消息不会从 Queue 中删除,但不幸的是它无法自动重新发送。 If I restart session then only I am able to receive same message.如果我重新启动会话,那么只有我能够收到相同的消息。

I have explore few options ex.我已经探索了几个选项,例如。 session.rollback or session.revoke on exception but it will increased the delivery count of all the messages in the queue. session.rollback 或 session.revoke 异常,但它会增加队列中所有消息的传递计数。 Also there isn't any configuration of delay time to redeliver same message.也没有任何延迟时间配置来重新传递相同的消息。

The expectation is, same message should be redelivered after 30 min (configured delay) automatically.期望是,应在 30 分钟(配置延迟)后自动重新发送相同的消息。

Below is sample code I am using for Consumer:以下是我用于消费者的示例代码:

https://github.com/SolaceSamples/solace-samples-jms/blob/master/src/main/java/com/solace/samples/QueueConsumer.java https://github.com/SolaceSamples/solace-samples-jms/blob/master/src/main/java/com/solace/samples/QueueConsumer.java

@Override
public void onMessage(Message message) {
    try {
        if (message instanceof TextMessage) {
            System.out.printf("TextMessage received: '%s'%n", ((TextMessage) message).getText());
        } else {
            System.out.println("Message received.");
        }
        System.out.printf("Message Content:%n%s%n", SolJmsUtility.dumpMessage(message));

        // ACK the received message manually because of the set SupportedProperty.SOL_CLIENT_ACKNOWLEDGE above
        message.acknowledge();

        latch.countDown(); // unblock the main thread
    } catch (JMSException ex) {
        System.out.println("Error processing incoming message.");
        ex.printStackTrace();
    }
}

Appreciate your support.感谢您的支持。 Thanks谢谢

Solace doesn't support such feature currently. Solace 目前不支持此类功能。 Messages are not redelivered on the application layer.消息不会在应用层重新传递。 They will be redelivered only if the connection (flow to be exact) is reestablished.只有在重新建立连接(准确地说是流)时,它们才会被重新传送。

Solace does redeliver the messages on the transport level. Solace 确实在传输级别重新传递消息。 Purpose of this is to ensure that the messages are delivered to the application buffer.这样做的目的是确保将消息传递到应用程序缓冲区。 From then on, its application's responsibility to process them and ack.从那时起,它的应用程序负责处理它们并确认。 Redelivering beyond that point will lead to duplicate messages on the consumer end - which will be in violation of several protocols including JMS.超过该点重新交付将导致消费者端出现重复消息 - 这将违反包括 JMS 在内的多种协议。

When the application flow is reestablished, any unacked messages can be safely redelivered since we know the original flow it was delivered to can no longer ack the message (and lead to potential dup message delivery).当应用程序流重新建立时,任何未确认的消息都可以安全地重新传递,因为我们知道它被传递到的原始流不能再确认​​消息(并导致潜在的重复消息传递)。

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

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