如何安排JMS Listener的onMessage()方法

时间:2017-03-23 09:54:51

标签: jms spring-jms spring-scheduled

我希望我的听众能够在' x'分钟,我已经通过了 @Scheduled 注释Spring,但我不确定如何将它与jms监听器一起使用,如果有人输入同样的话我会很感激 -

Here is my code snippet of Consumer

@Override @Scheduled(cron="0 */x * * * *")
  public void onMessage(Message message) {
   try {
    LOG.info("+++++++++++++++++++++++++++++++");
    MailMessageObject response = (MailMessageObject)messageConverter.fromMessage(message);
    LOG.info("Application : failed message as a response: {}", response);
    LOG.info("+++++++++++++++++++++++++++++++");
// Here we are getting failed message, again create mail and will           // send thru java mail
            SendMessageHelper help = new SendMessageHelper();
            help.abstractEmailSender(response);

    }

1 个答案:

答案 0 :(得分:1)

它不起作用 - 监听器是消息驱动的,并且只要收到消息就会运行。

如果您想根据计划提取邮件,请使用JmsTemplate.receive(...)方法(在没有邮件时使用超时处理)。