ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r690127 [6/11] - in /webservices/sandesha/trunk/c: ./ build/win32/ config/ ides/vc8/sandesha2/sandesha2/ include/ include/sandesha2/ samples/ samples/RMSampleService/ samples/rm_echo_1_0/ samples/rm_echo_1_0_large_sequence/ samples/rm_echo_...
Date Fri, 29 Aug 2008 06:56:38 GMT
Modified: webservices/sandesha/trunk/c/src/msgprocessors/terminate_seq_msg_processor.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/msgprocessors/terminate_seq_msg_processor.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/msgprocessors/terminate_seq_msg_processor.c (original)
+++ webservices/sandesha/trunk/c/src/msgprocessors/terminate_seq_msg_processor.c Thu Aug 28 23:56:29 2008
@@ -71,7 +71,6 @@
     ((sandesha2_terminate_seq_msg_processor_impl_t *)\
     (msg_proc))
 
-/***************************** Function headers *******************************/
 static axis2_status_t AXIS2_CALL 
 sandesha2_terminate_seq_msg_processor_process_in_msg (
     sandesha2_msg_processor_t *msg_processor,
@@ -107,7 +106,6 @@
     sandesha2_msg_processor_t *msg_processor, 
 	const axutil_env_t *env);								
 
-/***************************** End of function headers ************************/
 
 AXIS2_EXTERN sandesha2_msg_processor_t* AXIS2_CALL
 sandesha2_terminate_seq_msg_processor_create(
@@ -168,9 +166,9 @@
     const axutil_env_t *env,
     sandesha2_msg_ctx_t *rm_msg_ctx)
 {
-    axis2_msg_ctx_t *msg_ctx = NULL;
+    axis2_msg_ctx_t *terminate_msg_ctx = NULL;
     sandesha2_terminate_seq_t *term_seq = NULL;
-    axis2_char_t *seq_id = NULL;
+    axis2_char_t *rmd_sequence_id = NULL;
     axis2_conf_ctx_t *conf_ctx = NULL;
     sandesha2_storage_mgr_t *storage_mgr = NULL;
     sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
@@ -181,105 +179,143 @@
     axis2_char_t *spec_version = NULL;
     axis2_char_t *dbname = NULL;
     sandesha2_seq_ack_t *seq_ack = NULL;
+    axis2_op_ctx_t *op_ctx = NULL;
+    /*sandesha2_seq_property_bean_t *term_rcvd_bean = NULL;*/
   
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
         "[sandesha2]Entry:sandesha2_terminate_seq_msg_processor_process_in_msg");
+
     AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE);
 
-    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
+    terminate_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
+
+    if(axis2_msg_ctx_get_server_side(terminate_msg_ctx, env))
+    {
+        axis2_msg_ctx_t **msg_ctx_map = NULL;
+
+        op_ctx = axis2_msg_ctx_get_op_ctx(terminate_msg_ctx, env);
+        msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+        msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = terminate_msg_ctx;
+    }
     
     term_seq = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env);
     if(!term_seq)
     {
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                 "[sandesha2] Terminate Sequence part is not available");
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, 
-            AXIS2_FAILURE);
+
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE);
+
         return AXIS2_FAILURE;
     }
-    seq_id = sandesha2_identifier_get_identifier(
-        sandesha2_terminate_seq_get_identifier(term_seq, env), env);
-    if(!seq_id || 0 == axutil_strlen(seq_id))
+
+    rmd_sequence_id = sandesha2_identifier_get_identifier(sandesha2_terminate_seq_get_identifier(
+        term_seq, env), env);
+    if(!rmd_sequence_id || 0 == axutil_strlen(rmd_sequence_id))
     {
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Invalid sequence id");
+
         return AXIS2_FAILURE;
     }
-    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+
+    conf_ctx = axis2_msg_ctx_get_conf_ctx(terminate_msg_ctx, env);
     dbname = sandesha2_util_get_dbname(env, conf_ctx);
     storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
     seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
     create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
     sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
     next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname);
-    fault_ctx = sandesha2_fault_mgr_check_for_unknown_seq(env, 
-        rm_msg_ctx, seq_id, seq_prop_mgr, create_seq_mgr, next_msg_mgr);
+    fault_ctx = sandesha2_fault_mgr_check_for_unknown_seq(env, rm_msg_ctx, rmd_sequence_id, seq_prop_mgr, 
+            create_seq_mgr, next_msg_mgr);
+
     if(fault_ctx)
     {
         axis2_engine_t *engine = NULL;
+
         engine = axis2_engine_create(env, conf_ctx);
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-            "[sandesha2] Send fault occurred");
-        axis2_engine_send_fault(engine, env, sandesha2_msg_ctx_get_msg_ctx(
-            fault_ctx, env));
+
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Send fault occurred");
+
+        axis2_engine_send_fault(engine, env, sandesha2_msg_ctx_get_msg_ctx(fault_ctx, env));
         sandesha2_msg_ctx_free(fault_ctx, env);
         if(engine)
+        {
             axis2_engine_free(engine, env);
-        axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE);
+        }
+
+        axis2_msg_ctx_set_paused(terminate_msg_ctx, env, AXIS2_TRUE);
+
         if(seq_prop_mgr)
+        {
             sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+        }
         if(create_seq_mgr)
+        {
             sandesha2_create_seq_mgr_free(create_seq_mgr, env);
+        }
         if(sender_mgr)
+        {
             sandesha2_sender_mgr_free(sender_mgr, env);
+        }
         if(next_msg_mgr)
+        {
             sandesha2_next_msg_mgr_free(next_msg_mgr, env);
+        }
         if(storage_mgr)
+        {
             sandesha2_storage_mgr_free(storage_mgr, env);
+        }
+
         return AXIS2_SUCCESS;
     }
-    /*seq_prop_mgr = sandesha2_storage_mgr_get_seq_property_mgr(storage_mgr, env);
-    term_rcvd_bean = sandesha2_seq_property_bean_create(env);
-    sandesha2_seq_property_bean_set_seq_id(term_rcvd_bean, env, seq_id);
-    sandesha2_seq_property_bean_set_name(term_rcvd_bean, env, 
-        SANDESHA2_SEQ_PROP_TERMINATE_RECEIVED);
-    sandesha2_seq_property_bean_set_value(term_rcvd_bean, env, 
-        AXIS2_VALUE_TRUE);
+
+    /*term_rcvd_bean = sandesha2_seq_property_bean_create(env);
+    sandesha2_seq_property_bean_set_seq_id(term_rcvd_bean, env, rmd_sequence_id);
+    sandesha2_seq_property_bean_set_name(term_rcvd_bean, env, SANDESHA2_SEQ_PROP_TERMINATE_RECEIVED);
+    sandesha2_seq_property_bean_set_value(term_rcvd_bean, env, AXIS2_VALUE_TRUE);
     sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, term_rcvd_bean);*/
+
     spec_version = sandesha2_msg_ctx_get_rm_spec_ver(rm_msg_ctx, env);
-    if(AXIS2_TRUE == sandesha2_spec_specific_consts_is_term_seq_res_reqd(env, 
-            spec_version))
+    if(sandesha2_spec_specific_consts_is_term_seq_res_reqd(env, spec_version))
     {
-        sandesha2_terminate_seq_msg_processor_add_terminate_seq_res(env, 
-            rm_msg_ctx, seq_id, seq_prop_mgr);
+        sandesha2_terminate_seq_msg_processor_add_terminate_seq_res(env, rm_msg_ctx, rmd_sequence_id, 
+                seq_prop_mgr);
     }
+
     seq_ack = sandesha2_msg_ctx_get_seq_ack(rm_msg_ctx, env);
     if(seq_ack)
     {
-        axis2_char_t *int_seq_id = NULL;
-        axis2_char_t *out_seq_id = NULL;
+        axis2_char_t *internal_sequence_id = NULL;
+        axis2_char_t *rms_sequence_id = NULL;
         axis2_char_t *last_out_msg_no_str = NULL;
         long highest_out_msg_no = 0;
         
         /* If there is a sequence acknowledgement element present in the sequence we will check
          * whether the sequence is completed. If so send a terminate sequence message.
          */
-        out_seq_id = sandesha2_identifier_get_identifier(
-            sandesha2_seq_ack_get_identifier(seq_ack, env), env);
-        int_seq_id = sandesha2_utils_get_seq_property(env, out_seq_id, 
-                SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID, seq_prop_mgr);
-        last_out_msg_no_str = sandesha2_utils_get_seq_property(env, int_seq_id,
+        rms_sequence_id = sandesha2_identifier_get_identifier(sandesha2_seq_ack_get_identifier(
+                    seq_ack, env), env);
+
+        internal_sequence_id = sandesha2_utils_get_seq_property(env, rms_sequence_id, 
+                SANDESHA2_SEQUENCE_PROPERTY_RMS_INTERNAL_SEQ_ID, seq_prop_mgr);
+
+        last_out_msg_no_str = sandesha2_utils_get_seq_property(env, internal_sequence_id,
             SANDESHA2_SEQ_PROP_LAST_OUT_MESSAGE_NO, seq_prop_mgr);
+
         if(last_out_msg_no_str)
         {
             highest_out_msg_no = atol(last_out_msg_no_str);
             if(last_out_msg_no_str)
+            {
                 AXIS2_FREE(env->allocator, last_out_msg_no_str);
+            }
         }
         else
         {
             highest_out_msg_no = sandesha2_app_msg_processor_get_prev_msg_no(env, 
-                int_seq_id, seq_prop_mgr);
+                    internal_sequence_id, seq_prop_mgr);
         }
+
         if(highest_out_msg_no > 0)
         {
             axis2_bool_t completed = AXIS2_FALSE;
@@ -288,45 +324,70 @@
             AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "highest_out_msg_no:%ld", highest_out_msg_no);
 
             ack_range_list = sandesha2_seq_ack_get_ack_range_list(seq_ack, env);
-            completed = sandesha2_ack_mgr_verify_seq_completion(env, 
-                ack_range_list, highest_out_msg_no);
+            completed = sandesha2_ack_mgr_verify_seq_completion(env, ack_range_list, 
+                    highest_out_msg_no);
+
             if(completed)
             {
                 AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
                         "[sandesha2]Sequence %s is completed. So adding terminate msg", 
-                        out_seq_id); 
-                sandesha2_terminate_mgr_add_terminate_seq_msg(env, rm_msg_ctx, 
-                    out_seq_id, int_seq_id, storage_mgr, seq_prop_mgr, 
-                    create_seq_mgr, sender_mgr);
+                        rms_sequence_id); 
+
+                sandesha2_terminate_mgr_send_terminate_seq_msg(env, rm_msg_ctx, rms_sequence_id, 
+                        internal_sequence_id, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
             }
         }
+
+        if(internal_sequence_id)
+        {
+            AXIS2_FREE(env->allocator, internal_sequence_id);
+        }
     }
     else
     {
-        sandesha2_terminate_seq_msg_processor_setup_highest_msg_nums(env, conf_ctx, 
-            storage_mgr, seq_id, rm_msg_ctx, seq_prop_mgr, create_seq_mgr, 
-            sender_mgr);
-    }
-    sandesha2_terminate_mgr_clean_recv_side_after_terminate_msg(env, conf_ctx,
-        seq_id, storage_mgr, seq_prop_mgr, next_msg_mgr);
-    /*transmit_bean = sandesha2_seq_property_bean_create_with_data(env, seq_id,
+        sandesha2_terminate_seq_msg_processor_setup_highest_msg_nums(env, conf_ctx, storage_mgr, 
+                rmd_sequence_id, rm_msg_ctx, seq_prop_mgr, create_seq_mgr, sender_mgr);
+    }
+
+    /*sandesha2_terminate_mgr_clean_recv_side_after_terminate_msg(env, conf_ctx, rmd_sequence_id, storage_mgr, 
+            seq_prop_mgr, next_msg_mgr);*/
+
+    /*transmit_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id,
         SANDESHA2_SEQ_PROP_SEQ_TERMINATED, AXIS2_VALUE_TRUE);
     sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, transmit_bean);
-    sandesha2_seq_mgr_update_last_activated_time(env, seq_id, storage_mgr);
+    sandesha2_seq_mgr_update_last_activated_time(env, rmd_sequence_id, storage_mgr);
     */
+
     sandesha2_msg_ctx_set_paused(rm_msg_ctx, env, AXIS2_TRUE);
+
     if(seq_prop_mgr)
+    {
         sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+    }
+
     if(create_seq_mgr)
+    {
         sandesha2_create_seq_mgr_free(create_seq_mgr, env);
+    }
+
     if(sender_mgr)
+    {
         sandesha2_sender_mgr_free(sender_mgr, env);
+    }
+
     if(next_msg_mgr)
+    {
         sandesha2_next_msg_mgr_free(next_msg_mgr, env);
+    }
+
     if(storage_mgr)
+    {
         sandesha2_storage_mgr_free(storage_mgr, env);
+    }
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
         "[sandesha2]Exit:sandesha2_terminate_seq_msg_processor_process_in_msg");
+
     return AXIS2_SUCCESS;
 }
 
@@ -350,8 +411,8 @@
     axis2_bool_t add_rec_side_term = AXIS2_FALSE;
     axis2_char_t *out_seq_id = NULL;
     
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_"\
-        "terminate_seq_msg_processor_setup_highest_msg_nums");
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
+            "[sandesha2] Entry:sandesha2_terminate_seq_msg_processor_setup_highest_msg_nums");
     AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, storage_mgr, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE);
@@ -362,89 +423,133 @@
     
     highest_in_msg_num_str = sandesha2_utils_get_seq_property(env, seq_id,
         SANDESHA2_SEQ_PROP_HIGHEST_IN_MSG_NUMBER, seq_prop_mgr);
+
     highest_in_msg_id = sandesha2_utils_get_seq_property(env, seq_id,
         SANDESHA2_SEQ_PROP_HIGHEST_IN_MSG_ID, seq_prop_mgr);
+
     AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]highest_in_msg_num_str:%s",
         highest_in_msg_num_str);
+
     if(highest_in_msg_num_str)
     {
         if(!highest_in_msg_id)
         {
-            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] "
-                "highest in msg id has not been stored");
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                    "[sandesha2] highest in msg id has not been stored");
+
             if(highest_in_msg_num_str)
+            {
                 AXIS2_FREE(env->allocator, highest_in_msg_num_str);
+            }
+
             return AXIS2_FAILURE;
         }
+
         highest_in_msg_num = atol(highest_in_msg_num_str);
         if(highest_in_msg_num_str)
+        {
             AXIS2_FREE(env->allocator, highest_in_msg_num_str);
+        }
     }
-    rec_side_int_seq_id = sandesha2_utils_get_outgoing_internal_seq_id(env,
-        seq_id);
-    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]rec_side_int_seq_id:%s", 
+
+    rec_side_int_seq_id = sandesha2_utils_get_internal_sequence_id(env, seq_id);
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] rec_side_int_seq_id:%s", 
         rec_side_int_seq_id);
+
     if(0 == highest_in_msg_num)
+    {
         add_rec_side_term = AXIS2_FALSE;
+    }
     else
     {
         /* Mark up the highest inbound message as if it had the last message 
          * flag on it.*/
         sandesha2_seq_property_bean_t *last_in_msg_bean = NULL;
         axis2_char_t *highest_out_relates_to = NULL;
-        last_in_msg_bean = sandesha2_seq_property_bean_create_with_data(env, 
-            seq_id, SANDESHA2_SEQ_PROP_LAST_IN_MESSAGE_ID, highest_in_msg_id);
+
+        last_in_msg_bean = sandesha2_seq_property_bean_create_with_data(env, seq_id, 
+                SANDESHA2_SEQ_PROP_LAST_IN_MESSAGE_ID, highest_in_msg_id);
+
         if(last_in_msg_bean)
         {
             sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, last_in_msg_bean);
+            sandesha2_seq_property_bean_free(last_in_msg_bean, env);
         }
+
         /* If an outbound message has already gone out with that relatesTo, then 
          * we can terminate right away.
          */
-        highest_out_relates_to = sandesha2_utils_get_seq_property(env, 
-            rec_side_int_seq_id, SANDESHA2_SEQ_PROP_HIGHEST_OUT_RELATES_TO, 
-            seq_prop_mgr);
-        if(highest_out_relates_to && 0 == axutil_strcmp(highest_out_relates_to, 
-            highest_in_msg_id))
+        highest_out_relates_to = sandesha2_utils_get_seq_property(env, rec_side_int_seq_id, 
+                SANDESHA2_SEQ_PROP_HIGHEST_OUT_RELATES_TO, seq_prop_mgr);
+
+        if(highest_out_relates_to && 0 == axutil_strcmp(highest_out_relates_to, highest_in_msg_id))
         {
             axis2_char_t *highest_out_msg_num_str = NULL;
-            highest_out_msg_num_str = sandesha2_utils_get_seq_property(env, 
-                rec_side_int_seq_id, SANDESHA2_SEQ_PROP_HIGHEST_OUT_MSG_NUMBER, 
-                seq_prop_mgr);
+
+            highest_out_msg_num_str = sandesha2_utils_get_seq_property(env, rec_side_int_seq_id, 
+                    SANDESHA2_SEQ_PROP_HIGHEST_OUT_MSG_NUMBER, seq_prop_mgr);
+
             highest_out_msg_num = atol(highest_out_msg_num_str);
             add_rec_side_term = AXIS2_TRUE;
             if(highest_out_msg_num_str)
+            {
                 AXIS2_FREE(env->allocator, highest_out_msg_num_str);
+            }
         }
+
         if(highest_out_relates_to)
+        {
             AXIS2_FREE(env->allocator, highest_out_relates_to);
         }
+    }
+
     if(highest_in_msg_id)
+    {
         AXIS2_FREE(env->allocator, highest_in_msg_id);
-    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]add_rec_side_term:%d",
-        add_rec_side_term);
+    }
+
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]add_rec_side_term:%d", add_rec_side_term);
+
     out_seq_id = sandesha2_utils_get_seq_property(env, rec_side_int_seq_id,
-        SANDESHA2_SEQ_PROP_OUT_SEQ_ID, seq_prop_mgr);
-    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]out_seq_id:%s",
-        out_seq_id);
-    if(add_rec_side_term && highest_out_msg_num > 0 &&
-        rec_side_int_seq_id && out_seq_id)
+        SANDESHA2_SEQUENCE_PROPERTY_RMS_SEQ_ID, seq_prop_mgr);
+
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]out_seq_id:%s", out_seq_id);
+    if(rec_side_int_seq_id)
+    {
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] rec_side_int_seq_id:%s", rec_side_int_seq_id);
+    }
+        
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] highest_out_msg_num:%d", highest_out_msg_num);
+
+    if(add_rec_side_term && highest_out_msg_num > 0 && rec_side_int_seq_id && out_seq_id)
     {
         axis2_bool_t all_acked = AXIS2_FALSE;
-        all_acked = sandesha2_utils_is_all_msgs_acked_upto(env, 
-            highest_out_msg_num, rec_side_int_seq_id, seq_prop_mgr);
+
+        all_acked = sandesha2_utils_is_all_msgs_acked_upto(env, highest_out_msg_num, 
+                rec_side_int_seq_id, seq_prop_mgr);
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] all_acked:%d", all_acked);
         if(!all_acked)
-        all_acked = sandesha2_utils_is_all_msgs_acked_upto(env, 
-            highest_out_msg_num, out_seq_id, seq_prop_mgr);
+        {
+            all_acked = sandesha2_utils_is_all_msgs_acked_upto(env, highest_out_msg_num, out_seq_id, 
+                    seq_prop_mgr);
+            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] all_acked:%d", all_acked);
+        }
+
         if(all_acked)
         {
-            sandesha2_terminate_mgr_add_terminate_seq_msg(env, rm_msg_ctx,
-                out_seq_id, rec_side_int_seq_id, storage_mgr, seq_prop_mgr,
-                create_seq_mgr, sender_mgr);
-        }
-    }        
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_"\
-        "terminate_seq_msg_processor_setup_highest_msg_nums");
+            sandesha2_terminate_mgr_send_terminate_seq_msg(env, rm_msg_ctx, out_seq_id, 
+                    rec_side_int_seq_id, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
+        }
+    }
+
+    if(rec_side_int_seq_id)
+    {
+        AXIS2_FREE(env->allocator, rec_side_int_seq_id);
+    }
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
+            "[sandesha2]Exit:sandesha2_terminate_seq_msg_processor_setup_highest_msg_nums");
+
     return AXIS2_SUCCESS;    
 }
 
@@ -469,44 +574,46 @@
     sandesha2_sender_bean_t *term_res_bean = NULL;
     axis2_char_t *key = NULL;
     sandesha2_sender_mgr_t *retrans_mgr = NULL;*/
+
     AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, seq_id, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_"\
-        "terminate_seq_msg_processor_add_terminate_seq_res");
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
+            "[sandesha2] Entry:sandesha2_terminate_seq_msg_processor_add_terminate_seq_res");
     
     msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
     out_msg_ctx = sandesha2_utils_create_out_msg_ctx(env, msg_ctx);
-    out_rm_msg = sandesha2_msg_creator_create_terminate_seq_res_msg(env, 
-        rm_msg_ctx, out_msg_ctx, seq_prop_mgr);
+    out_rm_msg = sandesha2_msg_creator_create_terminate_seq_res_msg(env, rm_msg_ctx, out_msg_ctx, 
+            seq_prop_mgr);
     if(!out_rm_msg)
+    {
         return AXIS2_FAILURE;
-    ack_rm_msg = sandesha2_ack_mgr_generate_ack_msg(env, rm_msg_ctx, seq_id,
-        seq_prop_mgr);
+    }
+
+    ack_rm_msg = sandesha2_ack_mgr_generate_ack_msg(env, rm_msg_ctx, seq_id, seq_prop_mgr);
     if(ack_rm_msg)
     {
         seq_ack = sandesha2_msg_ctx_get_seq_ack(ack_rm_msg, env);
         sandesha2_msg_ctx_set_seq_ack(out_rm_msg, env, seq_ack);
     }
+
     sandesha2_msg_ctx_add_soap_envelope(out_rm_msg, env);
     sandesha2_msg_ctx_set_flow(out_rm_msg, env, AXIS2_OUT_FLOW);
     
-    property = axutil_property_create_with_args(env, 0, 0, 0, 
-        AXIS2_VALUE_TRUE);
-    axis2_msg_ctx_set_property(out_msg_ctx, env, 
-        SANDESHA2_APPLICATION_PROCESSING_DONE, property);
+    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
+    axis2_msg_ctx_set_property(out_msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property);
+
     /* test code */
     /*
     to_epr = axis2_msg_ctx_get_to(out_msg_ctx, env);
     if(to_epr && !sandesha2_utils_is_anon_uri(env, 
         axis2_endpoint_ref_get_address(to_epr, env)))
     {   
-        axis2_msg_ctx_t *tsr_msg_ctx = axis2_core_utils_create_out_msg_ctx(
-                env, msg_ctx);
+        axis2_msg_ctx_t *tsr_msg_ctx = axis2_core_utils_create_out_msg_ctx(env, msg_ctx);
         orig_trans_out = axis2_msg_ctx_get_transport_out_desc(tsr_msg_ctx, env);
         property = axutil_property_create_with_args(env, 0, 0, 0, orig_trans_out);
-        axis2_msg_ctx_set_property(tsr_msg_ctx, env,
-            SANDESHA2_ORIGINAL_TRANSPORT_OUT_DESC, property);
+        axis2_msg_ctx_set_property(tsr_msg_ctx, env, SANDESHA2_ORIGINAL_TRANSPORT_OUT_DESC, property);
         trans_out = sandesha2_utils_get_transport_out(env);
         axis2_msg_ctx_set_transport_out_desc(tsr_msg_ctx, env, trans_out);
 
@@ -514,23 +621,19 @@
         term_res_bean = sandesha2_sender_bean_create(env);
         sandesha2_sender_bean_set_msg_ctx_ref_key(term_res_bean, env, key);
         property = axutil_property_create_with_args(env, 0, 0, 0, key);
-        axis2_msg_ctx_set_property(tsr_msg_ctx, env, SANDESHA2_MESSAGE_STORE_KEY, 
-            property);
+        axis2_msg_ctx_set_property(tsr_msg_ctx, env, SANDESHA2_MESSAGE_STORE_KEY, property);
         sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, tsr_msg_ctx);
         */  
         /* TODO: refine the terminate delay */
         /*
-        sandesha2_sender_bean_set_time_to_send(term_res_bean, env,
-            sandesha2_utils_get_current_time_in_millis(env) +
-            SANDESHA2_TERMINATE_DELAY);
+        sandesha2_sender_bean_set_time_to_send(term_res_bean, env, 
+            sandesha2_utils_get_current_time_in_millis(env) + SANDESHA2_TERMINATE_DELAY);
         sandesha2_sender_bean_set_msg_id(term_res_bean, env,
             (axis2_char_t *) axis2_msg_ctx_get_msg_id(tsr_msg_ctx, env));
         sandesha2_sender_bean_set_send(term_res_bean, env, AXIS2_TRUE);
 
-        property = axutil_property_create_with_args(env, 0, 0, 0, 
-            AXIS2_VALUE_TRUE);
-        axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_QUALIFIED_FOR_SENDING,
-            property);
+        property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
+        axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_QUALIFIED_FOR_SENDING, property);
         sandesha2_sender_bean_set_resend(term_res_bean, env, AXIS2_FALSE);
         retrans_mgr = sandesha2_storage_mgr_get_retrans_mgr(storage_mgr, env);
         sandesha2_sender_mgr_insert(retrans_mgr, env, term_res_bean);
@@ -538,7 +641,9 @@
     /* end test code */
     
     engine = axis2_engine_create(env, axis2_msg_ctx_get_conf_ctx(msg_ctx, env));
+
     AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]axis2_engine_send");
+
     axis2_engine_send(engine, env, out_msg_ctx); 
     op_ctx = axis2_msg_ctx_get_op_ctx(out_msg_ctx, env);
     if(to_epr)
@@ -557,12 +662,20 @@
     {
         axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE);
     }
+
     if(engine)
+    {
         axis2_engine_free(engine, env);
+    }
+
     if(out_rm_msg)
+    {
         sandesha2_msg_ctx_free(out_rm_msg, env);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_"\
-        "terminate_seq_msg_processor_add_terminate_seq_res");
+    }
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
+            "[sandesha2] Exit:sandesha2_terminate_seq_msg_processor_add_terminate_seq_res");
+
     return AXIS2_SUCCESS;
 }
 
@@ -601,6 +714,7 @@
     axis2_char_t *dbname = NULL;
     
     AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE);
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
         "[sandesha2]Entry:sandesha2_terminate_msg_processor_process_out_msg.");
     
@@ -612,41 +726,61 @@
     seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
     create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
     sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
-    to_address = (axis2_char_t*)axis2_endpoint_ref_get_address(
-        axis2_msg_ctx_get_to(msg_ctx, env), env);
+    to_address = (axis2_char_t*)axis2_endpoint_ref_get_address(axis2_msg_ctx_get_to(msg_ctx, env), 
+            env);
+
     property = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_SEQ_KEY);
     if(property)
+    {
         seq_key = axutil_property_get_value(property, env);
-    int_seq_id = sandesha2_utils_get_internal_seq_id(env, to_address, seq_key);
+    }
+
+    int_seq_id = sandesha2_utils_get_client_internal_sequence_id(env, to_address, seq_key);
     out_seq_id = sandesha2_utils_get_seq_property(env, int_seq_id, 
-        SANDESHA2_SEQ_PROP_OUT_SEQ_ID, seq_prop_mgr);
+        SANDESHA2_SEQUENCE_PROPERTY_RMS_SEQ_ID, seq_prop_mgr);
+
     if(!out_seq_id)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]seq_id was not"
-            " found. Cannot send the terminate message");
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID,
-            AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                "[sandesha2]seq_id was not found. Cannot send the terminate message");
+
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE);
         if(seq_prop_mgr)
+        {
             sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+        }
+
         if(create_seq_mgr)
+        {
             sandesha2_create_seq_mgr_free(create_seq_mgr, env);
+        }
+
         if(sender_mgr)
+        {
             sandesha2_sender_mgr_free(sender_mgr, env);
+        }
+
         if(storage_mgr)
+        {
             sandesha2_storage_mgr_free(storage_mgr, env);
+        }
+
         return AXIS2_FAILURE;
     }
-    terminated = sandesha2_utils_get_seq_property(env, int_seq_id,
-        SANDESHA2_SEQ_PROP_TERMINATE_ADDED, seq_prop_mgr);
+
+    terminated = sandesha2_utils_get_seq_property(env, int_seq_id, 
+            SANDESHA2_SEQ_PROP_TERMINATE_ADDED, seq_prop_mgr);
     old_op = axis2_msg_ctx_get_op(msg_ctx, env);
     
     qname = axutil_qname_create(env, "temp", NULL, NULL); 
     out_in_op = axis2_op_create_with_qname(env, qname);
     if(qname)
+    {
         axutil_qname_free(qname, env);
+    }
+
     axis2_op_set_msg_exchange_pattern(out_in_op, env, AXIS2_MEP_URI_OUT_IN);
-    axis2_op_set_in_flow(out_in_op, env, 
-         axis2_op_get_in_flow(old_op, env));
+    axis2_op_set_in_flow(out_in_op, env, axis2_op_get_in_flow(old_op, env));
 
     /*axutil_allocator_switch_to_global_pool(env->allocator);
     op_ctx = axis2_op_ctx_create(env, out_in_op, NULL);
@@ -655,58 +789,98 @@
         rm_msg_ctx, env), op_ctx);
     axutil_allocator_switch_to_local_pool(env->allocator);*/
     
-    if(terminated && 0 == axutil_strcmp(terminated, AXIS2_VALUE_TRUE))
+    if(terminated && !axutil_strcmp(terminated, AXIS2_VALUE_TRUE))
     {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Terminate was added previously");
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate was added previously");
         if(terminated)
+        {
             AXIS2_FREE(env->allocator, terminated);
+        }
+
         if(out_seq_id)
+        {
             AXIS2_FREE(env->allocator, out_seq_id);
+        }
+
         if(seq_prop_mgr)
+        {
             sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+        }
+
         if(create_seq_mgr)
+        {
             sandesha2_create_seq_mgr_free(create_seq_mgr, env);
+        }
+
         if(sender_mgr)
+        {
             sandesha2_sender_mgr_free(sender_mgr, env);
+        }
+
         if(storage_mgr)
+        {
             sandesha2_storage_mgr_free(storage_mgr, env);
+        }
+
         return AXIS2_SUCCESS;
     }
+
     if(terminated)
+    {
         AXIS2_FREE(env->allocator, terminated);
+    }
+
     term_seq_part = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env);
-    sandesha2_identifier_set_identifier(sandesha2_terminate_seq_get_identifier(
-         term_seq_part, env), env, out_seq_id);
+    sandesha2_identifier_set_identifier(sandesha2_terminate_seq_get_identifier(term_seq_part, env), 
+            env, out_seq_id);
+
     sandesha2_msg_ctx_set_flow(rm_msg_ctx, env, AXIS2_OUT_FLOW);
     property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
-    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, 
-        property);
+    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property);
     axis2_msg_ctx_set_to(msg_ctx, env, axis2_endpoint_ref_create(env, to_address));
     rm_version = sandesha2_utils_get_rm_version(env, int_seq_id, seq_prop_mgr);
     if(!rm_version)
     {
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Cant find the rm_version of the given message");
+                "[sandesha2] Cant find the rm_version of the given message");
+
         if(out_seq_id)
+        {
             AXIS2_FREE(env->allocator, out_seq_id);
+        }
+
         if(seq_prop_mgr)
+        {
             sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+        }
+
         if(create_seq_mgr)
+        {
             sandesha2_create_seq_mgr_free(create_seq_mgr, env);
+        }
+
         if(sender_mgr)
+        {
             sandesha2_sender_mgr_free(sender_mgr, env);
+        }
+
         if(storage_mgr)
+        {
             sandesha2_storage_mgr_free(storage_mgr, env);
+        }
+
         return AXIS2_FAILURE;
     }
+
     axis2_msg_ctx_set_wsa_action(msg_ctx, env, 
-        sandesha2_spec_specific_consts_get_terminate_seq_action(
-        env, rm_version));
-    temp_action = sandesha2_spec_specific_consts_get_terminate_seq_soap_action
-        (env, rm_version);
+            sandesha2_spec_specific_consts_get_terminate_seq_action(env, rm_version));
+
+    temp_action = sandesha2_spec_specific_consts_get_terminate_seq_soap_action(env, rm_version);
     if(rm_version)
+    {
         AXIS2_FREE(env->allocator, rm_version);
+    }
+
     soap_action = axutil_string_create(env, temp_action);
     axis2_msg_ctx_set_soap_action(msg_ctx, env, soap_action);
     transport_to = sandesha2_utils_get_seq_property(env, int_seq_id, 
@@ -718,8 +892,12 @@
         AXIS2_FREE(env->allocator, transport_to);
     }
 
-    sandesha2_msg_ctx_add_soap_envelope(rm_msg_ctx, env);
-    
+    if(!sandesha2_util_is_ack_already_piggybacked(env, rm_msg_ctx))
+    {
+        sandesha2_ack_mgr_piggyback_acks_if_present(env, out_seq_id, rm_msg_ctx, storage_mgr, 
+                seq_prop_mgr, sender_mgr);
+    }
+
     /*key = axutil_uuid_gen(env);
     term_bean = sandesha2_sender_bean_create(env);
     sandesha2_sender_bean_set_msg_ctx_ref_key(term_bean, env, key);
@@ -742,26 +920,42 @@
     sandesha2_sender_mgr_insert(retrans_mgr, env, term_bean);*/
     
     term_added = sandesha2_seq_property_bean_create(env);
-    sandesha2_seq_property_bean_set_name(term_added, env, 
-        SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
-    sandesha2_seq_property_bean_set_seq_id(term_added, env, out_seq_id);
+    sandesha2_seq_property_bean_set_name(term_added, env, SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
+    sandesha2_seq_property_bean_set_seq_id(term_added, env, int_seq_id);
     if(out_seq_id)
+    {
         AXIS2_FREE(env->allocator, out_seq_id);
+    }
+
     sandesha2_seq_property_bean_set_value(term_added, env, AXIS2_VALUE_TRUE); 
     sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, term_added);
-    sandesha2_terminate_mgr_terminate_sending_side(env, conf_ctx, int_seq_id, 
-        axis2_msg_ctx_get_server_side(msg_ctx, env), storage_mgr, seq_prop_mgr,
-        create_seq_mgr, sender_mgr);
+    /*sandesha2_terminate_mgr_terminate_sending_side(env, conf_ctx, int_seq_id, 
+        axis2_msg_ctx_get_server_side(msg_ctx, env), storage_mgr, seq_prop_mgr, create_seq_mgr, 
+        sender_mgr);*/
+
     if(seq_prop_mgr)
+    {
         sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+    }
+
     if(create_seq_mgr)
+    {
         sandesha2_create_seq_mgr_free(create_seq_mgr, env);
+    }
+
     if(sender_mgr)
+    {
         sandesha2_sender_mgr_free(sender_mgr, env);
+    }
+
     if(storage_mgr)
+    {
         sandesha2_storage_mgr_free(storage_mgr, env);
+    }
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
-        "[sandesha2]Exit:sandesha2_terminate_msg_processor_process_out_msg");
+        "[sandesha2] Exit:sandesha2_terminate_msg_processor_process_out_msg");
+
     return AXIS2_SUCCESS;
 }
 

Modified: webservices/sandesha/trunk/c/src/msgprocessors/terminate_seq_res_msg_processor.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/msgprocessors/terminate_seq_res_msg_processor.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/msgprocessors/terminate_seq_res_msg_processor.c (original)
+++ webservices/sandesha/trunk/c/src/msgprocessors/terminate_seq_res_msg_processor.c Thu Aug 28 23:56:29 2008
@@ -137,47 +137,66 @@
     axis2_char_t *dbname = NULL;
    
     AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_"\
-        "terminate_seq_res_msg_processor_process_in_msg");
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
+            "[sandesha2] Entry:sandesha2_terminate_seq_res_msg_processor_process_in_msg");
+
     msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
     term_seq_res = sandesha2_msg_ctx_get_terminate_seq_res(rm_msg_ctx, env);
     if(!term_seq_res)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate "
-            "Sequence part is not available");
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, 
-            AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                "[sandesha2] Terminate Sequence part is not available");
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
+
     seq_id = sandesha2_identifier_get_identifier(
         sandesha2_terminate_seq_res_get_identifier(term_seq_res, env), env);
     if(!seq_id || 0 == axutil_strlen(seq_id))
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Invalid "\
-            "sequence id");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Invalid sequence id");
         return AXIS2_FAILURE;
     }
+
     conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
     dbname = sandesha2_util_get_dbname(env, conf_ctx);
     storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
     seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
     create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
     sender_mgr =sandesha2_permanent_sender_mgr_create(env, dbname);
+
     /* We need to pass here internal seq id isn't it?:damitha
     int internal_seq_id = sandesha2_utils_get_seq_property(env, seq_id, 
-        SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID, storage_mgr);*/
-    sandesha2_terminate_mgr_terminate_sending_side(env, conf_ctx, seq_id, 
-        AXIS2_FALSE, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
+        SANDESHA2_SEQUENCE_PROPERTY_RMS_INTERNAL_SEQ_ID, storage_mgr);*/
+    /*sandesha2_terminate_mgr_terminate_sending_side(env, conf_ctx, seq_id, 
+        AXIS2_FALSE, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);*/
+
+    sandesha2_msg_ctx_set_paused(rm_msg_ctx, env, AXIS2_TRUE);
+
     if(seq_prop_mgr)
+    {
         sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+    }
+
     if(create_seq_mgr)
+    {
         sandesha2_create_seq_mgr_free(create_seq_mgr, env);
+    }
+
     if(sender_mgr)
+    {
         sandesha2_sender_mgr_free(sender_mgr, env);
+    }
+
     if(storage_mgr)
+    {
         sandesha2_storage_mgr_free(storage_mgr, env);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_"\
-        "terminate_seq_res_msg_processor_process_in_msg");
+    }
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
+            "[sandesha2] Exit:sandesha2_terminate_seq_res_msg_processor_process_in_msg");
+
     return AXIS2_SUCCESS;
 }
 

Modified: webservices/sandesha/trunk/c/src/polling/polling_mgr.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/polling/polling_mgr.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/polling/polling_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/polling/polling_mgr.c Thu Aug 28 23:56:29 2008
@@ -37,6 +37,7 @@
 #include <stdio.h>
 #include <platforms/axutil_platform_auto_sense.h>
 #include <axutil_types.h>
+#include <axiom_soap_const.h>
 
 
 /** 
@@ -45,29 +46,19 @@
  */
 typedef struct sandesha2_polling_mgr_args sandesha2_polling_mgr_args_t;
 
-struct sandesha2_polling_mgr_t
-{
-	axis2_conf_ctx_t *conf_ctx;
-    /**
-     * By adding an entry to this, the polling_mgr will be asked to do a polling 
-     * request on this sequence.
-     */
-    axutil_array_list_t *scheduled_polling_reqs;
-    axis2_bool_t poll;
-    axutil_thread_mutex_t *mutex;
-};
-
 struct sandesha2_polling_mgr_args
 {
-    sandesha2_polling_mgr_t *impl;
     axutil_env_t *env;
-    sandesha2_storage_mgr_t *storage_mgr;
+	axis2_conf_ctx_t *conf_ctx;
+    sandesha2_msg_ctx_t *rm_msg_ctx;
+    axis2_char_t *internal_sequence_id;
+    axis2_char_t *sequence_id;
 };
             
-static axis2_status_t AXIS2_CALL 
-sandesha2_polling_mgr_run (
-    sandesha2_polling_mgr_t *polling_mgr,
-    const axutil_env_t *env,
+static axis2_status_t AXIS2_CALL
+sandesha2_polling_mgr_process_make_connection_msg_response(
+    const axutil_env_t *env, 
+    axis2_msg_ctx_t *msg_ctx,
     sandesha2_storage_mgr_t *storage_mgr);
 
 /**
@@ -78,129 +69,151 @@
     axutil_thread_t *thd, 
     void *data);
 
-AXIS2_EXTERN sandesha2_polling_mgr_t* AXIS2_CALL
-sandesha2_polling_mgr_create(
-    const axutil_env_t *env)
+axis2_status_t AXIS2_CALL 
+sandesha2_polling_mgr_start (
+    const axutil_env_t *env,
+    axis2_conf_ctx_t *conf_ctx,
+    sandesha2_storage_mgr_t *storage_mgr,
+    sandesha2_sender_mgr_t *sender_mgr,
+    sandesha2_msg_ctx_t *rm_msg_ctx,
+    const axis2_char_t *internal_sequence_id,
+    axis2_char_t *sequence_id,
+    const axis2_char_t *reply_to)
 {
-    sandesha2_polling_mgr_t *polling_mgr = NULL;
+    axutil_thread_t *worker_thread = NULL;
+    sandesha2_polling_mgr_args_t *args = NULL;
+    axis2_char_t *wsmc_anon_reply_to_uri = NULL;
+    sandesha2_msg_ctx_t *make_conn_rm_msg_ctx = NULL;
+    axis2_char_t *make_conn_msg_store_key = NULL;
+    axis2_msg_ctx_t *make_conn_msg_ctx = NULL;
+    sandesha2_sender_bean_t *make_conn_sender_bean = NULL;
+    axis2_status_t status = AXIS2_SUCCESS;
+    axis2_engine_t *engine = NULL;
+    axiom_soap_envelope_t *res_envelope = NULL;
+    axutil_property_t *property = NULL;
     
-    polling_mgr =  (sandesha2_polling_mgr_t *)AXIS2_MALLOC 
-        (env->allocator, 
-        sizeof(sandesha2_polling_mgr_t));
-	
-    if(!polling_mgr)
-	{
-		AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-	}
-    polling_mgr->scheduled_polling_reqs = NULL;
-    polling_mgr->poll = AXIS2_FALSE; 
-    polling_mgr->mutex = axutil_thread_mutex_create(env->allocator,
-        AXIS2_THREAD_MUTEX_DEFAULT);
-                        
-	return polling_mgr;
-}
+    args = AXIS2_MALLOC(env->allocator, sizeof(sandesha2_polling_mgr_args_t)); 
+    args->env = axutil_init_thread_env(env);
+    args->conf_ctx = conf_ctx;
+    args->internal_sequence_id = (axis2_char_t *) internal_sequence_id;
+    args->sequence_id = (axis2_char_t *) sequence_id;
 
-axis2_status_t AXIS2_CALL
-sandesha2_polling_mgr_free_void_arg(
-    void *polling_mgr,
-    const axutil_env_t *env)
-{
-    sandesha2_polling_mgr_t *polling_mgr_l = NULL;
+    if(sandesha2_utils_is_wsrm_anon_reply_to(env, reply_to))
+    {
+        wsmc_anon_reply_to_uri = axutil_strcat(env, AXIS2_WS_RM_ANONYMOUS_URL, sequence_id, NULL);
+    }
 
-    polling_mgr_l = (sandesha2_polling_mgr_t *) polling_mgr;
-    return sandesha2_polling_mgr_free(polling_mgr_l, env);
-}
+    make_conn_rm_msg_ctx = sandesha2_msg_creator_create_make_connection_msg(env, rm_msg_ctx, 
+        sequence_id, internal_sequence_id, wsmc_anon_reply_to_uri, NULL);
+   
+    if(wsmc_anon_reply_to_uri)
+    {
+        AXIS2_FREE(env->allocator, wsmc_anon_reply_to_uri);
+    }
 
-axis2_status_t AXIS2_CALL 
-sandesha2_polling_mgr_free(
-    sandesha2_polling_mgr_t *polling_mgr, 
-    const axutil_env_t *env)
-{
-    /* Do not free this */
-    polling_mgr->conf_ctx = NULL;
-    
-    if(polling_mgr->mutex)
+    args->rm_msg_ctx = make_conn_rm_msg_ctx;
+
+    make_conn_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(make_conn_rm_msg_ctx, env);
+
+    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
+    axis2_msg_ctx_set_property(make_conn_msg_ctx, env, SANDESHA2_SEQ_PROP_MAKE_CONNECTION_OUT_PATH, 
+            property);
+
+    make_conn_sender_bean = sandesha2_sender_bean_create(env);
+    if(make_conn_sender_bean)
     {
-        axutil_thread_mutex_destroy(polling_mgr->mutex);
-        polling_mgr->mutex = NULL;
+        axis2_char_t *msg_id = NULL;
+        long millisecs = 0;
+        axis2_endpoint_ref_t *to = NULL;
+
+        millisecs = sandesha2_utils_get_current_time_in_millis(env);
+        sandesha2_sender_bean_set_time_to_send(make_conn_sender_bean, env, millisecs);
+        make_conn_msg_store_key = axutil_uuid_gen(env);
+        sandesha2_sender_bean_set_msg_ctx_ref_key(make_conn_sender_bean, env, 
+                make_conn_msg_store_key);
+        msg_id = sandesha2_msg_ctx_get_msg_id(make_conn_rm_msg_ctx, env);
+        sandesha2_sender_bean_set_msg_id(make_conn_sender_bean, env, msg_id);
+        sandesha2_sender_bean_set_msg_type(make_conn_sender_bean, env, 
+            SANDESHA2_MSG_TYPE_MAKE_CONNECTION_MSG);
+        sandesha2_sender_bean_set_resend(make_conn_sender_bean, env, AXIS2_FALSE);
+        sandesha2_sender_bean_set_send(make_conn_sender_bean, env, AXIS2_TRUE);
+        sandesha2_sender_bean_set_internal_seq_id(make_conn_sender_bean, env, 
+                (axis2_char_t *) internal_sequence_id);
+
+        to = sandesha2_msg_ctx_get_to(make_conn_rm_msg_ctx, env);
+        if(to)
+        {
+            axis2_char_t *address = NULL;
+            
+            address = (axis2_char_t *) axis2_endpoint_ref_get_address(
+                    (const axis2_endpoint_ref_t *) to, env);
+            sandesha2_sender_bean_set_to_address(make_conn_sender_bean, env, address);
+        }
     }
-    if(polling_mgr->scheduled_polling_reqs)
+    else
     {
-        axutil_array_list_free(polling_mgr->scheduled_polling_reqs, env);
-        polling_mgr->scheduled_polling_reqs = NULL;
+        return AXIS2_FAILURE;
     }
-	AXIS2_FREE(env->allocator, polling_mgr);
-	return AXIS2_SUCCESS;
-}
 
-axis2_status_t AXIS2_CALL 
-sandesha2_polling_mgr_stop_polling (
-    sandesha2_polling_mgr_t *polling_mgr,
-    const axutil_env_t *env)
-{
-    sandesha2_polling_mgr_set_poll(polling_mgr, env, AXIS2_FALSE);
-    return AXIS2_SUCCESS;
-}
-            
-axis2_status_t AXIS2_CALL 
-sandesha2_polling_mgr_start (
-    sandesha2_polling_mgr_t *polling_mgr, 
-    const axutil_env_t *env, 
-    axis2_conf_ctx_t *conf_ctx,
-    const axis2_char_t *internal_seq_id)
-{
-    sandesha2_storage_mgr_t *storage_mgr = NULL;
-    axis2_char_t *dbname = NULL;
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Entry:sandesha2_polling_mgr_start");
-    AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
+    if(sender_mgr)
+    {
+        sandesha2_sender_mgr_insert(sender_mgr, env, make_conn_sender_bean);
+        sandesha2_sender_bean_free(make_conn_sender_bean, env);
+    }
     
-    axutil_thread_mutex_lock(polling_mgr->mutex);
-    polling_mgr->conf_ctx = conf_ctx;
-    polling_mgr->scheduled_polling_reqs = axutil_array_list_create(env, 
-        AXIS2_ARRAY_LIST_DEFAULT_CAPACITY);
+    engine = axis2_engine_create(env, conf_ctx);
+    status = axis2_engine_send(engine, env, make_conn_msg_ctx);
+    if(engine)
+    {
+        axis2_engine_free(engine, env);
+    }
+
+    sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, make_conn_msg_store_key, make_conn_msg_ctx, 
+            AXIS2_TRUE);
+
+    res_envelope = axis2_msg_ctx_get_response_soap_envelope(make_conn_msg_ctx, env);
 
-    if(!polling_mgr->conf_ctx)
+    if(!res_envelope)
     {
-        axutil_thread_mutex_unlock(polling_mgr->mutex);
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "conf_ctx is NULL");
-        return AXIS2_FAILURE;
+        axis2_char_t *soap_ns_uri = NULL;
+
+        soap_ns_uri = axis2_msg_ctx_get_is_soap_11(make_conn_msg_ctx, env) ?
+             AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI:
+             AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Response envelope not found");
+
+        res_envelope = (axiom_soap_envelope_t *) axis2_http_transport_utils_create_soap_msg(env, 
+                make_conn_msg_ctx, soap_ns_uri);
     }
-    dbname = sandesha2_util_get_dbname(env, conf_ctx);
-    storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
-    sandesha2_polling_mgr_set_poll(polling_mgr, env, AXIS2_TRUE);
-    sandesha2_polling_mgr_schedule_polling_request(polling_mgr, env, 
-        internal_seq_id);
-    sandesha2_polling_mgr_run(polling_mgr, env, storage_mgr);
-    axutil_thread_mutex_unlock(polling_mgr->mutex);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Exit:sandesha2_polling_mgr_start");
-    return AXIS2_SUCCESS;
-}
-            
-static axis2_status_t AXIS2_CALL 
-sandesha2_polling_mgr_run (
-    sandesha2_polling_mgr_t *polling_mgr,
-    const axutil_env_t *env,
-    sandesha2_storage_mgr_t *storage_mgr)
-{
-    axutil_thread_t *worker_thread = NULL;
-    sandesha2_polling_mgr_args_t *args = NULL;
-    
-    args = AXIS2_MALLOC(env->allocator, sizeof(
-                        sandesha2_polling_mgr_args_t)); 
-    args->impl = polling_mgr;
-    args->env = (axutil_env_t*)env;
-    args->storage_mgr = storage_mgr;
-    worker_thread = axutil_thread_pool_get_thread(env->thread_pool,
-        sandesha2_polling_mgr_worker_func, (void*)args);
+
+    if(res_envelope)
+    {
+        axis2_msg_ctx_set_response_soap_envelope(make_conn_msg_ctx, env, res_envelope);
+        status = sandesha2_polling_mgr_process_make_connection_msg_response(env, make_conn_msg_ctx, 
+                storage_mgr);
+
+        if(AXIS2_SUCCESS != status)
+        {
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                "[sandesha2] Make connection message response process failed for sequence %s", 
+                internal_sequence_id);
+
+            return AXIS2_FAILURE;
+        }
+    }
+
+    worker_thread = axutil_thread_pool_get_thread(env->thread_pool, 
+            sandesha2_polling_mgr_worker_func, (void*)args);
+
     if(!worker_thread)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Thread creation failed" \
-            " sandesha2_polling_mgr_run");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                "Thread creation failed sandesha2_polling_mgr_run");
+
         return AXIS2_FAILURE;
     }
+
     axutil_thread_pool_thread_detach(env->thread_pool, worker_thread); 
         
     return AXIS2_SUCCESS;
@@ -214,259 +227,236 @@
     axutil_thread_t *thd, 
     void *data)
 {
-    axis2_char_t *dbname = NULL; 
-    sandesha2_polling_mgr_args_t *args = (sandesha2_polling_mgr_args_t*)data;
-    axutil_env_t *env = args->env;
-    sandesha2_polling_mgr_t *polling_mgr = args->impl;
-    sandesha2_storage_mgr_t *storage_mgr = args->storage_mgr;
+    axis2_char_t *dbname = NULL;
+    axis2_char_t *internal_sequence_id = NULL;
+    axis2_char_t *sequence_id = NULL;
+    axis2_conf_ctx_t *conf_ctx = NULL;
+    sandesha2_storage_mgr_t *storage_mgr = NULL;
     sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
     sandesha2_sender_mgr_t *sender_mgr = NULL;
     sandesha2_next_msg_mgr_t *next_msg_mgr = NULL;
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Entry:sandesha2_polling_mgr_worker_func");
+    axis2_msg_ctx_t *make_conn_msg_ctx = NULL;
+    sandesha2_property_bean_t *property_bean = NULL;
+    axis2_conf_t *conf = NULL;
+    int wait_time = 0;
+    axis2_status_t status = AXIS2_FAILURE;
+    sandesha2_sender_bean_t *find_sender_bean = NULL;
+    sandesha2_sender_bean_t *sender_bean = NULL;
+    axis2_char_t *key = NULL;
+    
+    sandesha2_polling_mgr_args_t *args = (sandesha2_polling_mgr_args_t*)data;
+    axutil_env_t *env = args->env;
+    conf_ctx = args->conf_ctx;
+    internal_sequence_id = axutil_strdup(env, args->internal_sequence_id);
+    sequence_id = axutil_strdup(env, args->sequence_id);
 
-    dbname = sandesha2_util_get_dbname(env, polling_mgr->conf_ctx);
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_polling_mgr_worker_func");
+
+    dbname = sandesha2_util_get_dbname(env, conf_ctx);
+    
+    storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
     seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
     sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
     next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname);
+ 
+    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+    property_bean = sandesha2_utils_get_property_bean(env, conf);
+    wait_time = sandesha2_property_bean_get_polling_delay(property_bean, env);
+
+    find_sender_bean = sandesha2_sender_bean_create(env);
+    sandesha2_sender_bean_set_msg_type(find_sender_bean, env, SANDESHA2_MSG_TYPE_MAKE_CONNECTION_MSG);
+    sandesha2_sender_bean_set_internal_seq_id(find_sender_bean, env, internal_sequence_id);
+    sandesha2_sender_bean_set_send(find_sender_bean, env, AXIS2_TRUE);
 
-    while(polling_mgr->poll)
+    sender_bean = sandesha2_sender_mgr_find_unique(sender_mgr, env, find_sender_bean);
+    if(find_sender_bean)
     {
-        sandesha2_next_msg_bean_t *next_msg_bean = NULL;
-        sandesha2_msg_ctx_t *ref_rm_msg_ctx = NULL;
-        sandesha2_msg_ctx_t *make_conn_rm_msg_ctx = NULL;
-        sandesha2_sender_bean_t *make_conn_sender_bean = NULL;
-        int size = 0;
-        axis2_char_t *seq_id = NULL;
-        axis2_char_t *make_conn_seq_id = NULL;
-        axis2_char_t *ref_msg_key = NULL;
-        axis2_char_t *seq_prop_key = NULL;
-        axis2_char_t *reply_to = NULL;
-        axis2_char_t *wsrm_anon_reply_to_uri = NULL;
-        axis2_char_t *make_conn_msg_store_key = NULL;
-        axis2_char_t *msg_id = NULL;
-        axis2_msg_ctx_t *ref_msg_ctx = NULL;
-        axis2_msg_ctx_t *make_conn_msg_ctx = NULL;
-        axis2_endpoint_ref_t *to = NULL;
+        sandesha2_sender_bean_free(find_sender_bean, env);
+    }
+    if(sender_bean)
+    {
+        key = sandesha2_sender_bean_get_msg_ctx_ref_key(sender_bean, env);
+    }
+
+    while(AXIS2_TRUE)
+    {
+        axiom_soap_envelope_t *res_envelope = NULL;
+        axis2_char_t *soap_ns_uri = NULL;
         axutil_property_t *property = NULL;
-        axutil_qname_t *qname = NULL;
-        axutil_param_t *wait_time_param = NULL;
-        int wait_time = 0;
-        axis2_conf_t *conf = NULL;
-        axis2_module_desc_t *module_desc = NULL;
-        axis2_status_t status = AXIS2_FAILURE;
-
-        conf = axis2_conf_ctx_get_conf(polling_mgr->conf_ctx, env);
-        qname = axutil_qname_create(env, "sandesha2", NULL, NULL);
-        module_desc = axis2_conf_get_module(conf, env, qname);
-        wait_time_param = axis2_module_desc_get_param(module_desc, env, 
-            SANDESHA2_POLLING_WAIT);
-        if(wait_time_param)
-        {
-            wait_time = AXIS2_ATOI(axutil_param_get_value(wait_time_param, env));
-        }
-        if(qname)
-            axutil_qname_free(qname, env);
+
+        axis2_transport_out_desc_t *transport_out = NULL;
+        axis2_transport_sender_t *transport_sender = NULL;
+        axis2_bool_t successfully_sent = AXIS2_FALSE;
+
         AXIS2_SLEEP(wait_time);
-         /* Getting the sequences to be polled. if schedule contains any requests, 
-          * do the earliest one. else pick one randomly.
-          */
-        if(polling_mgr->scheduled_polling_reqs)
-            size = axutil_array_list_size(polling_mgr->scheduled_polling_reqs, 
-                env);
-        if(size > 0)
+        
+        make_conn_msg_ctx = sandesha2_storage_mgr_retrieve_msg_ctx(storage_mgr, env, key, conf_ctx, 
+                AXIS2_TRUE);
+
+        property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
+        axis2_msg_ctx_set_property(make_conn_msg_ctx, env, SANDESHA2_SEQ_PROP_MAKE_CONNECTION_OUT_PATH, 
+                property);
+
+        soap_ns_uri = axis2_msg_ctx_get_is_soap_11(make_conn_msg_ctx, env) ?
+             AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI:
+             AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+            "[sandesha2] Sending make connection message for sequence with internal sequence id %s", 
+            internal_sequence_id);
+
+        transport_out = axis2_msg_ctx_get_transport_out_desc(make_conn_msg_ctx, env);
+        if(transport_out)
         {
-            seq_id = axutil_array_list_get(polling_mgr->scheduled_polling_reqs, 
-                env, 0);
-            /*axutil_array_list_remove(polling_mgr->scheduled_polling_reqs, env, 0);*/
+            transport_sender = axis2_transport_out_desc_get_sender(transport_out, env);
         }
-        if(!seq_id)
+        if(transport_sender)
         {
-            sandesha2_next_msg_bean_t *find_bean = 
-                sandesha2_next_msg_bean_create(env);
-            int size = 0;
-            if(find_bean)
+            /* This is neccessary to avoid a double free at http_sender.c */
+            axis2_msg_ctx_set_property(make_conn_msg_ctx, env, AXIS2_TRANSPORT_IN, NULL);
+            if(AXIS2_TRANSPORT_SENDER_INVOKE(transport_sender, env, make_conn_msg_ctx))
             {
-                axutil_array_list_t *results = NULL;
-                sandesha2_next_msg_bean_set_polling_mode(find_bean, env, 
-                    AXIS2_TRUE);
-                results = sandesha2_next_msg_mgr_find(next_msg_mgr, env, 
-                    find_bean);
-                if(results)
-                    size = axutil_array_list_size(results, env);
-                if(size > 0)
-                {
-                    unsigned int rand_var = 
-                        axutil_rand_get_seed_value_based_on_time(env);
-                    int item = axutil_rand_with_range(&rand_var, 0, size);
-                    item--;
-                    next_msg_bean = (sandesha2_next_msg_bean_t *) 
-                        axutil_array_list_get(results, env, item);
-                }
-
-            }
-        }
-        else
-        {
-            sandesha2_next_msg_bean_t *find_bean = 
-                sandesha2_next_msg_bean_create(env);
-            if(find_bean)
+                successfully_sent = AXIS2_TRUE;
+            }else
             {
-                sandesha2_next_msg_bean_set_polling_mode(find_bean, env, 
-                    AXIS2_TRUE);
-                sandesha2_next_msg_bean_set_internal_seq_id(find_bean, env, seq_id);
-                next_msg_bean = sandesha2_next_msg_mgr_find_unique(next_msg_mgr,
-                    env, find_bean);
+                successfully_sent = AXIS2_FALSE;
             }
         }
-        /* If no valid entry is found, try again later */
-        if(!next_msg_bean)
+
+        if(successfully_sent)
         {
-            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-                "No valid MakeConnection entry is found.");
-            continue;
+            res_envelope = axis2_msg_ctx_get_response_soap_envelope(make_conn_msg_ctx, env);
         }
-        make_conn_seq_id = sandesha2_next_msg_bean_get_seq_id(next_msg_bean, env);
-        /* Create a MakeConnection message */
-        ref_msg_key = sandesha2_next_msg_bean_get_ref_msg_key(next_msg_bean, env);
-        seq_prop_key = make_conn_seq_id;
-        reply_to = sandesha2_utils_get_seq_property(env, seq_prop_key, 
-            SANDESHA2_SEQ_PROP_REPLY_TO_EPR, seq_prop_mgr);
-        if(sandesha2_utils_is_wsrm_anon_reply_to(env, reply_to))
-            wsrm_anon_reply_to_uri = reply_to;
-        ref_msg_ctx = sandesha2_storage_mgr_retrieve_msg_ctx(storage_mgr, env, 
-            ref_msg_key, polling_mgr->conf_ctx, AXIS2_FALSE);
-        if(ref_msg_ctx)
-            ref_rm_msg_ctx = sandesha2_msg_init_init_msg(env, ref_msg_ctx);
-        make_conn_rm_msg_ctx = 
-            sandesha2_msg_creator_create_make_connection_msg(env, 
-            ref_rm_msg_ctx, make_conn_seq_id, wsrm_anon_reply_to_uri, seq_prop_mgr);
-        if(reply_to)
-            AXIS2_FREE(env->allocator, reply_to);
-        if(!make_conn_rm_msg_ctx)
+
+        if(!res_envelope)
         {
-            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
-            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-            if(seq_prop_mgr)
-                sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
-            if(sender_mgr)
-                sandesha2_sender_mgr_free(sender_mgr, env);
-            if(next_msg_mgr)
-                sandesha2_next_msg_mgr_free(next_msg_mgr, env);
-            return NULL;
+            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Response envelope not found");
+
+            res_envelope = (axiom_soap_envelope_t *) axis2_http_transport_utils_create_soap_msg(env, 
+                    make_conn_msg_ctx, soap_ns_uri);
         }
-        sandesha2_msg_ctx_set_property(make_conn_rm_msg_ctx, env, 
-            AXIS2_TRANSPORT_IN, NULL);
-        /* Storing the MakeConnection message */
-        make_conn_msg_store_key = axutil_uuid_gen(env);
-        property = axutil_property_create_with_args(env, 0, 0, 0, seq_prop_key);
-        sandesha2_msg_ctx_set_property(make_conn_rm_msg_ctx, env, 
-            SANDESHA2_MSG_CTX_PROP_SEQUENCE_PROPERTY_KEY, property); 
-        make_conn_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(make_conn_rm_msg_ctx, 
-            env);
-        sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, 
-            make_conn_msg_store_key, make_conn_msg_ctx);
-        /* Adde an entry for the MakeConnection message to the sender(with, 
-         * send=true, resend=false)
-         */
-        make_conn_sender_bean = sandesha2_sender_bean_create(env);
-        if(make_conn_sender_bean)
+        
+        if(res_envelope)
         {
-            long millisecs = 0;
-            millisecs = sandesha2_utils_get_current_time_in_millis(env);
-            sandesha2_sender_bean_set_time_to_send(make_conn_sender_bean, env, 
-                millisecs);
-            sandesha2_sender_bean_set_msg_ctx_ref_key(make_conn_sender_bean, env, 
-                make_conn_msg_store_key);
-            msg_id = sandesha2_msg_ctx_get_msg_id(make_conn_rm_msg_ctx, env);
-            sandesha2_sender_bean_set_msg_id(make_conn_sender_bean, env, msg_id);
-            sandesha2_sender_bean_set_msg_type(make_conn_sender_bean, env, 
-                SANDESHA2_MSG_TYPE_MAKE_CONNECTION_MSG);
-            sandesha2_sender_bean_set_resend(make_conn_sender_bean, env, AXIS2_FALSE);
-            sandesha2_sender_bean_set_send(make_conn_sender_bean, env, AXIS2_TRUE);
-            /*sandesha2_sender_bean_set_seq_id(make_conn_sender_bean, env, seq_id);*/
-            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]seq_id:%s", seq_id);
-            sandesha2_sender_bean_set_internal_seq_id(make_conn_sender_bean, 
-                env, seq_id);
-            to = sandesha2_msg_ctx_get_to(make_conn_rm_msg_ctx, env);
-            if(to)
+            axis2_msg_ctx_set_response_soap_envelope(make_conn_msg_ctx, env, res_envelope);
+            status = sandesha2_polling_mgr_process_make_connection_msg_response(env, make_conn_msg_ctx, 
+                    storage_mgr);
+
+            if(AXIS2_SUCCESS != status)
             {
-                axis2_char_t *address = (axis2_char_t *) 
-                    axis2_endpoint_ref_get_address(
-                    (const axis2_endpoint_ref_t *) to, env);
-                sandesha2_sender_bean_set_to_address(make_conn_sender_bean, env, 
-                    address);
+                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                    "[sandesha2] Make connection message response process failed for sequence %s", 
+                    internal_sequence_id);
+
+                break;
             }
         }
-        /* This message should not be sent untils it is qualified. i.e. Till
-         * it is sent through the sandesha2_transport_sender
-         */
-        property = axutil_property_create_with_args(env, 0, 0, 0, 
-            AXIS2_VALUE_FALSE);
-        sandesha2_msg_ctx_set_property(make_conn_rm_msg_ctx, env, 
-            SANDESHA2_QUALIFIED_FOR_SENDING, property);
-        if(sender_mgr)
-        {
-            sandesha2_sender_mgr_insert(sender_mgr, env, 
-                make_conn_sender_bean);
-        }
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]Sending the make "\
-            "connection message for the sequence with internal sequence id %s", 
-            seq_id);
-        status = sandesha2_utils_execute_and_store(env, make_conn_rm_msg_ctx, 
-            make_conn_msg_store_key);
-        if(!status)
-        {
-            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-                "[sandesha2]make_connection sending failed");
-            if(seq_prop_mgr)
-                sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
-            if(sender_mgr)
-                sandesha2_sender_mgr_free(sender_mgr, env);
-            if(next_msg_mgr)
-                sandesha2_next_msg_mgr_free(next_msg_mgr, env);
-            return NULL;
-        }
     }
+
     if(seq_prop_mgr)
+    {
         sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+    }
+
     if(sender_mgr)
+    {
         sandesha2_sender_mgr_free(sender_mgr, env);
+    }
+
     if(next_msg_mgr)
+    {
         sandesha2_next_msg_mgr_free(next_msg_mgr, env);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Exit:sandesha2_polling_mgr_worker_func");
+    }
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_polling_mgr_worker_func");
+
     return NULL;
 }
 
-void AXIS2_CALL
-sandesha2_polling_mgr_set_poll(
-    sandesha2_polling_mgr_t *polling_mgr,
-    const axutil_env_t *env,
-    axis2_bool_t poll)
+static axis2_status_t AXIS2_CALL
+sandesha2_polling_mgr_process_make_connection_msg_response(
+    const axutil_env_t *env, 
+    axis2_msg_ctx_t *msg_ctx,
+    sandesha2_storage_mgr_t *storage_mgr)
 {
-    polling_mgr->poll = poll;
-}
+    axis2_char_t *soap_ns_uri = NULL;
+    axis2_msg_ctx_t *response_msg_ctx = NULL;
+    axiom_soap_envelope_t *response_envelope = NULL;
+    axis2_conf_ctx_t *conf_ctx = NULL;
+    axis2_engine_t *engine = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    axis2_endpoint_ref_t *to = NULL;
+   
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
+        "[sandesha2] Entry:sandesha2_polling_mgr_process_make_connection_msg_response");
+
+    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+
+    soap_ns_uri = axis2_msg_ctx_get_is_soap_11(msg_ctx, env) ?
+         AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI:
+         AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
 
-axis2_bool_t AXIS2_CALL
-sandesha2_polling_mgr_is_poll(
-    sandesha2_polling_mgr_t *polling_mgr,
-    const axutil_env_t *env)
-{
-    return polling_mgr->poll;
-}
+    response_envelope = axis2_msg_ctx_get_response_soap_envelope(msg_ctx, env);
+    if(!response_envelope)
+    {
+        response_envelope = (axiom_soap_envelope_t *) axis2_http_transport_utils_create_soap_msg(env, 
+                msg_ctx, soap_ns_uri);
+        if(!response_envelope)
+        {
+            /* There is no response message context. */
 
-void AXIS2_CALL
-sandesha2_polling_mgr_schedule_polling_request(
-    sandesha2_polling_mgr_t *polling_mgr,
-    const axutil_env_t *env,
-    const axis2_char_t *internal_seq_id)
-{
-    if(!axutil_array_list_contains(polling_mgr->scheduled_polling_reqs, env, 
-        (axis2_char_t *)internal_seq_id))
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Response envelope not found");
+
+            return AXIS2_SUCCESS;
+        }
+    }
+
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+        "[sandesha2] Response envelope for make connection message found");
+
+    response_msg_ctx = axis2_msg_ctx_create(env, conf_ctx, axis2_msg_ctx_get_transport_in_desc(msg_ctx, 
+                env), axis2_msg_ctx_get_transport_out_desc(msg_ctx, env));
+   
+    to = axis2_endpoint_ref_create(env, 
+        "http://localhost/axis2/services/__ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__");
+    axis2_msg_ctx_set_to(response_msg_ctx, env, to);
+
+    axis2_msg_ctx_set_wsa_action(response_msg_ctx, env, 
+            "http://localhost/axis2/services/__ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__");
+
+    axis2_msg_ctx_set_soap_envelope(response_msg_ctx, env, response_envelope);
+
+    /*axis2_msg_ctx_set_server_side(response_msg_ctx, env, AXIS2_TRUE);*/
+
+    axis2_msg_ctx_set_op_ctx(response_msg_ctx, env, axis2_msg_ctx_get_op_ctx(msg_ctx, env));
+    axis2_msg_ctx_set_svc_ctx(response_msg_ctx, env, axis2_msg_ctx_get_svc_ctx(msg_ctx, env));
+    axis2_msg_ctx_set_svc_grp_ctx(response_msg_ctx, env, axis2_msg_ctx_get_svc_grp_ctx(msg_ctx, env));
+    axis2_msg_ctx_set_conf_ctx(response_msg_ctx, env, conf_ctx);
+
+
+    engine = axis2_engine_create(env, conf_ctx);
+    if(engine)
     {
-        axutil_array_list_add(polling_mgr->scheduled_polling_reqs, env, 
-            internal_seq_id);
+        if(sandesha2_util_is_fault_envelope(env, response_envelope))
+        {
+            status = axis2_engine_receive_fault(engine, env, response_msg_ctx);
+        }
+        else
+        {
+            status = axis2_engine_receive(engine, env, response_msg_ctx);
+        }
+            axis2_engine_free(engine, env);
     }
+
+    axis2_msg_ctx_set_paused(response_msg_ctx, env, AXIS2_FALSE);
+    axis2_msg_ctx_free(response_msg_ctx, env);
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
+        "[sandesha2] Exit:sandesha2_polling_mgr_process_make_connection_msg_response");
+
+    return AXIS2_SUCCESS;
 }
 
+

Modified: webservices/sandesha/trunk/c/src/storage/beans/create_seq_bean.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/beans/create_seq_bean.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/beans/create_seq_bean.c (original)
+++ webservices/sandesha/trunk/c/src/storage/beans/create_seq_bean.c Thu Aug 28 23:56:29 2008
@@ -91,9 +91,9 @@
 	}
 
 	/* init the properties. */
-	create_seq_bean->internal_seq_id = internal_seq_id;
-	create_seq_bean->create_seq_msg_id = create_seq_msg_id;
-	create_seq_bean->seq_id = seq_id;
+	create_seq_bean->internal_seq_id = axutil_strdup(env, internal_seq_id);
+	create_seq_bean->create_seq_msg_id = axutil_strdup(env, create_seq_msg_id);
+	create_seq_bean->seq_id = axutil_strdup(env, seq_id);
     create_seq_bean->create_seq_msg_store_key = NULL;
     create_seq_bean->ref_msg_store_key = NULL;
 
@@ -120,7 +120,7 @@
 	if(create_seq_bean->seq_id)
 	{
 		AXIS2_FREE(env->allocator, create_seq_bean->seq_id);
-		create_seq_bean->seq_id= NULL;
+		create_seq_bean->seq_id = NULL;
 	}
 	if(create_seq_bean->create_seq_msg_store_key)
 	{
@@ -155,11 +155,16 @@
     axis2_char_t* seq_msg_id)
 
 {
+    if(create_seq_bean->create_seq_msg_id)
+    {
+        AXIS2_FREE(env->allocator, create_seq_bean->create_seq_msg_id);
+    }
+
 	create_seq_bean->create_seq_msg_id = axutil_strdup(env, seq_msg_id);
 }
 
 axis2_char_t * AXIS2_CALL
-sandesha2_create_seq_bean_get_seq_id(
+sandesha2_create_seq_bean_get_rms_sequence_id(
     sandesha2_create_seq_bean_t *create_seq_bean,
 	const axutil_env_t *env)
 {
@@ -167,15 +172,21 @@
 }
 
 void AXIS2_CALL
-sandesha2_create_seq_bean_set_seq_id(
+sandesha2_create_seq_bean_set_rms_sequence_id(
     sandesha2_create_seq_bean_t *create_seq_bean,
-	const axutil_env_t *env, axis2_char_t *seq_id)
+	const axutil_env_t *env, 
+    axis2_char_t *seq_id)
 {
+    if(create_seq_bean->seq_id)
+    {
+        AXIS2_FREE(env->allocator, create_seq_bean->seq_id);
+    }
+
 	create_seq_bean->seq_id = axutil_strdup(env, seq_id);
 }
 
 axis2_char_t * AXIS2_CALL
-sandesha2_create_seq_bean_get_internal_seq_id( 
+sandesha2_create_seq_bean_get_internal_sequence_id( 
     sandesha2_create_seq_bean_t *create_seq_bean,
 	const axutil_env_t *env)
 {
@@ -183,10 +194,15 @@
 }
 
 void AXIS2_CALL
-sandesha2_create_seq_bean_set_internal_seq_id( 
+sandesha2_create_seq_bean_set_internal_sequence_id( 
     sandesha2_create_seq_bean_t *create_seq_bean,
 	const axutil_env_t *env, axis2_char_t *int_seq_id)
 {
+    if(create_seq_bean->internal_seq_id)
+    {
+        AXIS2_FREE(env->allocator, create_seq_bean->internal_seq_id);
+    }
+
 	create_seq_bean->internal_seq_id = axutil_strdup(env, int_seq_id);
 }
 
@@ -203,8 +219,12 @@
     sandesha2_create_seq_bean_t *create_seq_bean,
 	const axutil_env_t *env, axis2_char_t *create_seq_msg_store_key)
 {
-    create_seq_bean->create_seq_msg_store_key = axutil_strdup(
-        env, create_seq_msg_store_key);
+    if(create_seq_bean->create_seq_msg_store_key)
+    {
+        AXIS2_FREE(env->allocator, create_seq_bean->create_seq_msg_store_key);
+    }
+
+    create_seq_bean->create_seq_msg_store_key = axutil_strdup(env, create_seq_msg_store_key);
 }
 
 axis2_char_t * AXIS2_CALL
@@ -220,6 +240,11 @@
     sandesha2_create_seq_bean_t *create_seq_bean,
 	const axutil_env_t *env, axis2_char_t *ref_msg_store_key)
 {
+    if(create_seq_bean->ref_msg_store_key)
+    {
+        AXIS2_FREE(env->allocator, create_seq_bean->ref_msg_store_key);
+    }
+
     create_seq_bean->ref_msg_store_key = axutil_strdup(env, ref_msg_store_key);
 }
 

Modified: webservices/sandesha/trunk/c/src/storage/beans/seq_property_bean.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/beans/seq_property_bean.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/beans/seq_property_bean.c (original)
+++ webservices/sandesha/trunk/c/src/storage/beans/seq_property_bean.c Thu Aug 28 23:56:29 2008
@@ -171,8 +171,10 @@
 		AXIS2_FREE(env->allocator, seq_property_bean->value);
 		seq_property_bean->value = NULL;
 	}
+
     if(value)
+    {
         seq_property_bean->value = (axis2_char_t *)axutil_strdup(env, value);
-
+    }
 }
 

Modified: webservices/sandesha/trunk/c/src/storage/common/sender_mgr.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/common/sender_mgr.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/common/sender_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/storage/common/sender_mgr.c Thu Aug 28 23:56:29 2008
@@ -96,6 +96,16 @@
 }
 
 sandesha2_sender_bean_t *AXIS2_CALL
+sandesha2_sender_mgr_get_application_msg_to_send(
+    sandesha2_sender_mgr_t *sender,
+    const axutil_env_t *env,
+    const axis2_char_t *seq_id,
+    const axis2_char_t *msg_id)
+{
+    return sender->ops.get_application_msg_to_send(sender, env, seq_id, msg_id);
+}
+
+sandesha2_sender_bean_t *AXIS2_CALL
 sandesha2_sender_mgr_get_next_msg_to_send(
     sandesha2_sender_mgr_t *sender,
     const axutil_env_t *env,

Modified: webservices/sandesha/trunk/c/src/storage/common/seq_property_mgr.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/common/seq_property_mgr.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/common/seq_property_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/storage/common/seq_property_mgr.c Thu Aug 28 23:56:29 2008
@@ -54,8 +54,8 @@
 sandesha2_seq_property_mgr_retrieve(
     sandesha2_seq_property_mgr_t *seq_prop_mgr,
     const axutil_env_t *env,
-    axis2_char_t *seq_id,
-    axis2_char_t *name)
+    const axis2_char_t *seq_id,
+    const axis2_char_t *name)
 {
     return seq_prop_mgr->ops.retrieve(seq_prop_mgr, env, seq_id, name);
 }

Modified: webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/storage/common/storage_mgr.c Thu Aug 28 23:56:29 2008
@@ -74,9 +74,10 @@
     sandesha2_storage_mgr_t *storage_mgr,
     const axutil_env_t *env,
     axis2_char_t *key,
-    axis2_msg_ctx_t *msg_ctx)
+    axis2_msg_ctx_t *msg_ctx,
+    axis2_bool_t store_in_memory)
 {
-     return storage_mgr->ops->store_msg_ctx(storage_mgr, env, key, msg_ctx);
+     return storage_mgr->ops->store_msg_ctx(storage_mgr, env, key, msg_ctx, store_in_memory);
 }
 			
 axis2_status_t AXIS2_CALL

Modified: webservices/sandesha/trunk/c/src/storage/sqlite/msg_store_bean.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/sqlite/msg_store_bean.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/sqlite/msg_store_bean.c (original)
+++ webservices/sandesha/trunk/c/src/storage/sqlite/msg_store_bean.c Thu Aug 28 23:56:29 2008
@@ -97,11 +97,15 @@
         AXIS2_FREE(env->allocator, msg_store_bean->stored_key);
         msg_store_bean->stored_key = NULL;
     }
+
+    /* We should not free the envelope buffer here. Ownership is transferred to storage manager
+    msg_store_bean->soap_env_str = NULL;*/
     if(msg_store_bean->soap_env_str)
     {
         AXIS2_FREE(env->allocator, msg_store_bean->soap_env_str);
         msg_store_bean->soap_env_str = NULL;
     }
+
     if(msg_store_bean->op)
     {
         AXIS2_FREE(env->allocator, msg_store_bean->op);
@@ -183,6 +187,11 @@
     const axutil_env_t *env,
     axis2_char_t * msg_id) 
 {
+    if(msg_store_bean->msg_id)
+    {
+        AXIS2_FREE(env->allocator, msg_store_bean->msg_id);
+    }
+
     msg_store_bean->msg_id = axutil_strdup(env, msg_id);
 }
 
@@ -200,6 +209,11 @@
     const axutil_env_t *env,
     axis2_char_t * key) 
 {
+    if(msg_store_bean->stored_key)
+    {
+        AXIS2_FREE(env->allocator, msg_store_bean->stored_key);
+    }
+
     msg_store_bean->stored_key = axutil_strdup(env, key);
 }
 
@@ -217,6 +231,11 @@
     const axutil_env_t *env,
     axis2_char_t * soap_env_str) 
 {
+    if(msg_store_bean->soap_env_str)
+    {
+        AXIS2_FREE(env->allocator, msg_store_bean->soap_env_str);
+    }
+
     msg_store_bean->soap_env_str = axutil_strdup(env, soap_env_str);
 }
 

Modified: webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c (original)
+++ webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c Thu Aug 28 23:56:29 2008
@@ -106,10 +106,15 @@
         if(0 == axutil_strcmp(col_name[i], "msg_id"))
             if(argv[i])
                 sandesha2_msg_store_bean_set_msg_id(bean, env, argv[i]);
-        if(0 == axutil_strcmp(col_name[i], "soap_env_str"))
-            if(argv[i])
-                sandesha2_msg_store_bean_set_soap_envelope_str(bean, env, 
-                    argv[i]);
+
+        if(!axutil_strcmp(col_name[i], "soap_env_str"))
+        {
+            if(argv[i] && axutil_strcmp("(null)", argv[i]))
+            {
+                sandesha2_msg_store_bean_set_soap_envelope_str(bean, env, argv[i]);
+            }
+        }
+
         if(0 == axutil_strcmp(col_name[i], "soap_version"))
             if(argv[i])
                 sandesha2_msg_store_bean_set_soap_version(bean, env, AXIS2_ATOI(argv[i]));
@@ -128,9 +133,15 @@
         if(0 == axutil_strcmp(col_name[i], "op_mep"))
             if(argv[i])
                 sandesha2_msg_store_bean_set_op_mep(bean, env, argv[i]);
+
         if(0 == axutil_strcmp(col_name[i], "to_url"))
-            if(argv[i])
+        {
+            if(argv[i] && axutil_strcmp("(null)", argv[i]))
+            {
                 sandesha2_msg_store_bean_set_to_url(bean, env, argv[i]);
+            }
+        }
+
         if(0 == axutil_strcmp(col_name[i], "transport_to"))
             if(argv[i] && 0 != axutil_strcmp("(null)", argv[i]))
             {
@@ -239,7 +250,6 @@
     axis2_char_t *error_msg = NULL;
     int rc = -1;
     sqlite3 *dbconn = NULL;
-
     dbconn = sandesha2_permanent_bean_mgr_get_dbconn(env, bean_mgr->dbname);
     if(!dbconn)
     {
@@ -259,7 +269,6 @@
         return AXIS2_FALSE;
     }
     sqlite3_close(dbconn);
-
     return AXIS2_TRUE;
 }
 
@@ -355,7 +364,6 @@
     sqlite3 *dbconn = NULL;
     axutil_array_list_t *data_array = NULL;
     axis2_char_t *error_msg = NULL;
-
     args = AXIS2_MALLOC(env->allocator, sizeof(sandesha2_bean_mgr_args_t));
     args->env = (axutil_env_t*)env;
     args->data = NULL;
@@ -387,7 +395,6 @@
     if(args)
         AXIS2_FREE(env->allocator, args);
     sqlite3_close(dbconn);
-
     return data_array;
 }
 
@@ -403,8 +410,7 @@
     int rc = -1;
     sqlite3 *dbconn = NULL;
     axis2_char_t sql_stmt_retrieve[512];
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Entry:sandesha2_permanent_bean_mgr_retrieve_msg_store_bean");
+
     dbconn = sandesha2_permanent_bean_mgr_get_dbconn(env, bean_mgr->dbname);
     if(!dbconn)
     {
@@ -438,8 +444,7 @@
     if(args)
         AXIS2_FREE(env->allocator, args);
     sqlite3_close(dbconn);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Exit:sandesha2_permanent_bean_mgr_retrieve_msg_store_bean");
+
     return msg_store_bean;
 }
 
@@ -474,8 +479,6 @@
 	axis2_char_t *action = NULL;
     sqlite3 *dbconn = NULL;
 
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Entry:sandesha2_permanent_bean_mgr_update_msg_store_bean");
 	msg_id = sandesha2_msg_store_bean_get_msg_id(bean, env);
 	stored_key = sandesha2_msg_store_bean_get_stored_key(bean, env);
 	soap_env_str =  sandesha2_msg_store_bean_get_soap_envelope_str(bean, env);
@@ -535,8 +538,7 @@
     }
     AXIS2_FREE(env->allocator, sql_stmt_update);
     sqlite3_close(dbconn);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Exit:sandesha2_permanent_bean_mgr_update_msg_store_bean");
+
     return AXIS2_TRUE;
 }
 
@@ -571,8 +573,6 @@
 	axis2_char_t *action = NULL;
     sqlite3 *dbconn = NULL;
 
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Entry:sandesha2_permanent_bean_mgr_insert_msg_store_bean");
 	msg_id = sandesha2_msg_store_bean_get_msg_id(bean, env);
 	stored_key = sandesha2_msg_store_bean_get_stored_key(bean, env);
 	soap_env_str =  sandesha2_msg_store_bean_get_soap_envelope_str(bean, env);
@@ -631,8 +631,7 @@
     }
     AXIS2_FREE(env->allocator, sql_stmt_insert);
     sqlite3_close(dbconn);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Exit:sandesha2_permanent_bean_mgr_insert_msg_store_bean");
+
     return AXIS2_TRUE;
 }
 
@@ -646,8 +645,7 @@
     axis2_char_t *error_msg = NULL;
     int rc = -1;
     sqlite3 *dbconn = NULL;
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Entry:sandesha2_permanent_bean_mgr_remove_msg_store_bean");
+
     dbconn = sandesha2_permanent_bean_mgr_get_dbconn(env, bean_mgr->dbname);
     if(!dbconn)
     {
@@ -668,8 +666,7 @@
         return AXIS2_FALSE;
     }
     sqlite3_close(dbconn);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Exit:sandesha2_permanent_bean_mgr_remove_msg_store_bean");
+
     return AXIS2_TRUE;
 }
 
@@ -688,8 +685,6 @@
     int sql_size = -1;
     sqlite3 *dbconn = NULL;
 
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Entry:sandesha2_permanent_bean_mgr_store_response");
     sql_size = axutil_strlen(seq_id) + axutil_strlen(response) + 
         sizeof(int) + sizeof(int) + 512;
     dbconn = sandesha2_permanent_bean_mgr_get_dbconn(env, bean_mgr->dbname);
@@ -716,8 +711,7 @@
     }
     AXIS2_FREE(env->allocator, sql_stmt_insert);
     sqlite3_close(dbconn);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
-        "[sandesha2]Exit:sandesha2_permanent_bean_mgr_store_response");
+
     return AXIS2_TRUE;
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org


Mime
View raw message