我试图接收带有消息驱动bean的电子邮件。我正在使用jboss wildfly。 Unfortunatley,我找不到真正的文件。这是迄今为止我发现的最多:用于接收电子邮件的MDB
@MessageDriven(activationConfig={
@ActivationConfigProperty(propertyName="mailServer", propertyValue="imap.gmail.com"),
@ActivationConfigProperty(propertyName="mailFolder", propertyValue="INBOX"),
@ActivationConfigProperty(propertyName="storeProtocol", propertyValue="imap"),
@ActivationConfigProperty(propertyName="userName", propertyValue="[email protected]"),
@ActivationConfigProperty(propertyName="password", propertyValue="xxx")
})
@ResourceAdapter("mail-ra.rar")
public class EMailReceiver implements MailListener {
@Override
public void onMessage(Message msg) {
System.out.println("MSG: " + msg.toString());
}
}
我对如何使这项工作有几个问题。对不起,我把它们都归为一个问题,但我相信它们属于一个整体。
- 什么是此ResourceAdapter?我可以找到一个ResourceAdapter类,但不是注释。
- 我在哪里可以得到正确的mail-ra.rar,我在哪里放?我揣测这可能会有不同的版本,我无法在野蝇内找到它。
- 是注释配置足够还是我需要在xml中配置任何东西?
'mail-ra.rar'由IronJacamar项目提供。 AS7有一个[论坛帖子](https://community.jboss.org/message/725319),可能也会帮助Wildfly。 Tbh,在提供的文档中查看几分钟后,我感到害怕,并回到基于定时器的EJB的安全性。既然你使用gmail作为例子,如果你投票(使用计时器服务)而不是对消息作出反应(无论如何将由投票服务产生),我想你可以省下很多工作。 – mabi
谢谢。我想我也会去定时器路线。 MDB看起来很诱人,因为它看起来像一个开箱即用的解决方案。但我想这不是。 – EasterBunnyBugSmasher