title: cURL POST command is unresponsive
body: <p>I was learning about the <code>Event Sourcing and CQRS</code> and find a nice video series on Youtube. The series has a code repository given in the <a href="https://github.com/sdaschner/scalable-coffee-shop" rel="nofollow noreferrer">Github</a>. It uses 3 modules (<code>barista</code>, <code>orders</code>, and <code>beans</code>) that talks with each other in the distributedly for managing Coffee orders from the customers. The run instruction is provided as follows, </p>
  
  <blockquote>
    <ol>
    <li><p>Start Apache Kafka brokers, e.g. using Docker compose: <a href="https://github.com/wurstmeister/kafka-docker" rel="nofollow noreferrer">https://github.com/wurstmeister/kafka-docker</a>.
    Configure the <code>KAFKA_ADVERTISED_HOST_NAME</code> to your corresponding IP
    address.</p></li>
    <li><p>Configure each of the <code>kafka.properties</code> files with <code>bootstrap.servers=&lt;your-IP&gt;:9092</code>.</p></li>
    <li><p>Build and run the individual instances. On each of the <code>orders/</code>, <code>beans/</code> and <code>barista/</code> directories, execute <code>build-run-local.sh</code>.
    This builds the Gradle project, builds the Docker image and starts a
    new instance of the given service.</p></li>
    </ol>
  </blockquote>
  
  <p>I follow the steps seamlessly. After I build and run the individual instances, I execute the command, </p>
  
  <pre><code>$ curl http://localhost:8002/beans/resources/beans -i
  
      HTTP/1.1 200 OK
      Connection: keep-alive
      Content-Type: application/json
      Content-Length: 2
      Date: Tue, 08 Jan 2019 13:16:12 GMT
  </code></pre>
  
  <p>Then, I tried to POST a bean with the command, </p>
  
  <pre><code>$ curl http://localhost:8002/beans/resources/beans -i -XPOST \
        -H 'content-type: application/json' \
        -d '{"beanOrigin": "Colombia", "amount": 10}'
  </code></pre>
  
  <p>At this point, the terminal gets hanged and produce no response. I look into the individual modules and see the <code>Dockerfile</code> and the <code>build-run-local.sh</code> with execution instructions. For example, the <code>Dockerfile</code> for the <code>beans</code> module is provided below, </p>
  
  <pre><code>$ cat Dockerfile 
  
    FROM sdaschner/wildfly:javaee8-kafka-b1
  
    COPY build/libs/beans.war $DEPLOYMENT_DIR
  </code></pre>
  
  <p>The <code>beans/build-run-local.sh</code> is provided,</p>
  
  <pre><code>$ cat build-run-local.sh 
  
  #!/bin/bash
  cd ${0%/*}
  set -eu
  
  gradle build
  docker build --rm -t scalable-coffee-shop-beans:1 .
  docker run --rm --name beans -p 8002:8080 scalable-coffee-shop-beans:1
  </code></pre>
  
  <p>When I run the file I get output (initial lnes), </p>
  
  <pre><code>$ ./build-run-local.sh 
  
  BUILD SUCCESSFUL in 0s
  5 actionable tasks: 5 up-to-date
  Sending build context to Docker daemon  310.3kB
  
  Step 1/2 : FROM sdaschner/wildfly:javaee8-kafka-b1
   ---&gt; 7a638cd4a3c8
  
  Step 2/2 : COPY build/libs/beans.war $DEPLOYMENT_DIR
   ---&gt; Using cache
   ---&gt; ef4901bbea66
  Successfully built ef4901bbea66
  Successfully tagged scalable-coffee-shop-beans:1
  =========================================================================
  
    JBoss Bootstrap Environment
  
    JBOSS_HOME: /opt/jboss/wildfly
  
    JAVA: /usr/lib/jvm/java/bin/java
  
    JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true
  </code></pre>
  
  <p>My suspicion is the POST command gets hanged because  I might need more configurations that I'm missing. For example, I haven't configured any of <code>$DEPLOYMENT_DIR</code>, <code>JBOSS_HOME</code> or <code>JAVA_OPTS</code> mentioned earlier. </p>
  
  <p>I admit I have limited experience (or very little) experience with <code>Docker</code>. But, I find this is the command executes the info of the <code>Docker</code> file,</p>
  
  <pre><code># get 2 instructions from the `Dockerfile` and excutes them. 
  $ docker build --rm -t scalable-coffee-shop-beans:1 .
  
  Sending build context to Docker daemon  310.3kB
  Step 1/2 : FROM sdaschner/wildfly:javaee8-kafka-b1
   ---&gt; 7a638cd4a3c8
  
  Step 2/2 : COPY build/libs/beans.war $DEPLOYMENT_DIR
   ---&gt; Using cache
   ---&gt; ef4901bbea66
  Successfully built ef4901bbea66
  Successfully tagged scalable-coffee-shop-beans:1
  </code></pre>
  
  <p>Can anyone help me to run the app properly?   </p>
  
  <p><strong>Update:</strong></p>
  
  <p>I followed the advice from the comment and put the log messages. What I get is:</p>
  
  <pre><code>03:26:12,271 INFO  [com.sebastian_daschner.scalable_coffee_shop.beans.boundary.BeansResource] (default task-1) Bean origin = Colombia , Amount = 10
  
  03:26:12,273 INFO  [com.sebastian_daschner.scalable_coffee_shop.beans.boundary.BeanCommandService] (default task-1) Bean origin = Colombia , Amount = 1
  </code></pre>
  
  <p>So it seems that the <code>com.sebastian_daschner.scalable_coffee_shop.beans.boundary.BeanCommandService</code> did get the info properly and call the method of the class <code>com.sebastian_daschner.scalable_coffee_shop.events.control.EventProducer</code> as follows, </p>
  
  <pre><code>public void storeBeans(final String beanOrigin, final int amount) {
  
  
          LOGGER.log(Level.INFO, "Bean origin = " + beanOrigin +
                  " " + ", Amount = " + amount);
          eventProducer.publish(new BeansStored(beanOrigin, amount));
      }
  </code></pre>
  
  <p>Inside the <code>EventProducer</code>, it calls the <code>publish</code> method which is provided below,</p>
  
  <pre><code>public void publish(CoffeeEvent... events) {
          try {
  
              LOGGER.log(Level.INFO, "Events = " + Arrays.toString(events));
  
              producer.beginTransaction();
              send(events);
              producer.commitTransaction();
          } catch (ProducerFencedException e) {
  
  
              LOGGER.log(Level.SEVERE, e.toString(), e);
              producer.close();
          } catch (KafkaException e) {
  
              LOGGER.log(Level.SEVERE, e.toString(), e);
              producer.abortTransaction();
          }
      }
  </code></pre>
  
  <p>At this point, I dont get any log from the code, </p>
  
  <pre><code>LOGGER.log(Level.INFO, "Events = " + Arrays.toString(events));
  </code></pre>
  
  <p>I assume it's related to Kafka and the code below doesn't execute:</p>
  
  <pre><code>     producer.beginTransaction();
       send(events);
       producer.commitTransaction();
  </code></pre>
  
  <p>As I point it out exactly, does anyone can help now to find out what's wrong?</p>