1

我正在将应用程序从 Wildfly 10.0.1.0 移植到 Wildly Swarm 2017.7.0。

除了使用 YAML 的 SMTP 电子邮件配置之外,一切都进行得相当顺利:

我尝试了一些替代方案,但这是基于我认为 yaml 来自standalone.xml 映射的最新方案 - project-defaults.yml

swarm:
  socket-binding-groups:
    mail-socket:    
      outbound-socket-bindings:
        mail-smtp:
          remote-host: smtp.someprovider.com
          remote-port: 587

  mail:
    mail-sessions:
      smtpSession:
        jndi-name: java:/smtpSession
        smtp-server:
          username: username_here
          password: password_here
          tls: true
          outbound-socket-binding-ref: mail-smtp

但是我仍然收到错误:

2017-08-05 11:17:36,100 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "mail"),
("mail-session" => "smtpSession") 
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.outbound-socket-binding.mail-smtp"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.mail-session.smtpSession is missing [jboss.outbound-socket-binding.mail-smtp]"]
}
2017-08-05 11:17:36,155 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184:    New missing/unsatisfied dependencies:
  service jboss.outbound-socket-binding.mail-smtp (missing) dependents: [service jboss.mail-session.smtpSession] 

------------------ 2017 年 8 月 7 日编辑 -------------------

根据 Ladicek 的建议,我尝试了这个:

 swarm:
   socket-binding-groups:
     standard-sockets:
       mail-socket:
         outbound-socket-bindings:
           mail-smtp:
             remote-host: smtp.someprovider.com
             remote-port: 587

swarm:
  socket-binding-groups:
    standard-sockets:
      outbound-socket-bindings:
        mail-smtp:
          remote-host: smtp.someprovider.com
          remote-port: 587

swarm:
  socket-binding-groups:
    standard-socket:
      outbound-socket-bindings:
        mail-smtp:
          remote-host: smtp.someprovider.com
          remote-port: 587

但是两者都不起作用,仍然有相同的错误。

有人可以帮忙吗?

- - - - - - - - - - - 解决了 - - - - - - - - - - - - - - -

需要升级到2017.8.1并使用以下配置

network:
  socket-binding-groups:
    standard-sockets:
      outbound-socket-bindings:
        mail-smtp:
          remote-host: smtp.someprovider.com
          remote-port: 587

谢谢你。

4

3 回答 3

0

从我的脑海中,我相信您缺少一个级别的 YAML 结构:您需要选择要添加套接字绑定的套接字绑定组。这是 WildFly 托管域的产物,这是一个不适用于 Swarm 的概念,但您有时会遇到它。在独立的 WildFly 中只有一个套接字绑定组,因此在 Swarm:standard-sockets中。

所以 YAML 看起来像:

swarm:
  socket-binding-groups:
    standard-sockets:
      mail-socket:
        ...

还有关于 Swarm YAML 结构的任何问题,请咨询https://reference.wildfly-swarm.io

于 2017-08-05T07:40:46.497 回答
0

终于解决了:

需要升级到2017.8.1并使用以下配置

network:
  socket-binding-groups:
    standard-sockets:
      outbound-socket-bindings:
        mail-smtp:
        remote-host: smtp.someprovider.com
        remote-port: 587

谢谢你。

于 2017-08-07T08:16:38.807 回答
0

这对我有用。

.yml 文件:

swarm:
  mail:
    mail-sessions:
      mail-socket:
        jndi-name: java:/mail/NGSoftMail
        smtp-server:
          username: sigafco@xxxmail.com.co
          password: *****
          outbound-socket-binding-ref: mail-smtp
        debug: true
        from: sigafco@xxxmail.com.co 

  network:
    socket-binding-groups:
      standard-sockets:
        outbound-socket-bindings:
          mail-smtp:
            remote-host: xxxmail.com.co
            remote-port: 25

.java 文件:

@ApplicationScoped
@Path("mailsender")
public class MailSender {

  @Resource(mappedName = "java:/mail/NGSoftMail")
  private Session session;

  @GET
  @Path("mail")
  public String sendGet() throws Exception {
    Message message = new MimeMessage(session);

    message.setFrom();
    message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("david.vasquez@xxx.com.co", false));
    message.setSubject("asunto!!!");
    message.setSentDate(new Date());
    message.setContent("contenido!!!", "text/html; charset=UTF-8");

    Transport.send(message);

    return String.format("{\"your_mail\": \"%s\"}", "OK");
  }
}

pom文件:

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>mail</artifactId>
</dependency>
于 2017-08-24T17:51:37.170 回答