Search code examples
javawildfly-swarm

Equivalent YAML config for API calls


I have been using API to boot up my application successfully and now for some reasons I have to use a hollow uberjar to boot up the application from a separate WAR. As I could not find any references about how to use a custom main method with hollow jar and due to the deprecation notes in 2017.10.1 about main method, I decided to use a YAML config. I did the transformation but I'm getting different errors that show at least the messaging fraction is not picking up the configs. Digging up references did not also help.

Here is the method that works:

        swarm
            // Setup data sources
            .fraction(new DatasourcesFraction()
                    // SWARM BUG: at least one DS without JNDI binding shall be provided ~> https://issues.jboss.org/browse/SWARM-1447
                    .dataSource("def-ds", ds -> {
                        ds.driverName("postgresql");
                        ds.connectionUrl(jdbcUrl);
                        ds.userName("commons_user");
                        ds.password("commonsTestDb");
                        ds.jta(true);
                    })
                    .dataSource("common-ds", ds -> {
                        ds.driverName("postgresql");
                        ds.connectionUrl(jdbcUrl);
                        ds.userName("commons_user");
                        ds.password("commonsTestDb");
                        ds.jndiName("java:/jdbc/dbpool");
                        ds.jta(true);
                    }))

            // Setup JMS
            .outboundSocketBinding("standard-sockets",
                    new OutboundSocketBinding("remote-activemq")
                            .remoteHost("artemis")
                            .remotePort("61616"))


            .fraction(new MessagingFraction()
                    .defaultServer(server -> {

                        server.remoteConnector("remote-activemq", connector -> {
                            connector.socketBinding("remote-activemq");
                        });

                        server.pooledConnectionFactory("remote-activemq", factory -> {
                            factory.connectors("remote-activemq");
                            factory.entries("java:/jms/remote-mq");
                            factory.user("artemis_user");
                            factory.password("artemis_password");
                        });

                        server.jmsTopic("domain-events", topic -> {
                            topic.entries("java:/jms/topic/domain-events");
                        });

                    }))

            .start();

    // deploy JAX-RS resources
    swarm.deploy(
            ShrinkWrap
                    .create(JAXRSArchive.class)
                    .addAllDependencies());

and here is YAML config which is not working:

swarm:

  datasources:

    data-sources:
      # SWARM BUG: at least one DS without JNDI binding shall be provided ~> https://issues.jboss.org/browse/SWARM-1447
      CommonDSDef:
        driver-name: postgresql
        connection-url: "jdbc:postgresql://postgres:5432/commons"
        user-name: commons_user
        password: commonsTestDb
        jta: true

      CommonDS:
        driver-name: postgresql
        connection-url: "jdbc:postgresql://postgres:5432/commons"
        user-name: commons_user
        password: commonsTestDb
        jndi-name: java:/jdbc/dbpool
        jta: true

  network:
    socket-binding-groups:
      standard-sockets:
        outbound-socket-bindings:
              remote-activemq:
                remote-host: artemis
                remote-port: 61616

  messaging:
    servers:
      default:
        remote-connectors:
            remote-activemq:
              socket-binding: remote-activemq

        pooled-connection-factories:
            remote-activemq:
              connectors: remote-activemq
              entries: java:/jms/remote-mq
              user: artemis_user
              password: artemis_password

        jms-topics:
            domain-events:
              entries: java:/jms/topic/domain-events


  deployment:
    dummy-app:
      jaxrs:
        application-path: /

while trying to use the config, I get following error in logs:

    2017-10-28 19:36:31,219 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "commons-mocks-2.0.0-SNAPSHOT.war")) - failure description: {
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.ra.remote-activemq"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"commons-mocks-2.0.0-SNAPSHOT.war\".component.DummyDomainEventListener.CREATE is missing [jboss.ra.remote-activemq]"]
}
    2017-10-28 19:36:31,221 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "commons-mocks-2.0.0-SNAPSHOT.war" was rolled back with the following failure message: 
{
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.ra.remote-activemq"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"commons-mocks-2.0.0-SNAPSHOT.war\".component.DummyDomainEventListener.CREATE is missing [jboss.ra.remote-activemq]"]
}

after that a bunch of other related errors are thrown out and eventually the server stops.


Solution

  • The issue with datasources is filed under https://issues.jboss.org/browse/SWARM-1486 and I added an explanation there.

    The issue with messaging is a documentation problem -- the correct name is messaging-activemq. This was fixed already in the documentation refactoring: http://docs.wildfly-swarm.io/2017.11.0-SNAPSHOT/#_messaging