WildFly Swarm: Vert.x API


License

License

AL2
Categories

Categories

WildFly Container Application Servers
GroupId

GroupId

org.wildfly.swarm
ArtifactId

ArtifactId

vertx-api
Last Version

Last Version

1.0.0.Alpha1
Release Date

Release Date

Type

Type

jar
Description

Description

WildFly Swarm: Vert.x API
WildFly Swarm: Vert.x API
Project Organization

Project Organization

JBoss by Red Hat

Download vertx-api

How to add to project

<!-- https://jarcasting.com/artifacts/org.wildfly.swarm/vertx-api/ -->
<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>vertx-api</artifactId>
    <version>1.0.0.Alpha1</version>
</dependency>
// https://jarcasting.com/artifacts/org.wildfly.swarm/vertx-api/
implementation 'org.wildfly.swarm:vertx-api:1.0.0.Alpha1'
// https://jarcasting.com/artifacts/org.wildfly.swarm/vertx-api/
implementation ("org.wildfly.swarm:vertx-api:1.0.0.Alpha1")
'org.wildfly.swarm:vertx-api:jar:1.0.0.Alpha1'
<dependency org="org.wildfly.swarm" name="vertx-api" rev="1.0.0.Alpha1">
  <artifact name="vertx-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.wildfly.swarm', module='vertx-api', version='1.0.0.Alpha1')
)
libraryDependencies += "org.wildfly.swarm" % "vertx-api" % "1.0.0.Alpha1"
[org.wildfly.swarm/vertx-api "1.0.0.Alpha1"]

Dependencies

compile (6)

Group / Artifact Type Version
org.wildfly.swarm : spi-api jar
org.wildfly.swarm : vertx-modules jar 1.0.0.Alpha1
org.wildfly.swarm : resource-adapters-api jar
org.wildfly.swarm : messaging-api jar
io.vertx : vertx-core jar
io.vertx : vertx-jca-api jar

test (1)

Group / Artifact Type Version
junit : junit jar

Project Modules

There are no modules declared in this project.

WildFly Swarm - Vert.x

Build Status License Maven Central

This fraction adds support for the Vert.x API in Java EE applications by enabling the Vert.x JCA adapter.

Enable Vert.x

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>vertx</artifactId>
</dependency>

Overview

The general purpose of a JCA resource adapter is to provide connectivity to an Enterprise Information System (EIS) from a Java EE application server. Specifically, the Vert.x JCA adapter provides both outbound and inbound connectivity with a Vert.x instance.

Outbound Connectivity

An application component (e.g Servlet, EJB), can send messages to a Vert.x instance.

Usage:

@Resource(mappedName="java:/eis/VertxConnectionFactory")
VertxConnectionFactory connFactory;

public void sendMessage() throws Exception { 
    try (VertxConnection conn = connFactory.getVertxConnection()) {
        conn.vertxEventBus().send("tacos", "Hello from JCA");
    }
}
  • NOTE: as with any JCA resource, always call the close() method when your work is complete to allow the connection to be returned to the pool. This will not close the underly Vert.x instance. Please see the JCA specification for my details.

Inbound Connectivity

Since the JCA 1.5 specification, inbound connectivity is provided via a listener interface which can be implemented by a Java EE Message Driven Bean (MDB). As opposed to the default JMS listener type, the Vert.x JCA listener interface allows an MDB to receive messages from a Vert.x address.

The endpoint of the MDB implements interface: io.vertx.resourceadapter.inflow.VertxListener.

package io.vertx.resourceadapter.examples.mdb;

import io.vertx.resourceadapter.inflow.VertxListener;
import io.vertx.core.eventbus.Message;

import java.util.logging.Logger;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;

import org.jboss.ejb3.annotation.ResourceAdapter;


@MessageDriven(name = "VertxMonitor",
        messageListenerInterface = VertxListener.class,
        activationConfig = {
                @ActivationConfigProperty(propertyName = "address", propertyValue = "tacos"),
                @ActivationConfigProperty(propertyName = "clusterHost", propertyValue = "localhost"),
                @ActivationConfigProperty(propertyName = "clusterPort", propertyValue = "0"),
})
@ResourceAdapter("vertx-ra")
public class VertxMonitor implements VertxListener {

   private static final Logger logger = Logger.getLogger(VertxMonitor.class.getName());

    /**
     * Default constructor.
     */
    public VertxMonitor() {
        logger.info("VertxMonitor started.");
    }

   @Override
   public <T> void onMessage(Message<T> message) {
      logger.info("Get a message from Vert.x at address: " + message.address());

      T body = message.body();

      if (body != null) {
         logger.info("Body of the message: " + body.toString());
      }
   }
}
org.wildfly.swarm

WildFly Swarm

WildFly deconstructed

Versions

Version
1.0.0.Alpha1