WildFly Swarm Couchbase Sample
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/main/java/com/couchbase/wildfly/swarm
.gitignore
pom.xml
readme.adoc

readme.adoc

Java Microservice using Couchbase and WildFly Swarm

Start and Configure Couchbase

  1. Start Couchbase Docker container:

    docker run -d --name db -p 8091-8093:8091-8093 -p 11210:11210 arungupta/couchbase
  2. Create primary index on the sample bucket:

    docker run -it --link db:db arungupta/couchbase cbq -u Administrator -p password -engine http://db:8093 -s "create primary index \`travel-sample-primary-index\` on \`travel-sample\`;"

    Output is:

     Connected to : http://db:8093/. Type Ctrl-D or \QUIT to exit.
    
     Path to history file for the shell : /root/.cbq_history
    {
        "requestID": "3312706a-b7fb-451c-ba93-7e861e6a9b45",
        "signature": null,
        "results": [
        ],
        "status": "success",
        "metrics": {
            "elapsedTime": "5.178990295s",
            "executionTime": "5.178966139s",
            "resultCount": 0,
            "resultSize": 0
        }
    }
  3. Check the database:

    docker run -it --link db:db arungupta/couchbase cbq -u Administrator -p password -engine http://db:8093 -s "select * from \`travel-sample\` limit 1;"

    Output is:

     Connected to : http://db:8093/. Type Ctrl-D or \QUIT to exit.
    
     Path to history file for the shell : /root/.cbq_history
    {
        "requestID": "258f18cd-d36d-43b9-9522-f9c38a19dce5",
        "signature": {
            "*": "*"
        },
        "results": [
            {
                "travel-sample": {
                    "callsign": "MILE-AIR",
                    "country": "United States",
                    "iata": "Q5",
                    "icao": "MLA",
                    "id": 10,
                    "name": "40-Mile Air",
                    "type": "airline"
                }
            }
        ],
        "status": "success",
        "metrics": {
            "elapsedTime": "54.567432ms",
            "executionTime": "54.545552ms",
            "resultCount": 1,
            "resultSize": 300
        }
    }

Build and Run the microservice using WildFly Swarm

Using Maven

Build and Run: mvn -DCOUCHBASE_URI=<IP> clean wildfly-swarm:run

where <IP> is the IP address of where Couchbase Server is running. For example, this would be the IP address obtained using docker-machine ip <machine-name>. Default value is localhost.

Using Docker

Build: mvn package -Pdocker

Run: Needs debugging