Java 在ACTIVEMQ中为计划消息使用_AMQ_SCHED_DELIVERY属性

Java 在ACTIVEMQ中为计划消息使用_AMQ_SCHED_DELIVERY属性,java,rabbitmq,activemq,Java,Rabbitmq,Activemq,我正在想办法推迟邮件的发送。我遇到了插件,因为它是在实验阶段,我正在寻找其他的选择 从中,我看到我们可以设置_AMQ_SCHED_DELIVERY属性来延迟消息,但这似乎不起作用 以下是从中获取的生产者和消费者代码 及 但信息正在迅速传递: Sent message At: Mon Sep 14 17:37:01 IST 2015 Received: Hello world! From: Thread-0 : 746036857 at: Mon Sep 14 17:37:01 IST 2015

我正在想办法推迟邮件的发送。我遇到了插件,因为它是在实验阶段,我正在寻找其他的选择

从中,我看到我们可以设置_AMQ_SCHED_DELIVERY属性来延迟消息,但这似乎不起作用

以下是从中获取的生产者和消费者代码

但信息正在迅速传递:

Sent message At: Mon Sep 14 17:37:01 IST 2015
Received: Hello world! From: Thread-0 : 746036857 at: Mon Sep 14 17:37:01 IST 2015
从上面的链接可以清楚地看出,ActiveMQ支持调度具有不同延迟的单个消息,但我能够找到正确的方法


另外,如果您能将RabbitMQ的延迟消息支持与ActiveMQ的支持进行比较,我们将不胜感激。

ActiveMQ代理确实支持延迟消息传递,但不使用与Rabbit相同的属性,谷歌搜索文档将非常容易地显示这一点。此功能的文档如下所示,以供将来参考:


_AMQ_SCHED_交付实际上是ActiveMQ的属性,而不是RabbitMQ的属性。阅读文档或查看源代码,您会发现它不是ActiveMQ Artemis的一部分,而不是ActiveMQ的一部分。是啊,这个名字真让人困惑。为了增加混淆,ActiveMQ Artemis调用其客户机API类如下:ActiveMQ.Artemis包的ActiveMQInitialContextFactory部分,但您通常查看类名而不是包名。此外,一些嵌入ActiveMQ Artemis的产品,如JBoss EAP/Wildfly,在中仅将其称为“消息传递ActiveMQ”
 public static class HelloWorldConsumer implements Runnable, ExceptionListener {
    public void run() {
        try {

            // Create a ConnectionFactory
            ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");

            // Create a Connection
            Connection connection = connectionFactory.createConnection();
            connection.start();

            connection.setExceptionListener(this);

            // Create a Session
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

            // Create the destination (Topic or Queue)
            Destination destination = session.createQueue("TEST.FOO");

            // Create a MessageConsumer from the Session to the Topic or Queue
            MessageConsumer consumer = session.createConsumer(destination);

            // Wait for a message
            Message message = consumer.receive(40000);

            if (message instanceof TextMessage) {
                TextMessage textMessage = (TextMessage) message;
                String text = textMessage.getText();
                System.out.println("Received: " + text + " at: " + new Date(System.currentTimeMillis()));
            } else {
                System.out.println("Received: " + message);
            }

            consumer.close();
            session.close();
            connection.close();
        } catch (Exception e) {
            System.out.println("Caught: " + e);
            e.printStackTrace();
        }
    }
Sent message At: Mon Sep 14 17:37:01 IST 2015
Received: Hello world! From: Thread-0 : 746036857 at: Mon Sep 14 17:37:01 IST 2015