JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Use Agile By Default
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Create Issue
  • Mule
  • MULE-6220

concurrency issues with http endpoints

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 3.1.2
  • Fix Version/s: None
  • Component/s: Core: Concurrency / Threading, Transport: HTTP(S) / Jetty
  • Labels:
    None
  • Environment:

    Java 5, Mule 3.1.2 StandAlone

  • User impact:
    Very High
  • Configuration:
    Hide

    <?xml version="1.0" encoding="UTF-8"?>
    <mule xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:https="http://www.mulesoft.org/schema/mule/https"
    xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xsi:schemaLocation="
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.1/mule-http.xsd
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd">

    <flow name="http-test-flow" >
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="test" encoding="ISO-8859-1"/>

    <http:outbound-endpoint exchange-pattern="request-response" method="GET" address="http://localhost:8080/#[header:INBOUND:http.request]" encoding="ISO-8859-1"/>
    </flow>

    </mule>

    Show
    <?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:http="http://www.mulesoft.org/schema/mule/http" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.1/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd"> <flow name="http-test-flow" > <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="test" encoding="ISO-8859-1"/> <http:outbound-endpoint exchange-pattern="request-response" method="GET" address="http://localhost:8080/#[header:INBOUND:http.request]" encoding="ISO-8859-1"/> </flow> </mule>
  • Log Output:
    Hide
    /**
     * Demonstrate Mule concurrency issues when using http endpoints.
     *
     * Just serve two text files containing the single character '1' and '2'
     * from a web server.
     *
     * Test against the web server. See it OK
     * Test against Mule. See it KO.
     */
    package test;

    import java.util.Vector;

    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.HttpStatus;
    import org.apache.commons.httpclient.methods.GetMethod;


    public class Test {


    private static String PORT = "8080";

    private static String URL1 = "http://localhost:" + PORT + "/test/1.txt";
    private static String URL2 = "http://localhost:" + PORT + "/test/2.txt";

    private static byte ONE = '0' + 1;
    private static byte TWO = '0' + 2;

        private static int NUMBER_OF_THREADS=100;
        
        protected static Thread dotest(int i) {
            return (new Thread() {
                public void run() {
                
                 String url = (getThreadId() % 2 == 0) ? URL1 : URL2;
                
                 GetMethod get = new GetMethod(url);
                 HttpClient client = new HttpClient();
                 try {
    int status = client.executeMethod(get);
    if (status==HttpStatus.SC_OK){
                     byte b[] = new byte[1];
                     get.getResponseBodyAsStream().read(b, 0, 1);
    if (URL1.equals(url) && b[0] != ONE) {
    System.out.println("KO "+ URL1 + " thread: "+ getThreadId() + " byte: " + b[0]);
    System.exit(-1);
    } else if(URL2.equals(url) && b[0] != TWO) {
    System.out.println("KO "+ URL2 + " thread: "+ getThreadId() + " byte: " + b[0]);
    System.exit(-1);
    }else {
    System.out.println("OK " + getThreadId() + " url=" + url + " byte: " + b[0]);
    }
    } else {
    System.out.println("HTTP Status " + status);
    }
                 } catch(Exception e){
                 e.printStackTrace();
                 }
                }
            });
        }

        private static Vector<Thread> v=new Vector<Thread>();
        
        public static void main(String [] args) throws Exception {
         long startTime=System.currentTimeMillis();
            for(int i=0;i<NUMBER_OF_THREADS;i++) {
                Thread t=dotest(i);
                t.start();
                v.add(t);
            }

            for(int i=0;i<v.size();i++) {
                Thread t=(Thread) v.get(i);
                t.join();
            }
            
            System.out.println("Time: "+(System.currentTimeMillis()-startTime));
        }
        
    private static long getThreadId() {
    return Thread.currentThread().getId();
    }
        
      
    }
    Show
    /**  * Demonstrate Mule concurrency issues when using http endpoints.  *  * Just serve two text files containing the single character '1' and '2'  * from a web server.  *  * Test against the web server. See it OK  * Test against Mule. See it KO.  */ package test; import java.util.Vector; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; public class Test { private static String PORT = "8080"; private static String URL1 = "http://localhost:" + PORT + "/test/1.txt"; private static String URL2 = "http://localhost:" + PORT + "/test/2.txt"; private static byte ONE = '0' + 1; private static byte TWO = '0' + 2;     private static int NUMBER_OF_THREADS=100;          protected static Thread dotest(int i) {         return (new Thread() {             public void run() {                           String url = (getThreadId() % 2 == 0) ? URL1 : URL2;                           GetMethod get = new GetMethod(url);              HttpClient client = new HttpClient();              try { int status = client.executeMethod(get); if (status==HttpStatus.SC_OK){                  byte b[] = new byte[1];                  get.getResponseBodyAsStream().read(b, 0, 1); if (URL1.equals(url) && b[0] != ONE) { System.out.println("KO "+ URL1 + " thread: "+ getThreadId() + " byte: " + b[0]); System.exit(-1); } else if(URL2.equals(url) && b[0] != TWO) { System.out.println("KO "+ URL2 + " thread: "+ getThreadId() + " byte: " + b[0]); System.exit(-1); }else { System.out.println("OK " + getThreadId() + " url=" + url + " byte: " + b[0]); } } else { System.out.println("HTTP Status " + status); }              } catch(Exception e){              e.printStackTrace();              }             }         });     }     private static Vector<Thread> v=new Vector<Thread>();          public static void main(String [] args) throws Exception {      long startTime=System.currentTimeMillis();         for(int i=0;i<NUMBER_OF_THREADS;i++) {             Thread t=dotest(i);             t.start();             v.add(t);         }         for(int i=0;i<v.size();i++) {             Thread t=(Thread) v.get(i);             t.join();         }                  System.out.println("Time: "+(System.currentTimeMillis()-startTime));     }      private static long getThreadId() { return Thread.currentThread().getId(); }         }
  • Similar Issues:
    None

Description

Problem with http

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    Test.java
    14/Jun/12 10:05 AM
    3 kB
    j j
  2. Java Source File
    Test.java
    10/May/12 12:05 PM
    3 kB
    j j

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions
  • Commits
  • Source
  • Builds
No work has yet been logged on this issue.

People

  • Assignee:
    Unassigned
    Reporter:
    j j
Vote (0)
Watch (3)

Dates

  • Created:
    10/May/12 12:03 PM
    Updated:
    17/May/13 03:29 PM

Agile

  • View on Board
  • Atlassian JIRA (v5.0.7#734-sha1:8ad78a6)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for MuleForge. Try JIRA - bug tracking software for your team.