Index: trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListener.java
===================================================================
--- trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListener.java	(revision 1614)
+++ trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListener.java	(revision 1991)
@@ -27,4 +27,5 @@
 
 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorExchangeHandler;
+import de.ugoe.cs.autoquest.httpmonitor.IdGenerator;
 import de.ugoe.cs.autoquest.plugin.http.logdata.Address;
 import de.ugoe.cs.autoquest.plugin.http.logdata.Content;
@@ -46,6 +47,8 @@
  * recording an exchange can not be done in one step. This is due to the fact, that the proxy
  * servlet notifies different processing states for requests and response. An exchange listener
- * records all these event. On the occurrence of the final event, it compiles an
- * {@link HttpExchange} and forwards it to the exchange handler.
+ * records all these events. On the occurrence of the final event, it compiles an
+ * {@link HttpExchange} and forwards it to the exchange handler. When receiving the first event
+ * of the request, it also determines a respective ordering id. The same applies for the response.
+ * The ordering ids are retrieved from a provided id generator.
  * </p>
  * 
@@ -63,8 +66,22 @@
     /**
      * <p>
+     * the id generator used to generate ordering ids for requests and responses
+     * </p>
+     */
+    private IdGenerator idGenerator;
+    
+    /**
+     * <p>
      * the request of compiled exchange
      * </p>
      */
     private HttpServletRequest request;
+    
+    /**
+     * <p>
+     * the ordering id for the request
+     * </p>
+     */
+    private long requestOrderingId;
 
     /**
@@ -81,4 +98,11 @@
      */
     private HttpServletResponse response;
+    
+    /**
+     * <p>
+     * the ordering id for the response
+     * </p>
+     */
+    private long responseOrderingId;
 
     /**
@@ -99,10 +123,13 @@
      * <p>
      * initialized the exchange listener with the exchange handler to forward compiled exchanges to
+     * and the id generator to be used for generating ordering ids for requests and responses
      * </p>
      * 
      * @param exchangeHandler the exchange handler to forward compiled exchanges to
-     */
-    ExchangeListener(HttpMonitorExchangeHandler exchangeHandler) {
+     * @param idGenerator     the id generator to used for generating ordering ids
+     */
+    ExchangeListener(HttpMonitorExchangeHandler exchangeHandler, IdGenerator idGenerator) {
         this.exchangeHandler = exchangeHandler;
+        this.idGenerator = idGenerator;
     }
 
@@ -123,4 +150,5 @@
         lastUpdate = System.currentTimeMillis();
         this.request = request;
+        this.requestOrderingId = idGenerator.getNextId();
     }
 
@@ -159,4 +187,5 @@
         lastUpdate = System.currentTimeMillis();
         this.response = response;
+        this.responseOrderingId = idGenerator.getNextId();
     }
     
@@ -239,6 +268,6 @@
         exchange.setReceiver(address);
         
-        exchange.setRequest(map(request, eventObjectFactory));
-        exchange.setResponse(map(response, eventObjectFactory));
+        exchange.setRequest(map(request, requestOrderingId, eventObjectFactory));
+        exchange.setResponse(map(response, responseOrderingId, eventObjectFactory));
         
         exchangeHandler.handleHttpExchange(exchange);
@@ -250,6 +279,10 @@
      * </p>
      */
-    private HttpRequest map(HttpServletRequest request, ObjectFactory eventObjectFactory) {
+    private HttpRequest map(HttpServletRequest request,
+                            long               requestOrderingId,
+                            ObjectFactory      eventObjectFactory)
+    {
         HttpRequest eventRequest = eventObjectFactory.createHttpRequest();
+        eventRequest.setOrderingId(requestOrderingId);
         eventRequest.setMethod(Method.fromValue(request.getMethod()));
         eventRequest.setProtocol(Protocol.fromValue(request.getProtocol()));
@@ -311,8 +344,12 @@
      * </p>
      */
-    private HttpResponse map(HttpServletResponse response, ObjectFactory eventObjectFactory) {
+    private HttpResponse map(HttpServletResponse response,
+                             long                responseOrderingId,
+                             ObjectFactory       eventObjectFactory)
+    {
         HttpResponse eventResponse = eventObjectFactory.createHttpResponse();
         
         eventResponse.setStatus(BigInteger.valueOf(response.getStatus()));
+        eventResponse.setOrderingId(responseOrderingId);
 
         Headers headers = eventObjectFactory.createHeaders();
Index: trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListenerManager.java
===================================================================
--- trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListenerManager.java	(revision 1614)
+++ trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListenerManager.java	(revision 1991)
@@ -30,4 +30,5 @@
 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorException;
 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorExchangeHandler;
+import de.ugoe.cs.autoquest.httpmonitor.IdGenerator;
 import de.ugoe.cs.autoquest.plugin.http.logdata.Status;
 import de.ugoe.cs.util.console.Console;
@@ -60,4 +61,11 @@
     /**
      * <p>
+     * the id generator used to generate ordering ids for requests and responses
+     * </p>
+     */
+    private IdGenerator idGenerator;
+    
+    /**
+     * <p>
      * the mapping of requests handled by the proxy to the respective exchange listeners
      * </p>
@@ -79,7 +87,9 @@
      * 
      * @param exchangeHandler the exchange handler to be forwarded to the exchange listeners
-     */
-    ExchangeListenerManager(HttpMonitorExchangeHandler exchangeHandler) {
+     * @param idGenerator     the id generator to used for generating ordering ids
+     */
+    ExchangeListenerManager(HttpMonitorExchangeHandler exchangeHandler, IdGenerator idGenerator) {
         this.exchangeHandler = exchangeHandler;
+        this.idGenerator = idGenerator;
     }
 
@@ -219,5 +229,5 @@
                 if (listener == null) {
                     Console.traceln(Level.FINEST, "creating exchange listener for " + request);
-                    listener = new ExchangeListener(exchangeHandler); 
+                    listener = new ExchangeListener(exchangeHandler, idGenerator); 
                     listeners.put(request, listener);
                 }
Index: trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteConnection.java
===================================================================
--- trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteConnection.java	(revision 1991)
+++ trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteConnection.java	(revision 1991)
@@ -0,0 +1,212 @@
+//   Copyright 2012 Georg-August-Universität Göttingen, Germany
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+
+package de.ugoe.cs.autoquest.httpmonitor.proxy;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.api.Response.CompleteListener;
+import org.eclipse.jetty.client.api.Result;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+
+import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent;
+import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorException;
+import de.ugoe.cs.util.console.Console;
+
+/**
+ * <p>
+ * This is a base class that combines common implementations required for connecting to a central
+ * HTTP monitoring server. The class allows for sending HTTP requests to the central server and
+ * waiting for the asynchronous response.
+ * </p>
+ * 
+ * @author Patrick Harms
+ */
+public abstract class HttpMonitorRemoteConnection implements CompleteListener, HttpMonitorComponent
+{
+    
+    /**
+     * <p>
+     * the HTTP client used internally to send data to the central server
+     * </p>
+     */
+    private HttpClient httpClient;
+    
+    /**
+     * <p>
+     * the host name of the central server
+     * </p>
+     */
+    private String httpMonitorServer;
+    
+    /**
+     * <p>
+     * the port of the central server
+     * </p>
+     */
+    private int httpMonitorPort;
+
+    /**
+     * <p>
+     * a map of requests send to the central server and the corresponding result.
+     * Initially, the result mapped to a request is null until the result is received.
+     * </p>
+     */
+    private Map<Request, Result> openRequests = new HashMap<>();
+    
+    /**
+     * <p>
+     * initializes the exchange handler with the host and port of the central server
+     * </p>
+     *
+     * @param httpMonitorServer the host name of the central server
+     * @param httpMonitorPort   the port of the central server
+     */
+    public HttpMonitorRemoteConnection(String httpMonitorServer, int httpMonitorPort) {
+        this.httpMonitorServer = httpMonitorServer;
+        this.httpMonitorPort = httpMonitorPort;
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#init()
+     */
+    @Override
+    public void init() throws IllegalStateException, HttpMonitorException {
+        httpClient = createHttpClient();
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#start()
+     */
+    @Override
+    public void start() throws IllegalStateException, HttpMonitorException {
+        try {
+            httpClient.start();
+            httpClient.getContentDecoderFactories().clear();
+        }
+        catch (Exception e) {
+            throw new HttpMonitorException("could not start client for HTTP-Monitor", e);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#stop()
+     */
+    @Override
+    public void stop() {
+        if (httpClient != null) {
+            try {
+                httpClient.stop();
+            }
+            catch (Exception e) {
+                Console.traceln(Level.WARNING, "could not stop client for HTTP-Monitor");
+                Console.logException(e);
+            }
+        }
+        
+        httpClient = null;
+    }
+
+    /**
+     * <p>
+     * creates a new request that can be used by subclasses to send something to the central server
+     * </p>
+     *
+     * @return as described
+     */
+    protected Request newRequest() {
+        return httpClient.newRequest(httpMonitorServer, httpMonitorPort);
+    }
+
+    /**
+     * <p>
+     * used to send a request to the central server. The request is stored internally to be able
+     * to wait for the result.
+     * </p>
+     *
+     * @param httpMonitorRequest the request to be sent to the central server
+     */
+    protected synchronized void sendRequest(Request httpMonitorRequest) {
+        openRequests.put(httpMonitorRequest, null);
+        httpMonitorRequest.send(this);
+    }
+
+    /**
+     * <p>
+     * used to synchronously wait for the result of a given request.
+     * </p>
+     *
+     * @param httpMonitorRequest the request for which the result shall be waited for
+     * 
+     * @return the result of the request or null, if no result was received after 30 seconds
+     */
+    protected synchronized Result getResult(Request httpMonitorRequest) {
+
+        try {
+            // wait for the result of the request to be added to the map asynchronously
+            int count = 30;
+            while (openRequests.containsKey(httpMonitorRequest) &&
+                   (openRequests.get(httpMonitorRequest) == null))
+            {
+                this.wait(1000);
+                
+                if (--count == 0) {
+                    // after 30 seconds, cancel the sending of the request
+                    openRequests.remove(httpMonitorRequest);
+                    break;
+                }
+            }
+        }
+        catch (InterruptedException e) {
+            // ignore, as this may only happen on system shutdown
+        }
+
+        return openRequests.get(httpMonitorRequest);
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jetty.client.api.Response.CompleteListener#onComplete(Result)
+     */
+    @Override
+    public synchronized void onComplete(Result result) {
+        openRequests.put(result.getRequest(), result);
+        this.notify();
+    }
+
+    /**
+     * <p>
+     * convenience method to create an initialize the utilized HTTP client
+     * </p>
+     */
+    private HttpClient createHttpClient() {
+        HttpClient client = new HttpClient();
+        
+        QueuedThreadPool executor = new QueuedThreadPool(10);
+        executor.setName("HttpMonitorClients");
+        client.setExecutor(executor);
+
+        client.setMaxConnectionsPerDestination(10000);
+        client.setIdleTimeout(30000);
+        client.setConnectTimeout(30000);
+        client.setStopTimeout(30000);
+        client.setRequestBufferSize(1024*1024);
+        client.setResponseBufferSize(1024*1024);
+        
+        return client;
+    }
+}
Index: trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteExchangeHandler.java
===================================================================
--- trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteExchangeHandler.java	(revision 1614)
+++ trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteExchangeHandler.java	(revision 1991)
@@ -17,6 +17,4 @@
 import java.io.IOException;
 import java.io.OutputStreamWriter;
-import java.util.HashSet;
-import java.util.Set;
 import java.util.logging.Level;
 
@@ -25,16 +23,11 @@
 import javax.xml.bind.Marshaller;
 
-import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.api.Response.CompleteListener;
 import org.eclipse.jetty.client.api.Result;
 import org.eclipse.jetty.client.util.OutputStreamContentProvider;
 import org.eclipse.jetty.http.HttpMethod;
 import org.eclipse.jetty.http.HttpVersion;
-import org.eclipse.jetty.util.thread.QueuedThreadPool;
 
 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitor;
-import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent;
-import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorException;
 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorExchangeHandler;
 import de.ugoe.cs.autoquest.plugin.http.logdata.HttpExchange;
@@ -48,5 +41,5 @@
  * request/response. It then creates an HTTP request to the central monitor and sends it there.
  * It is initialized with the name of the server and the port on which the central monitor runs.
- * If the exchanges can not be forwarded to the central server, they are discarded.
+ * If the exchanges cannot be forwarded to the central server, they are discarded.
  * </p>
  * 
@@ -54,34 +47,7 @@
  */
 public class HttpMonitorRemoteExchangeHandler
-    implements CompleteListener, HttpMonitorExchangeHandler, HttpMonitorComponent
+    extends HttpMonitorRemoteConnection
+    implements HttpMonitorExchangeHandler
 {
-
-    /**
-     * <p>
-     * the HTTP client used internally to send data to the central server
-     * </p>
-     */
-    private HttpClient httpClient;
-    
-    /**
-     * <p>
-     * the host name of the central server
-     * </p>
-     */
-    private String httpMonitorServer;
-    
-    /**
-     * <p>
-     * the port of the central server
-     * </p>
-     */
-    private int httpMonitorPort;
-
-    /**
-     * <p>
-     * a set of requests send to the central server for which the response was not received yet
-     * </p>
-     */
-    private Set<Request> openRequests = new HashSet<Request>();
     
     /**
@@ -94,46 +60,5 @@
      */
     public HttpMonitorRemoteExchangeHandler(String httpMonitorServer, int httpMonitorPort) {
-        this.httpMonitorServer = httpMonitorServer;
-        this.httpMonitorPort = httpMonitorPort;
-    }
-
-    /* (non-Javadoc)
-     * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#init()
-     */
-    @Override
-    public void init() throws IllegalStateException, HttpMonitorException {
-        httpClient = createHttpClient();
-    }
-
-    /* (non-Javadoc)
-     * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#start()
-     */
-    @Override
-    public void start() throws IllegalStateException, HttpMonitorException {
-        try {
-            httpClient.start();
-            httpClient.getContentDecoderFactories().clear();
-        }
-        catch (Exception e) {
-            throw new HttpMonitorException("could not start client for HTTP-Monitor", e);
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#stop()
-     */
-    @Override
-    public void stop() {
-        if (httpClient != null) {
-            try {
-                httpClient.stop();
-            }
-            catch (Exception e) {
-                Console.traceln(Level.WARNING, "could not stop client for HTTP-Monitor");
-                Console.logException(e);
-            }
-        }
-        
-        httpClient = null;
+        super(httpMonitorServer, httpMonitorPort);
     }
 
@@ -144,5 +69,5 @@
     public synchronized void handleHttpExchange(HttpExchange httpExchange) {
         // send the exchange to the server and wait for completion
-        Request httpMonitorRequest = httpClient.newRequest(httpMonitorServer, httpMonitorPort);
+        Request httpMonitorRequest = super.newRequest();
         httpMonitorRequest.method(HttpMethod.POST);
         httpMonitorRequest.version(HttpVersion.HTTP_1_1);
@@ -151,6 +76,5 @@
         httpMonitorRequest.content(out);
         
-        openRequests.add(httpMonitorRequest);
-        httpMonitorRequest.send(this);
+        super.sendRequest(httpMonitorRequest);
 
         try {
@@ -173,28 +97,8 @@
             Console.logException(e);
         }
-
-        try {
-            // wait for the request to be removed from the list asynchronously
-            int count = 30;
-            while (openRequests.contains(httpMonitorRequest)) {
-                this.wait(1000);
-                
-                if (--count == 0) {
-                    // after 30 seconds, cancel the sending of the loggin request
-                    openRequests.remove(httpMonitorRequest);
-                    break;
-                }
-            }
-        }
-        catch (InterruptedException e) {
-            // ignore, as this may only happen on system shutdown
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.jetty.client.api.Response.CompleteListener#onComplete(Result)
-     */
-    @Override
-    public synchronized void onComplete(Result result) {
+        
+        // wait to ensure that the request was received
+        Result result = super.getResult(httpMonitorRequest);
+        
         if (result.isFailed()) {
             Console.traceln
@@ -202,29 +106,4 @@
             Console.logException((Exception) result.getFailure());
         }
-        
-        openRequests.remove(result.getRequest());
-        this.notify();
-    }
-
-    /**
-     * <p>
-     * convenience method to create an initialize the utilized HTTP client
-     * </p>
-     */
-    private HttpClient createHttpClient() {
-        HttpClient client = new HttpClient();
-        
-        QueuedThreadPool executor = new QueuedThreadPool(10);
-        executor.setName("HttpMonitorClients");
-        client.setExecutor(executor);
-
-        client.setMaxConnectionsPerDestination(10000);
-        client.setIdleTimeout(30000);
-        client.setConnectTimeout(30000);
-        client.setStopTimeout(30000);
-        client.setRequestBufferSize(1024*1024);
-        client.setResponseBufferSize(1024*1024);
-        
-        return client;
     }
 }
Index: trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteIdGenerator.java
===================================================================
--- trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteIdGenerator.java	(revision 1991)
+++ trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteIdGenerator.java	(revision 1991)
@@ -0,0 +1,122 @@
+//   Copyright 2012 Georg-August-Universität Göttingen, Germany
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+
+package de.ugoe.cs.autoquest.httpmonitor.proxy;
+
+import java.util.logging.Level;
+
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.api.Result;
+import org.eclipse.jetty.client.api.Response.CompleteListener;
+import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpVersion;
+
+import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent;
+import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorException;
+import de.ugoe.cs.autoquest.httpmonitor.IdGenerator;
+import de.ugoe.cs.autoquest.httpmonitor.SimpleIdGenerator;
+import de.ugoe.cs.util.console.Console;
+
+/**
+ * <p>
+ * if a central monitoring server is used by the proxy, then this id generator is a connection to
+ * the server to receive centrally unique ordering ids from the central server. If the central
+ * server cannot be reached, this id generated uses a fallback internal {@link SimpleIdGenerator}.
+ * </p>
+ * 
+ * @author Patrick Harms
+ */
+public class HttpMonitorRemoteIdGenerator
+    extends HttpMonitorRemoteConnection
+    implements CompleteListener, IdGenerator, HttpMonitorComponent
+{
+    /** the fall back id generator used internally if the server is not reachable*/
+    private IdGenerator fallBackIdGenerator = new SimpleIdGenerator();
+    
+    /**
+     * <p>
+     * initializes the id generator with the host and port of the central server from which to
+     * retrieve the ids
+     * </p>
+     *
+     * @param httpMonitorServer the host name of the central server
+     * @param httpMonitorPort   the port of the central server
+     */
+    public HttpMonitorRemoteIdGenerator(String httpMonitorServer, int httpMonitorPort) {
+        super(httpMonitorServer, httpMonitorPort);
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.httpmonitor.proxy.HttpMonitorRemoteConnection#init()
+     */
+    @Override
+    public void init() throws IllegalStateException, HttpMonitorException {
+        fallBackIdGenerator.init();
+        super.init();
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.httpmonitor.proxy.HttpMonitorRemoteConnection#start()
+     */
+    @Override
+    public void start() throws IllegalStateException, HttpMonitorException {
+        fallBackIdGenerator.start();
+        super.start();
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.httpmonitor.proxy.HttpMonitorRemoteConnection#stop()
+     */
+    @Override
+    public void stop() {
+        super.stop();
+        fallBackIdGenerator.stop();
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.httpmonitor.IdGenerator#getNextId()
+     */
+    @Override
+    public synchronized long getNextId() {
+        Request httpMonitorRequest = super.newRequest();
+        httpMonitorRequest.method(HttpMethod.GET);
+        httpMonitorRequest.version(HttpVersion.HTTP_1_1);
+        super.sendRequest(httpMonitorRequest);
+
+        Result result = super.getResult(httpMonitorRequest);
+        
+        if (result.isFailed()) {
+            Console.traceln
+                (Level.WARNING, "could not retrieve next id correctly: " + result.getFailure());
+            Console.logException((Exception) result.getFailure());
+            
+            Console.traceln(Level.WARNING, "using fallback, i.e., internal id generator");
+            return fallBackIdGenerator.getNextId();
+        }
+        else {
+            try {
+                return result.getResponse().getHeaders().getLongField("X-AutoQUEST-OrderingId");
+            }
+            catch (NumberFormatException e) {
+                Console.traceln(Level.WARNING, "could not retrieve next id correctly: " + e);
+                Console.logException(e);
+                
+                Console.traceln(Level.WARNING, "using fallback, i.e., internal id generator");
+                return fallBackIdGenerator.getNextId();
+            }
+        }
+        
+    }
+
+}
Index: trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxy.java
===================================================================
--- trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxy.java	(revision 1614)
+++ trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxy.java	(revision 1991)
@@ -22,6 +22,8 @@
 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorLogManager;
 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorServer;
+import de.ugoe.cs.autoquest.httpmonitor.IdGenerator;
 import de.ugoe.cs.autoquest.httpmonitor.Runner;
 import de.ugoe.cs.autoquest.httpmonitor.ShutdownHook;
+import de.ugoe.cs.autoquest.httpmonitor.SimpleIdGenerator;
 import de.ugoe.cs.util.console.Console;
 
@@ -29,8 +31,11 @@
  * <p>
  * The HTTP monitory proxy monitor starts a web server ({@link HttpMonitorServer}) that receives
- * proxies HTTP messages and response. Each exchange of a request and a response is forwarded to
+ * proxied HTTP messages and response. Each exchange of a request and a response is forwarded to
  * an exchange handler. The exchange handler is either a local log manager
  * ({@link HttpMonitorLogManager}) or a connection to an external and central HTTP monitor via
- * an {@link HttpMonitorRemoteExchangeHandler}. The class ensures that on shutdown e.g. caused
+ * an {@link HttpMonitorRemoteExchangeHandler}. It also holds a reference to an id generator. If
+ * the exchanges are handled locally, then also a local {@link SimpleIdGenerator} is used. If
+ * the exchanges are send to a central HTTP monitor, then this monitor is used as id generator via
+ * an {@link HttpMonitorRemoteIdGenerator}. The class ensures that on shutdown e.g. caused
  * by CTRL-C the server and all other requied components are stopped correctly.
  * </p>
@@ -59,4 +64,9 @@
      */
     private HttpMonitorExchangeHandler exchangeHandler;
+    
+    /**
+     *  the id generator used to generate order ids for the requests and responses
+     */
+    private IdGenerator idGenerator;
     
     /**
@@ -170,8 +180,11 @@
             exchangeHandler =
                 new HttpMonitorRemoteExchangeHandler(httpMonitorServer, httpMonitorPort);
+            
+            idGenerator = new HttpMonitorRemoteIdGenerator(httpMonitorServer, httpMonitorPort);
         }
         else {
             Console.println("storing logs locally into directory " + logFileBaseDir);
             exchangeHandler = new HttpMonitorLogManager(logFileBaseDir);
+            idGenerator = new SimpleIdGenerator();
         }
     }
@@ -187,6 +200,7 @@
         
         exchangeHandler.init();
-        
-        exchangeListenerManager = new ExchangeListenerManager(exchangeHandler);
+        idGenerator.init();
+        
+        exchangeListenerManager = new ExchangeListenerManager(exchangeHandler, idGenerator);
         exchangeListenerManager.init();
         
@@ -205,5 +219,7 @@
     @Override
     public synchronized void start() {
-        if ((exchangeHandler == null) || (exchangeListenerManager == null) || (server == null)) {
+        if ((exchangeHandler == null) || (idGenerator == null) ||
+            (exchangeListenerManager == null) || (server == null))
+        {
             throw new IllegalStateException("not initialized.");
         }
@@ -212,4 +228,5 @@
             Runtime.getRuntime().addShutdownHook(shutdownHook);
             exchangeHandler.start();
+            idGenerator.start();
             exchangeListenerManager.start();
             server.start();
@@ -226,5 +243,7 @@
     @Override
     public synchronized void stop() {
-        if ((exchangeHandler == null) || (exchangeListenerManager == null) || (server == null)) {
+        if ((exchangeHandler == null) || (idGenerator == null) ||
+            (exchangeListenerManager == null) || (server == null))
+        {
             throw new IllegalStateException("not initialized.");
         }
@@ -233,8 +252,10 @@
         server.stop();
         exchangeListenerManager.stop();
+        idGenerator.stop();
         exchangeHandler.stop();
         
         server = null;
         exchangeListenerManager = null;
+        idGenerator = null;
         exchangeHandler = null;
     }
