Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/Makefile.in
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/Makefile.in	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/Makefile.in	(revision 617)
@@ -13,5 +13,5 @@
 
 CFLAGS=@DEB_DEF@  -fpic ${GLIB_CPPFLAGS} ${YAML_CFLAGS} ${MACOS_CFLAGS} ${MS_CFLAGS} -I../../thirds/cgic206 -I. -DLINUX_FREE_ISSUE #-DDEBUG #-DDEBUG_SERVICE_CONF
-LDFLAGS=  -lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${GLIB_LDFLAGS}  ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${YAML_LDFLAGS} 
+LDFLAGS=  -lcurl -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${GLIB_LDFLAGS}  ${RABBITMQ_LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS}  ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} -lfcgi -lcrypto ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${YAML_LDFLAGS} ${JSON_LDFLAGS} ${MYSQL_LDFLAGS}
 
 PHPCFLAGS=@PHP_CPPFLAGS@
@@ -25,4 +25,14 @@
 PERL_ENABLED=@PERL_ENABLED@
 PERL_FILE=@PERL_FILE@
+
+JSON_LDFLAGS=@JSON_LDFLAGS@
+JSON_CPPFLAGS=@JSON_CPPFLAGS@
+
+RABBITMQ_LDFLAGS=@RABBITMQ_LDFLAGS@
+RABBITMQ_CPPFLAGS=@RABBITMQ_CPPFLAGS@
+
+MYSQL_LDFLAGS=@MYSQL_LDFLAGS@
+MYSQL_CPPFLAGS=@MYSQL_CPPFLAGS@
+
 
 
@@ -62,4 +72,14 @@
 	g++ ${GLIB_CPPFLAGS} ${XML2CFLAGS} -c service_zcfg.c
 
+zoo_json.o:	zoo_json.c service.h
+	g++ ${JSON_CPPFLAGS} ${XML2CFLAGS} -c zoo_json.c
+
+zoo_amqp.o: zoo_amqp.c
+	g++ ${CFLAGS} -c zoo_amqp.c
+
+zoo_sql.o: zoo_sql.c
+	g++ ${MYSQL_CPPFLAGS} -c zoo_sql.c
+
+
 service_internal.o: service_internal.c service.h
 	g++ ${GDAL_CFLAGS} ${JS_ENABLED} ${JSCFLAGS} ${XML2CFLAGS} ${CFLAGS} -fPIC -c service_internal.c
@@ -93,9 +113,9 @@
 
 zoo_service_loader.o: zoo_service_loader.c service.h
-	g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
+	g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} ${JSON_CPPFLAGS} -c zoo_service_loader.c  -fno-common -DPIC -o zoo_service_loader.o
 
-zoo_loader.cgi: version.h zoo_loader.c service_zcfg.o zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE}
-	g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS}  ${PERLCFLAGS} ${RUBYCFLAGS}  ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} -c zoo_loader.c  -fno-common -DPIC -o zoo_loader.o
-	g++  ${JSCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_loader.o service_zcfg.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE}  ${PERL_FILE} ${PHP_FILE}  ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}
+zoo_loader.cgi: version.h zoo_loader.c zoo_sql.o zoo_amqp.o zoo_json.o service_zcfg.o zoo_service_loader.o  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE}
+	g++ -g -O2 ${JSCFLAGS} ${PHPCFLAGS}  ${PERLCFLAGS} ${RUBYCFLAGS}  ${JAVACFLAGS} ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS}  ${JSON_CPPFLAGS} -c zoo_loader.c  -fno-common -DPIC -o zoo_loader.o
+	g++  ${JSCFLAGS} ${GDAL_CFLAGS} ${XML2CFLAGS} ${PHPCFLAGS} ${PERLCFLAGS} ${JAVACFLAGS} ${PYTHONCFLAGS} ${CFLAGS} zoo_sql.o zoo_amqp.o zoo_json.o zoo_loader.o service_zcfg.o zoo_service_loader.o service_internal.o ${MS_FILE} ${PYTHON_FILE}  ${PERL_FILE} ${PHP_FILE}  ${JS_FILE} ${JAVA_FILE} ${YAML_FILE} ulinet.o lex.cr.o lex.sr.o service_conf.tab.o main_conf_read.tab.o -o zoo_loader.cgi ${LDFLAGS}
 
 zcfg2yaml: zcfg2yaml.c  ulinet.o service.h lex.sr.o service_conf.tab.o service_conf.y ulinet.o main_conf_read.tab.o lex.cr.o service_internal.o ${MS_FILE} ${JS_FILE} ${RUBY_FILE}  ${YAML_FILE}
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/bdd/schema.sql
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/bdd/schema.sql	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/bdd/schema.sql	(revision 617)
@@ -8,5 +8,6 @@
     end_date DATETIME,
     progress int,
-    info TEXT
+    info TEXT,
+    identifier TEXT
     );
 
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/configure.ac
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/configure.ac	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/configure.ac	(revision 617)
@@ -15,4 +15,5 @@
 AC_CHECK_LIB([pthread], [main])
 AC_CHECK_LIB([ssl], [main])
+
 
 # Checks for header files.
@@ -135,4 +136,45 @@
 AC_SUBST([FCGI_CPPFLAGS])
 AC_SUBST([FCGI_LDFLAGS])
+
+
+# ===========================================================================
+# Detect if json-c is available
+# ===========================================================================
+
+AC_CHECK_LIB([json-c], [main])
+JSON_LDFLAGS=`pkg-config --libs json-c`
+JSON_CPPFLAGS=`pkg-config --cflags json-c`
+
+AC_SUBST([JSON_LDFLAGS])
+AC_SUBST([JSON_CPPFLAGS])
+
+
+
+
+# ===========================================================================
+# Detect if librabbitmq is available
+# ===========================================================================
+
+
+AC_CHECK_LIB([rabbitmq], [main])
+RABBITMQ_LDFLAGS=`pkg-config --libs librabbitmq`
+RABBITMQ_CPPFLAGS=`pkg-config --cflags librabbitmq`
+
+AC_SUBST([RABBITMQ_LDFLAGS])
+AC_SUBST([RABBITMQ_CPPFLAGS])
+
+# ===========================================================================
+# Detect if libmysql is available
+# ===========================================================================
+
+
+AC_CHECK_LIB([mysqlclient], [main])
+MYSQL_LDFLAGS=`mysql_config --libs`
+MYSQL_CPPFLAGS=`mysql_config --cflags`
+
+AC_SUBST([MYSQL_LDFLAGS])
+AC_SUBST([MYSQL_CPPFLAGS])
+
+
 
 # ===========================================================================
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/main.cfg
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/main.cfg	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/main.cfg	(revision 617)
@@ -1,5 +1,5 @@
 [server]
-req_worker=10
-async_worker=10
+req_worker=1
+async_worker=1
 max_requests=200
 listen=/tmp/zoo.sock
@@ -10,5 +10,23 @@
 uid=65534
 gid=65534
-#rootDir=/var/www/zoo-wps/cgi-bin
+rootDir=/var/www/zoo-wps/cgi-bin
+
+[rabbitmq]
+host=192.168.1.167
+port=5672
+user=david
+passwd=pass
+exchange=amq.direct
+routingkey=zoo
+queue=zoo_service_queue
+
+
+[status]
+driver=mysql
+user=david
+passwd=pass
+bdd=zoo_status
+host=127.0.0.1
+port=3306
 
 [headers]
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal.c	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/service_internal.c	(revision 617)
@@ -1977,6 +1977,10 @@
   xmlDocSetRootElement (doc, nr);
 
-  if (hasStoredExecuteResponse == true)
-    {
+
+  map * background = NULL;
+  background = getMapFromMaps(m,"lenv","background");
+
+    if (background != NULL){
+        /* requete asynchrone */
       /* We need to write the ExecuteResponse Document somewhere */
       FILE *output = fopen (stored_path, "w");
@@ -2006,6 +2010,7 @@
       fclose (output);
     }
+    else {
   printDocument (m, doc, pid,out);
-
+    }
   xmlCleanupParser ();
   zooXmlCleanupNs ();
@@ -2031,6 +2036,10 @@
    */
   xmlDocDumpFormatMemoryEnc (doc, &xmlbuff, &buffersize, encoding, 1);
-  FCGX_FPrintF(out,(char *)xmlbuff);
-  FCGX_FFlush(out);
+  
+  
+  if (out != NULL){
+    FCGX_FPrintF(out,(char *)xmlbuff);
+    FCGX_FFlush(out);
+    }
   //printf ("%s", xmlbuff);
   //fflush (stdout);
@@ -3687,4 +3696,5 @@
   if (fsize == 0)
     {
+      
       return errorException (*m, _("Unable to download the file."),
                              "InternalError", NULL,NULL);
@@ -3699,7 +3709,9 @@
   free (tmpMap->value);
   tmpMap->value = (char *) malloc ((fsize + 1) * sizeof (char));
-  if (tmpMap->value == NULL)
+  if (tmpMap->value == NULL){
+
     return errorException (*m, _("Unable to allocate memory."),
                            "InternalError", NULL,NULL);
+  }
   memcpy (tmpMap->value, fcontent, (fsize + 1) * sizeof (char));
 
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.c
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.c	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.c	(revision 617)
@@ -1,2 +1,27 @@
+/**
+ * Author : David Saggiorato
+ *
+ *  Copyright 2008-2009 GeoLabs SARL. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
 #include <string.h>
 #include <stdio.h>
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.h
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.h	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.h	(revision 617)
@@ -1,2 +1,27 @@
+/**
+ * Author : David Saggiorato
+ *
+ *  Copyright 2008-2009 GeoLabs SARL. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
 #ifndef ZOO_JSON_H
 #define ZOO_JSON_H 1
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_loader.c
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_loader.c	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_loader.c	(revision 617)
@@ -67,5 +67,13 @@
 
 #include "service_zcfg.h"
+#include "zoo_json.h"
+#include "zoo_amqp.h"
+#include "zoo_sql.h"
 //#include "service_internal.h"
+
+
+void
+loadServiceAndRun (maps ** myMap, service * s1, map * request_inputs,
+                   maps ** inputs, maps ** ioutputs, int *eres,FCGX_Stream *out, FCGX_Stream *err);
 
 xmlXPathObjectPtr extractFromDoc (xmlDocPtr, const char *);
@@ -100,5 +108,4 @@
       int pid = getpid();
       struct cgi_env *cgi;
-      //PrintEnv(request.err, "Request environment", request.envp); 
       cgi = (struct cgi_env*)malloc(sizeof(struct cgi_env));
       cgiMain_init (NULL, NULL,&cgi,request);
@@ -455,5 +462,10 @@
       if (strQuery != NULL)
         free (strQuery);
-
+/*
+      json_object *obj;
+      maptojson(&obj,tmpMap);
+      fprintf(stderr,"%s\n",json_object_to_json_string(obj));
+      fflush(stderr);
+  */    
       runRequest (&tmpMap,&cgi,request);
 
@@ -525,5 +537,15 @@
     return 1;
   }
-
+/* 
+ json_object *jobj;
+  mapstojson(&jobj,conf);
+  fprintf (stderr,"The json object created: %s\n",json_object_to_json_string(jobj));
+    freeMaps(&conf);
+ 
+  maps *conf_tmp;
+  jsontomaps(jobj,&conf_tmp);
+  dumpMaps(conf_tmp);
+   return 1;
+*/
   char *rootDir;
   map *m_rootDir = getMapFromMaps (conf, "server", "rootDir");
@@ -684,4 +706,155 @@
     }
   }
+
+
+  char * amqp_host;
+  map * m_amqp_host = getMapFromMaps (conf, "rabbitmq", "host");
+  if (m_amqp_host == NULL){
+    fprintf(stderr,"Configuration error: [rabbitmq] host");
+    return 2;
+  }
+  else {
+    amqp_host = (char *)malloc((strlen(m_amqp_host->value) +1)*sizeof(char*));
+    strncpy(amqp_host,m_amqp_host->value,strlen(m_amqp_host->value));
+    amqp_host[strlen(m_amqp_host->value)] = '\0';
+ }
+
+  int amqp_port;
+  map *m_amqp_port = getMapFromMaps (conf, "rabbitmq", "port");
+  if (m_amqp_port == NULL){
+    fprintf(stderr,"Configuration error: [rabbitmq] port");
+    return 2;
+  }
+  else {
+    amqp_port = atoi(m_amqp_port->value);
+    if (amqp_port == 0){
+        fprintf(stderr,"Configuration error: [rabbitmq] port");
+        return 2;
+    }
+  }
+
+  char * amqp_user;
+  map * m_amqp_user = getMapFromMaps (conf, "rabbitmq", "user");
+  if (m_amqp_user == NULL){
+    fprintf(stderr,"Configuration error: [rabbitmq] user");
+    return 2;
+  }
+  else {
+    amqp_user = (char *)malloc((strlen(m_amqp_user->value) +1)*sizeof(char*));
+    strncpy(amqp_user,m_amqp_user->value,strlen(m_amqp_user->value));
+    amqp_user[strlen(m_amqp_user->value)] = '\0';
+ }
+
+  char * amqp_passwd;
+  map * m_amqp_passwd = getMapFromMaps (conf, "rabbitmq", "passwd");
+  if (m_amqp_passwd == NULL){
+    fprintf(stderr,"Configuration error: [rabbitmq] passwd");
+    return 2;
+  }
+  else {
+    amqp_passwd = (char *)malloc((strlen(m_amqp_passwd->value) +1)*sizeof(char*));
+    strncpy(amqp_passwd,m_amqp_passwd->value,strlen(m_amqp_passwd->value));
+    amqp_passwd[strlen(m_amqp_passwd->value)] = '\0';
+ }
+
+  char * amqp_exchange;
+  map * m_amqp_exchange = getMapFromMaps (conf, "rabbitmq", "exchange");
+  if (m_amqp_exchange == NULL){
+    fprintf(stderr,"Configuration error: [rabbitmq] exchange");
+    return 2;
+  }
+  else {
+    amqp_exchange = (char *)malloc((strlen(m_amqp_exchange->value) +1)*sizeof(char*));
+    strncpy(amqp_exchange,m_amqp_exchange->value,strlen(m_amqp_exchange->value));
+    amqp_exchange[strlen(m_amqp_exchange->value)] = '\0';
+ }
+
+  char * amqp_routingkey;
+  map * m_amqp_routingkey = getMapFromMaps (conf, "rabbitmq", "routingkey");
+  if (m_amqp_routingkey == NULL){
+    fprintf(stderr,"Configuration error: [amqp] routingkey");
+    return 2;
+  }
+  else {
+    amqp_routingkey = (char *)malloc((strlen(m_amqp_routingkey->value) +1)*sizeof(char*));
+    strncpy(amqp_routingkey,m_amqp_routingkey->value,strlen(m_amqp_routingkey->value));
+    amqp_routingkey[strlen(m_amqp_routingkey->value)] = '\0';
+ }
+
+  char * amqp_queue;
+  map * m_amqp_queue = getMapFromMaps (conf, "rabbitmq", "queue");
+  if (m_amqp_queue == NULL){
+    fprintf(stderr,"Configuration error: [rabbitmq] queue");
+    return 2;
+  }
+  else {
+    amqp_queue = (char *)malloc((strlen(m_amqp_queue->value) +1)*sizeof(char*));
+    strncpy(amqp_queue,m_amqp_queue->value,strlen(m_amqp_queue->value));
+    amqp_queue[strlen(m_amqp_queue->value)] = '\0';
+ }
+
+  char * status_user;
+  map * m_status_user = getMapFromMaps (conf, "status", "user");
+  if (m_status_user == NULL){
+    fprintf(stderr,"Configuration error: [status] user");
+    return 2;
+  }
+  else {
+    status_user = (char *)malloc((strlen(m_status_user->value) +1)*sizeof(char*));
+    strncpy(status_user,m_status_user->value,strlen(m_status_user->value));
+    status_user[strlen(m_status_user->value)] = '\0';
+  }
+
+
+  char * status_passwd;
+  map * m_status_passwd = getMapFromMaps (conf, "status", "passwd");
+  if (m_status_passwd == NULL){
+    fprintf(stderr,"Configuration error: [status] passwd");
+    return 2;
+  }
+  else {
+    status_passwd = (char *)malloc((strlen(m_status_passwd->value) +1)*sizeof(char*));
+    strncpy(status_passwd,m_status_passwd->value,strlen(m_status_passwd->value));
+    status_passwd[strlen(m_status_passwd->value)] = '\0';
+  }
+
+  char * status_bdd;
+  map * m_status_bdd = getMapFromMaps (conf, "status", "bdd");
+  if (m_status_bdd == NULL){
+    fprintf(stderr,"Configuration error: [status] bdd");
+    return 2;
+  }
+  else {
+    status_bdd = (char *)malloc((strlen(m_status_bdd->value) +1)*sizeof(char*));
+    strncpy(status_bdd,m_status_bdd->value,strlen(m_status_bdd->value));
+    status_bdd[strlen(m_status_bdd->value)] = '\0';
+  }
+
+  char * status_host;
+  map * m_status_host = getMapFromMaps (conf, "status", "host");
+  if (m_status_host == NULL){
+    fprintf(stderr,"Configuration error: [status] host");
+    return 2;
+  }
+  else {
+    status_host = (char *)malloc((strlen(m_status_host->value) +1)*sizeof(char*));
+    strncpy(status_host,m_status_host->value,strlen(m_status_host->value));
+    status_host[strlen(m_status_host->value)] = '\0';
+  }
+
+  int status_port;
+  map *m_status_port = getMapFromMaps (conf, "status", "port");
+  if (m_status_port == NULL){
+    fprintf(stderr,"Configuration error: [status] port");
+    return 2;
+  }
+  else {
+    status_port = atoi(m_status_port->value);
+    if (status_port == 0){
+        fprintf(stderr,"Configuration error: [status] port");
+        return 2;
+    }
+  }
+  init_sql(status_host,status_user,status_passwd,status_bdd,status_port);
 
   int sock = FCGX_OpenSocket(listen, listen_queue); 
@@ -705,9 +878,13 @@
     return 3;
   }
- 
+
+  init_amqp(amqp_host,amqp_port,amqp_user, amqp_passwd, amqp_exchange, amqp_routingkey,amqp_queue);
+
+
   int fork_status = fork();
   if (fork_status == 0){
     //child
-    int forker_pid = getpid();
+    int master_sync= getpid();
+    fprintf(stderr,"Master sync%d\n",getpid());
     FCGX_Init();
     FCGX_Request request;
@@ -718,5 +895,5 @@
         fork_status = fork();
         if (fork_status == 0){
-            fprintf(stderr,"child %d \n",i);
+            fprintf(stderr,"child sync %d \n",getpid());
             fflush(stderr);
             break;
@@ -724,5 +901,6 @@
     }
     while(1){
-        if (forker_pid != getpid()){
+        /* mode synchrone */
+        if (master_sync != getpid()){
             while(FCGX_Accept_r(&request) == 0){
                 process(&request);
@@ -737,5 +915,6 @@
         else {
             wait(0);
-            fprintf(stderr,"new child\n");
+            fprintf(stderr,"Master sync %d\n",getpid());
+            fprintf(stderr,"New sync Child\n");
             fflush(stderr);
             fork();
@@ -744,6 +923,141 @@
   }
   else {
-  
-  while(1);
+   int master_async = getpid();
+   fprintf(stderr,"Master async %d\n",master_async);
+    int fork_s;
+    int j;
+    for (j = 0; j< async_worker; j++){
+        fork_s = fork();
+        if (fork_s == 0){
+            fprintf(stderr,"child async %d \n",getpid());
+            fflush(stderr);
+            break;
+        }
+    }
+    json_object *msg_obj;
+    json_object *maps_obj;
+    maps * map_c;
+    json_object *req_format_jobj;
+    maps * request_input_real_format;
+    json_object *req_jobj;
+    map * request_inputs;
+    json_object *outputs_jobj;
+    maps * request_output_real_format;
+
+    char *msg;
+    int c;
+    int eres;
+    char * service_identifier;
+    service * s1 = NULL;
+    while(1){
+        /* mode asynchrone */
+        if( master_async != getpid()){
+            /*traitement des requetes de la queue */
+            bind_amqp();
+            init_consumer();
+            while(1){
+                
+                c = consumer_amqp(&msg);
+                if (c == 0)
+                    break;
+                msg_obj = json_tokener_parse(msg);
+                
+                free(msg);
+                maps_obj = json_object_object_get(msg_obj,"maps");
+
+                map_c = jsontomaps(maps_obj);
+
+                req_format_jobj = json_object_object_get(msg_obj,"request_input_real_format");
+                request_input_real_format = jsontomaps(req_format_jobj);
+
+                req_jobj = json_object_object_get(msg_obj,"request_inputs");
+                request_inputs = jsontomap(req_jobj);
+
+                outputs_jobj = json_object_object_get(msg_obj,"request_output_real_format");
+                request_output_real_format = jsontomaps(outputs_jobj);
+                
+                json_object_put(msg_obj);
+
+                /* traitemement du message */
+                /* Recherche des references */
+                maps* tmp=request_input_real_format;
+                HINTERNET hInternet = InternetOpen ((LPCTSTR) "ZooWPSClient\0",INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
+                while(tmp!=NULL){
+                    map * tmp_map = getMap(tmp->content,"xlink:href");
+                    if (tmp_map != NULL){
+                        if (loadRemoteFile(&map_c, &tmp_map, &hInternet,tmp_map->value) < 0) {
+                            /* passer le status failed dans la base de donnÃ©e */
+                            fprintf(stderr,"Erreur de chargement \n");
+                        }
+                    }
+                    tmp=tmp->next;
+                }
+                runHttpRequests (&map_c, &request_input_real_format, &hInternet);
+                InternetCloseHandle (&hInternet);
+                free(tmp); 
+                map * uuid = getMapFromMaps(map_c,"lenv","usid");
+                if (uuid != NULL)
+                    start_job(uuid->value);
+                map *t=createMap("background","1");
+                maps * lenv = getMaps(map_c,"lenv");
+                addMapToMap(&lenv->content,t);
+                freeMap(&t);
+                free(t);
+                
+                map * m_identifier = getMap (request_inputs, "Identifier");
+                
+                service_identifier = zStrdup (m_identifier->value);
+
+                s1 = search_service (service_identifier);
+                free(service_identifier);
+                
+
+                //dumpMaps(request_input_real_format);
+
+                loadServiceAndRun(&map_c, s1,request_inputs,&request_input_real_format, &request_output_real_format, &eres,NULL,NULL);
+                if (eres == SERVICE_SUCCEEDED) {
+                    outputResponse (s1,request_input_real_format,request_output_real_format,request_inputs, 0, map_c, eres,NULL,NULL);
+                }
+                    
+                    
+                //dumpMaps(request_output_real_format);
+                //fprintf(stderr,"################################################################\n");
+                //dumpMaps(map_c);
+
+                outputResponse (s1,request_input_real_format,request_output_real_format,request_inputs, 0, map_c, eres,NULL,NULL);
+
+                
+                freeMaps(&map_c);
+                map_c= NULL;
+               
+                freeMaps(&request_input_real_format);
+                request_input_real_format = NULL;
+
+                //dumpMap(request_inputs);
+                freeMap(&request_inputs);
+                request_inputs = NULL;
+                
+                //dumpMaps(request_output_real_format);
+                freeMaps(&request_output_real_format);
+                request_output_real_format = NULL;
+                consumer_ack_amqp(c);
+                
+
+            }
+            close_amqp();
+            
+
+
+
+            
+        }
+        else {
+            wait(0);
+            fprintf(stderr,"Master async %d\n",getpid());
+            fprintf(stderr,"New async Child\n");
+            fflush(stderr);
+            fork();
+        }
+    }
 
   }
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 617)
@@ -31,4 +31,5 @@
 #include "zoo_amqp.h"
 #include "zoo_sql.h"
+#include "zoo_json.h"
 extern "C"
 {
@@ -275,5 +276,4 @@
 }
 
-#include "zoo_json.h"
 void
 loadServiceAndRun (maps ** myMap, service * s1, map * request_inputs,
@@ -281,26 +281,4 @@
 {
  
- json_object *obj;
- mapstojson(&obj,*myMap);
- fprintf(stderr,"myMaps: %s\n",json_object_to_json_string(obj));
-
-
-json_object *obj3;
-mapstojson(&obj3,*inputs);
-fprintf(stderr,"inputs: %s\n",json_object_to_json_string(obj3));
-
-
-json_object *obj1;
- maptojson(&obj1,request_inputs);
- fprintf(stderr,"request_inputs: %s\n",json_object_to_json_string(obj1));
-
-json_object *obj2;
-mapstojson(&obj2,*ioutputs);
-fprintf(stderr,"ioutputs: %s\n",json_object_to_json_string(obj2));
-
-
-
- fflush(stderr);
-
 
  char tmps1[1024];
@@ -309,4 +287,9 @@
   maps *request_output_real_format = *ioutputs;
   maps *request_input_real_format = *inputs;
+  map * background = NULL;
+  map * uuid = getMapFromMaps(m,"lenv","usid");
+  background = getMapFromMaps(m,"lenv","background");
+
+
   /**
    * Extract serviceType to know what kind of service should be loaded
@@ -443,5 +426,11 @@
                            ("Error occured while running the %s function: %s"),
                            s1->name, errstr);
-                  errorException (m, tmpMsg, "InternalError", NULL,out);
+
+                  if (background == NULL){
+                    errorException (m, tmpMsg, "InternalError", NULL,out);
+                  }
+                  else {
+                    /* mise a jour de la table status */
+                   }
                   free (tmpMsg);
 #ifdef DEBUG
@@ -466,9 +455,10 @@
               fflush (stderr);
 #endif
-              *eres =
+
+            *eres =
                 execute (&m, &request_input_real_format,
                          &request_output_real_format);
 #ifdef DEBUG
-              fprintf (stderr, "Function loaded and returned %d\n", eres);
+              fprintf (stderr, "Function loaded and returned %d\n", *eres);
               fflush (stderr);
 #endif
@@ -497,5 +487,10 @@
           sprintf (tmps, _("C Library can't be loaded %s"), errstr);
           map *tmps1 = createMap ("text", tmps);
-          printExceptionReportResponse (m, tmps1,out);
+          if (background == NULL){
+             printExceptionReportResponse (m, tmps1,out);
+          }
+          else {
+            /* mise a jour table status */
+           }
           *eres = -1;
           freeMap (&tmps1);
@@ -578,6 +573,11 @@
                ("Programming Language (%s) set in ZCFG file is not currently supported by ZOO Kernel.\n"),
                r_inputs->value);
-      map *tmps = createMap ("text", tmpv);
-      printExceptionReportResponse (m, tmps,out);
+      if (background == NULL){
+        map *tmps = createMap ("text", tmpv);
+        printExceptionReportResponse (m, tmps,out);
+      }
+      else {
+      /* mise jour table status */
+      }
       *eres = -1;
     }
@@ -3043,4 +3043,5 @@
   if (status == NULLMAP)
     {
+
       loadServiceAndRun
         (&m, s1,
@@ -3055,8 +3056,5 @@
 
     eres = SERVICE_ACCEPTED;
-    json_object * msg_jobj = json_object_new_object();
-    json_object_object_add(msg_jobj,"service_identifier",json_object_new_string(service_identifier));
-
-
+    json_object *msg_jobj = json_object_new_object();
     json_object *maps_obj;
     mapstojson(&maps_obj,m);
@@ -3076,8 +3074,13 @@
     mapstojson(&outputs_jobj,request_output_real_format);
     json_object_object_add(msg_jobj,"request_output_real_format",outputs_jobj);
-   
-    if ( (send_msg(json_object_to_json_string(msg_jobj),"application/json") != 0) || (add_status(uuid) != 0) ){     
+  
+    bind_amqp();
+
+    if ( (send_msg(json_object_to_json_string(msg_jobj),"application/json") != 0) || (add_job(uuid) != 0) ){     
         eres = SERVICE_FAILED;
     }
+    close_amqp();
+    json_object_put(msg_jobj);
+    
 
 }
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_sql.c
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_sql.c	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_sql.c	(revision 617)
@@ -1,2 +1,28 @@
+/**
+ * Author : David Saggiorato
+ *
+ *  Copyright 2008-2009 GeoLabs SARL. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+
 #include <string.h>
 #include <stdio.h>
@@ -58,5 +84,5 @@
  }
 
-int add_status(const char * uuid) {
+int add_job(const char * uuid) {
     init_connection();
     const char * query = "insert into status (uuid,status,created_time) values ('%s','queue',now())";
@@ -72,2 +98,19 @@
     return 0;
 }
+
+int start_job(const char *uuid){
+    init_connection();
+    const char * query = "update status set start_date=now(), status='running', progress=0 where uuid='%s';";
+    char * query_f = (char*) malloc(strlen(query) + strlen(uuid) + 1);
+    sprintf(query_f,query,uuid);
+    if (mysql_query(con, query_f) != 0){
+        fprintf(stderr, "%s\n", mysql_error(con));
+        free(query_f);
+        return -1;
+    }
+    free(query_f);
+    mysql_close(con);
+    return 0;
+}
+
+
Index: branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_sql.h
===================================================================
--- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_sql.h	(revision 616)
+++ branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_sql.h	(revision 617)
@@ -1,2 +1,28 @@
+/**
+ * Author : David Saggiorato
+ *
+ *  Copyright 2008-2009 GeoLabs SARL. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+
 #ifndef ZOO_SQL_H
 #define ZOO_SQL_H 1
@@ -5,4 +31,6 @@
 void init_sql(const char* host,const char *user, const char *passwd, const char * bdd,int port);
 char * get_uuid();
-int add_status(const char * uuid);
+int add_job(const char * uuid);
+int start_job(const char *uuid);
+
 #endif
