You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by da...@apache.org on 2006/11/21 06:11:39 UTC

svn commit: r477506 - in /webservices/sandesha/trunk/c: Makefile.am config/module.xml include/sandesha2_constants.h samples/rm_echo/rm_echo_client.c src/msgprocessors/app_msg_processor.c src/polling/ src/polling/Makefile.am src/polling/polling_mgr.c

Author: damitha
Date: Mon Nov 20 21:11:39 2006
New Revision: 477506

URL: http://svn.apache.org/viewvc?view=rev&rev=477506
Log:
added new directory related to implementing MakeConnection functionality

Added:
    webservices/sandesha/trunk/c/src/polling/
    webservices/sandesha/trunk/c/src/polling/Makefile.am
    webservices/sandesha/trunk/c/src/polling/polling_mgr.c
Modified:
    webservices/sandesha/trunk/c/Makefile.am
    webservices/sandesha/trunk/c/config/module.xml
    webservices/sandesha/trunk/c/include/sandesha2_constants.h
    webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c
    webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c

Modified: webservices/sandesha/trunk/c/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/Makefile.am?view=diff&rev=477506&r1=477505&r2=477506
==============================================================================
--- webservices/sandesha/trunk/c/Makefile.am (original)
+++ webservices/sandesha/trunk/c/Makefile.am Mon Nov 20 21:11:39 2006
@@ -1,4 +1,6 @@
 datadir=$(prefix)/sandesha2
 SUBDIRS = src
-data_DATA = LICENSE config/module.xml src/client/sandesha2_client_constants.h
+data_DATA = LICENSE config/module.xml \
+			src/client/sandesha2_client_constants.h \
+			include/sandesha2_constants.h
 

Modified: webservices/sandesha/trunk/c/config/module.xml
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/config/module.xml?view=diff&rev=477506&r1=477505&r2=477506
==============================================================================
--- webservices/sandesha/trunk/c/config/module.xml (original)
+++ webservices/sandesha/trunk/c/config/module.xml Mon Nov 20 21:11:39 2006
@@ -45,12 +45,14 @@
         <actionMapping>http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</actionMapping>
         <actionMapping>http://schemas.xmlsoap.org/ws/2005/02/rm/SequenceAcknowledgement</actionMapping>
         <actionMapping>http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</actionMapping>
+        <actionMapping>http://schemas.xmlsoap.org/ws/2005/02/rm/AckRequested</actionMapping>
+        <actionMapping>http://schemas.xmlsoap.org/ws/2005/02/rm/LastMessage</actionMapping>
 
-        <!-- namespaces for the 2005-10 spec -->
+        <!-- namespaces for the 2006-08 spec -->
         
-        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200602/SequenceAcknowledgement</actionMapping>
-        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequenceResponse</actionMapping>
-        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200602/AckRequested</actionMapping>
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/SequenceAcknowledgement</actionMapping>
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/CreateSequenceResponse</actionMapping>
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/AckRequested</actionMapping>
      </operation>
  
      <operation name="RMInOutOperation" mep="http://www.w3.org/2004/08/wsdl/in-out">
@@ -60,12 +62,13 @@
         <!-- namespaces for the 2005-02 spec -->
         <actionMapping>http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</actionMapping>
 
-        <!-- namespaces for the 2005-10 spec -->
-        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequence</actionMapping>
-        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequence</actionMapping>
-        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200602/CloseSequence</actionMapping>
-        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequenceResponse</actionMapping>
-        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200602/CloseSequenceResponse</actionMapping>
+        <!-- namespaces for the 2006-08 spec -->
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/CreateSequence</actionMapping>
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/TerminateSequence</actionMapping>
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/CloseSequence</actionMapping>
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/TerminateSequenceResponse</actionMapping>
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/CloseSequenceResponse</actionMapping>
+        <actionMapping>http://docs.oasis-open.org/ws-rx/wsrm/200608/MakeConnection</actionMapping>
 
     </operation>
 

Modified: webservices/sandesha/trunk/c/include/sandesha2_constants.h
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/include/sandesha2_constants.h?view=diff&rev=477506&r1=477505&r2=477506
==============================================================================
--- webservices/sandesha/trunk/c/include/sandesha2_constants.h (original)
+++ webservices/sandesha/trunk/c/include/sandesha2_constants.h Mon Nov 20 21:11:39 2006
@@ -58,38 +58,38 @@
 	 * Spec 2005-10
 	 */
 			
-	#define SANDESHA2_SPEC_2006_08_NS_URI  "http://docs.oasis-open.org/ws-rx/wsrm/200602"
+	#define SANDESHA2_SPEC_2006_08_NS_URI  "http://docs.oasis-open.org/ws-rx/wsrm/200608"
 		
-	#define SANDESHA2_SPEC_2006_08_ACTION_CREATE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequence"
+	#define SANDESHA2_SPEC_2006_08_ACTION_CREATE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200608/CreateSequence"
 
-	#define SANDESHA2_SPEC_2006_08_ACTION_CREATE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequenceResponse"
+	#define SANDESHA2_SPEC_2006_08_ACTION_CREATE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200608/CreateSequenceResponse"
 
-	#define SANDESHA2_SPEC_2006_08_ACTION_SEQ_ACKNOWLEDGEMENT  "http://docs.oasis-open.org/ws-rx/wsrm/200602/SequenceAcknowledgement"
+	#define SANDESHA2_SPEC_2006_08_ACTION_SEQ_ACKNOWLEDGEMENT  "http://docs.oasis-open.org/ws-rx/wsrm/200608/SequenceAcknowledgement"
 
-	#define SANDESHA2_SPEC_2006_08_ACTION_TERMINATE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequence"
+	#define SANDESHA2_SPEC_2006_08_ACTION_TERMINATE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200608/TerminateSequence"
 			
-	#define SANDESHA2_SPEC_2006_08_ACTION_TERMINATE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequenceResponse"
+	#define SANDESHA2_SPEC_2006_08_ACTION_TERMINATE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200608/TerminateSequenceResponse"
 			
-	#define SANDESHA2_SPEC_2006_08_ACTION_ACK_REQUEST  "http://docs.oasis-open.org/ws-rx/wsrm/200602/AckRequested"
+	#define SANDESHA2_SPEC_2006_08_ACTION_ACK_REQUEST  "http://docs.oasis-open.org/ws-rx/wsrm/200608/AckRequested"
 			
-	#define SANDESHA2_SPEC_2006_08_ACTION_CLOSE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200602/CloseSequence"
+	#define SANDESHA2_SPEC_2006_08_ACTION_CLOSE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200608/CloseSequence"
 			
-	#define SANDESHA2_SPEC_2006_08_ACTION_CLOSE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200602/CloseSequenceResponse"
+	#define SANDESHA2_SPEC_2006_08_ACTION_CLOSE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200608/CloseSequenceResponse"
 	#define SANDESHA2_SPEC_2006_08_ACTION_MAKE_CONNECTION "http://docs.oasisopen.org/ws-rx/wsrm/200608/MakeConnection"
 
-	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_CREATE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequence"
+	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_CREATE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200608/CreateSequence"
 
-	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_CREATE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200602/CreateSequenceResponse"
+	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_CREATE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200608/CreateSequenceResponse"
 
-	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_SEQ_ACKNOWLEDGEMENT  "http://docs.oasis-open.org/ws-rx/wsrm/200602/SequenceAcknowledgement"
+	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_SEQ_ACKNOWLEDGEMENT  "http://docs.oasis-open.org/ws-rx/wsrm/200608/SequenceAcknowledgement"
 
-	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_TERMINATE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequence"
+	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_TERMINATE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200608/TerminateSequence"
 			
-	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_TERMINATE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200602/TerminateSequenceResponse"
+	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_TERMINATE_SEQ_RESPONSE  "http://docs.oasis-open.org/ws-rx/wsrm/200608/TerminateSequenceResponse"
 			
-	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_ACK_REQUEST  "http://docs.oasis-open.org/ws-rx/wsrm/200602/AckRequested"
+	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_ACK_REQUEST  "http://docs.oasis-open.org/ws-rx/wsrm/200608/AckRequested"
 			
-	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_CLOSE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200602/CloseSequence"
+	#define SANDESHA2_SPEC_2006_08_SOAP_ACTION_CLOSE_SEQ  "http://docs.oasis-open.org/ws-rx/wsrm/200608/CloseSequence"
      
     #define SANDESHA2_SPEC_2006_08_SOAP_ACTION_MAKE_CONNECTION "http://docs.oasis-open.org/ws-rx/wsrm/200608/MakeConnection"
 	/**

Modified: webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c?view=diff&rev=477506&r1=477505&r2=477506
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c (original)
+++ webservices/sandesha/trunk/c/samples/rm_echo/rm_echo_client.c Mon Nov 20 21:11:39 2006
@@ -25,6 +25,7 @@
 #include <axis2_callback_recv.h>
 #include <axis2_svc_client.h>
 #include <sandesha2_client_constants.h>
+#include <sandesha2_constants.h>
 
 /* on_complete callback function */
 axis2_status_t AXIS2_CALL
@@ -80,6 +81,7 @@
     axis2_listener_manager_t *listener_manager = NULL;
     axis2_char_t *offered_seq_id = NULL;
     axis2_bool_t offer = AXIS2_FALSE;
+    int version = 0;
     int c;
    
     /* Set up the environment */
@@ -89,7 +91,7 @@
     /* Set end point reference of echo service */
     /*address = "http://127.0.0.1:8888/axis2/services/RMSampleService";*/
     address = "http://127.0.0.1:5555/axis2/services/RMSampleService";
-    while ((c = AXIS2_GETOPT(argc, argv, ":a:o:")) != -1)
+    while ((c = AXIS2_GETOPT(argc, argv, ":a:o:v:")) != -1)
     {
 
         switch (c)
@@ -97,9 +99,12 @@
             case 'a':
                 address = optarg;
                 break;
-            case 'o':
+            case 'o': /* Sequence Offer */
                 offer = AXIS2_ATOI(optarg);
                 break;
+            case 'v': /* RM Version */
+                version = AXIS2_ATOI(optarg);
+                break;
             case ':':
                 fprintf(stderr, "\nOption -%c requires an operand\n", optopt);
                 usage(argv[0]);
@@ -183,6 +188,18 @@
                 property);
         }
     }
+    /* RM Version 1.1 */
+    if(version == 1)
+    {
+        property = axis2_property_create(env);
+        if(property)
+        {
+            AXIS2_PROPERTY_SET_VALUE(property, env, AXIS2_STRDUP(
+                SANDESHA2_SPEC_VERSION_1_1, env));
+            AXIS2_OPTIONS_SET_PROPERTY(options, env, 
+                SANDESHA2_CLIENT_RM_SPEC_VERSION, property);
+        }
+    }
     payload = build_om_payload_for_echo_svc(env, "echo1", "sequence1");
     callback = axis2_callback_create(env);
     AXIS2_CALLBACK_SET_ON_COMPLETE(callback, rm_echo_callback_on_complete);
@@ -318,7 +335,6 @@
     axis2_op_t *op = NULL;
     axis2_callback_recv_t *callback_recv = NULL;
     const axis2_char_t *transport_in_protocol = NULL;
-    axis2_callback_t *callback_temp = NULL;
 
     if(!op_qname)
         op_qname = axis2_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);
@@ -414,12 +430,15 @@
     axis2_char_t *prog_name)
 {
     fprintf(stdout, "\n Usage : %s", prog_name);
-    fprintf(stdout, " [-o ADDRESS]");
+    fprintf(stdout, " [-a ADDRESS]");
     fprintf(stdout, " [-o OFFER]");
+    fprintf(stdout, " [-v RM VERSION]");
     fprintf(stdout, " Options :\n");
+    fprintf(stdout, "\t-v RM VERSION \t rm version.. The"
+            " default rm version is 1.0 ../\n");
     fprintf(stdout, "\t-o OFFER \t seq offer value.. The"
             " default offer value is 0(false) ../\n");
-    fprintf(stdout, "\t-o ADDRESS \t endpoint address.. The"
+    fprintf(stdout, "\t-a ADDRESS \t endpoint address.. The"
             " default is http://127.0.0.1:5555/axis2/services/RMSampleService ../\n");
     fprintf(stdout, " Help :\n\t-h \t display this help screen.\n\n");
 }

Modified: webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c?view=diff&rev=477506&r1=477505&r2=477506
==============================================================================
--- webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c (original)
+++ webservices/sandesha/trunk/c/src/msgprocessors/app_msg_processor.c Mon Nov 20 21:11:39 2006
@@ -730,7 +730,7 @@
     else
     {
         property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, 
-                        SANDESHA2_CLIENT_RM_SPEC_VERSION, AXIS2_FALSE);
+            SANDESHA2_CLIENT_RM_SPEC_VERSION, AXIS2_FALSE);
         if(property)
             spec_ver = AXIS2_PROPERTY_GET_VALUE(property, env);
     }

Added: webservices/sandesha/trunk/c/src/polling/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/polling/Makefile.am?view=auto&rev=477506
==============================================================================
--- webservices/sandesha/trunk/c/src/polling/Makefile.am (added)
+++ webservices/sandesha/trunk/c/src/polling/Makefile.am Mon Nov 20 21:11:39 2006
@@ -0,0 +1,7 @@
+noinst_LTLIBRARIES = libsandesha2_polling.la
+
+libsandesha2_polling_la_SOURCES = polling_mgr.c
+
+INCLUDES = -I$(top_builddir)/include \
+            @AXIS2INC@
+

Added: webservices/sandesha/trunk/c/src/polling/polling_mgr.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/polling/polling_mgr.c?view=auto&rev=477506
==============================================================================
--- webservices/sandesha/trunk/c/src/polling/polling_mgr.c (added)
+++ webservices/sandesha/trunk/c/src/polling/polling_mgr.c Mon Nov 20 21:11:39 2006
@@ -0,0 +1,401 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <sandesha2_polling_mgr.h>
+#include <sandesha2_constants.h>
+#include <sandesha2_utils.h>
+#include <sandesha2_transaction.h>
+#include <sandesha2_storage_mgr.h>
+#include <sandesha2_terminate_mgr.h>
+#include <sandesha2_seq_property_bean.h>
+#include <sandesha2_seq_property_mgr.h>
+#include <sandesha2_msg_ctx.h>
+#include <sandesha2_seq.h>
+#include <sandesha2_msg_init.h>
+#include <sandesha2_msg_creator.h>
+#include <axis2_addr.h>
+#include <axis2_engine.h>
+#include <axis2_uuid_gen.h>
+#include <stdio.h>
+#include <platforms/axis2_platform_auto_sense.h>
+
+
+/** 
+ * @brief Polling Manager struct impl
+ *	Sandesha2 Polling Manager
+ */
+typedef struct sandesha2_polling_mgr_args sandesha2_polling_mgr_args_t;
+#define SANDESHA2_POLLING_MANAGER_WAIT_TIME 5000
+
+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.
+     */
+    axis2_array_list_t *scheduled_polling_reqs;
+    axis2_bool_t poll;
+    axis2_thread_mutex_t *mutex;
+};
+
+struct sandesha2_polling_mgr_args
+{
+    sandesha2_polling_mgr_t *impl;
+    axis2_env_t *env;
+    sandesha2_storage_mgr_t *storage_mgr;
+};
+            
+static axis2_status_t AXIS2_CALL 
+sandesha2_polling_mgr_run (
+    sandesha2_polling_mgr_t *polling_mgr,
+    const axis2_env_t *env,
+    sandesha2_storage_mgr_t *storage_mgr);
+
+/**
+ * Thread worker function.
+ */
+static void * AXIS2_THREAD_FUNC
+sandesha2_polling_mgr_worker_func(
+    axis2_thread_t *thd, 
+    void *data);
+
+AXIS2_EXTERN sandesha2_polling_mgr_t* AXIS2_CALL
+sandesha2_polling_mgr_create(
+    const axis2_env_t *env)
+{
+    sandesha2_polling_mgr_t *polling_mgr = NULL;
+    AXIS2_ENV_CHECK(env, 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 = axis2_thread_mutex_create(env->allocator,
+        AXIS2_THREAD_MUTEX_DEFAULT);
+                        
+	return polling_mgr;
+}
+
+axis2_status_t AXIS2_CALL
+sandesha2_polling_mgr_free_void_arg(
+    void *polling_mgr,
+    const axis2_env_t *env)
+{
+    sandesha2_polling_mgr_t *polling_mgr_l = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+    polling_mgr_l = (sandesha2_polling_mgr_t *) polling_mgr;
+    return sandesha2_polling_mgr_free(polling_mgr_l, env);
+}
+
+axis2_status_t AXIS2_CALL 
+sandesha2_polling_mgr_free(
+    sandesha2_polling_mgr_t *polling_mgr, 
+    const axis2_env_t *env)
+{
+	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    /* Do not free this */
+    polling_mgr->conf_ctx = NULL;
+    
+    if(polling_mgr->mutex)
+    {
+        axis2_thread_mutex_destroy(polling_mgr->mutex);
+        polling_mgr->mutex = NULL;
+    }
+    if(polling_mgr->scheduled_polling_reqs)
+    {
+        AXIS2_ARRAY_LIST_FREE(polling_mgr->scheduled_polling_reqs, env);
+        polling_mgr->scheduled_polling_reqs = NULL;
+    }
+	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 axis2_env_t *env)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    
+    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 axis2_env_t *env, 
+    axis2_conf_ctx_t *conf_ctx)
+{
+    sandesha2_storage_mgr_t *storage_mgr = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
+    
+    polling_mgr->conf_ctx = conf_ctx;
+    polling_mgr->scheduled_polling_reqs = axis2_array_list_create(env, 
+        AXIS2_ARRAY_LIST_DEFAULT_CAPACITY);
+
+    if(!polling_mgr->conf_ctx || !polling_mgr->conf_ctx->ops)
+        return AXIS2_FAILURE;
+    storage_mgr = sandesha2_utils_get_storage_mgr(env, 
+        polling_mgr->conf_ctx, 
+        AXIS2_CONF_CTX_GET_CONF(polling_mgr->conf_ctx, env));
+    set_poll(AXIS2_TRUE);
+    sandesha2_polling_mgr_run(polling_mgr, env, storage_mgr);
+    return AXIS2_SUCCESS;
+}
+            
+static axis2_status_t AXIS2_CALL 
+sandesha2_polling_mgr_run (
+    sandesha2_polling_mgr_t *polling_mgr,
+    const axis2_env_t *env,
+    sandesha2_storage_mgr_t *storage_mgr)
+{
+    axis2_thread_t *worker_thread = NULL;
+    sandesha2_polling_mgr_args_t *args = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    
+    args = AXIS2_MALLOC(env->allocator, sizeof(
+                        sandesha2_polling_mgr_args_t)); 
+    args->impl = polling_mgr;
+    args->env = (axis2_env_t*)env;
+    args->storage_mgr = storage_mgr;
+    worker_thread = AXIS2_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");
+        return AXIS2_FAILURE;
+    }
+    AXIS2_THREAD_POOL_THREAD_DETACH(env->thread_pool, worker_thread); 
+        
+    return AXIS2_SUCCESS;
+}
+
+/**
+ * Thread worker function.
+ */
+static void * AXIS2_THREAD_FUNC
+sandesha2_polling_mgr_worker_func(
+    axis2_thread_t *thd, 
+    void *data)
+{
+    sandesha2_polling_mgr_t *polling_mgr = NULL;
+    sandesha2_polling_mgr_args_t *args;
+    sandesha2_storage_mgr_t *storage_mgr;
+    axis2_env_t *env = NULL;
+    
+    args = (sandesha2_polling_mgr_args_t*)data;
+    env = args->env;
+    polling_mgr = args->impl;
+    storage_mgr = args->storage_mgr;
+
+    while(sandesha2_polling_mgr_is_poll(polling_mgr, env))
+    {
+        sandesha2_storage_mgr_t *storage_mgr = NULL;
+        sandesha2_next_msg_mgr_t *next_msg_mgr = NULL;
+        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;
+        sandesha2_sender_mgr_t *sender_bean_mgr = NULL;
+        int size = 0;
+        axis2_char_t *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;
+        axis2_property_t *property = NULL;
+
+        AXIS2_SLEEP(SANDESHA2_POLLING_MANAGER_WAIT_TIME);
+        next_msg_mgr = sandesha2_storage_mgr_get_next_msg_mgr(
+                        storage_mgr, env);
+         /* Geting 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 = AXIS2_ARRAY_LIST_SIZE(polling_mgr->scheduled_polling_reqs, 
+                env);
+        if(size > 0)
+        {
+            seq_id = AXIS2_ARRAY_LIST_GET(polling_mgr->scheduled_polling_reqs, 
+                env, 0);
+            AXIS2_ARRAY_LIST_REMOVE(polling_mgr->scheduled_polling_reqs, env, 0);
+        }
+        if(!seq_id)
+        {
+            sandesha2_next_msg_bean_t *find_bean = 
+                sandesha2_next_msg_bean_create(env);
+            int size = 0;
+            if(find_bean)
+            {
+                axis2_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 = AXIS2_ARRAY_LIST_SIZE(results, env);
+                if(size > 0)
+                {
+                    unsigned int rand_var = 
+                        axis2_rand_get_seed_value_based_on_time(env);
+                    int item = axis2_rand_with_range(&rand_var, 1, size);
+                    next_msg_bean = (sandesha2_next_msg_bean_t *) 
+                        AXIS2_ARRAY_LIST_GET(results, env, item);
+                }
+
+            }
+        }
+        else
+        {
+            sandesha2_next_msg_bean_t *find_bean = 
+                sandesha2_next_msg_bean_create(env);
+            if(find_bean)
+            {
+                sandesha2_next_msg_bean_set_polling_mode(find_bean, env, 
+                    AXIS2_TRUE);
+                sandesha2_next_msg_bean_set_seq_id(find_bean, env, seq_id);
+                next_msg_bean = sandesha2_next_msg_mgr_find_unique(next_msg_mgr,
+                    env, find_bean);
+            }
+        }
+        /* If no valid entry is found, try again later */
+        if(!next_msg_bean)
+            continue;
+        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 = seq_id;
+        reply_to = sandesha2_utils_get_seq_property(env, seq_prop_key, 
+            SANDESHA2_SEQ_PROP_REPLY_TO_EPR, storage_mgr);
+        if(sandesha2_util_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);
+        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, seq_id, wsrm_anon_reply_to_uri, storage_mgr);
+        if(!make_conn_rm_msg_ctx)
+        {
+            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+            return NULL;
+        }
+        sandesha2_msg_ctx_set_property(make_conn_rm_msg_ctx, env, 
+            AXIS2_TRANSPORT_IN, NULL);
+        /* Storing the MakeConnection message */
+        make_conn_msg_store_key = axis2_uuid_gen(env);
+        property = axis2_property_create(env);
+        AXIS2_PROPERTY_SET_VALUE(property, env, AXIS2_STRDUP(seq_prop_key, env));
+        AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_SESSION);
+        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)
+        {
+            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);
+            to = sandesha2_msg_ctx_get_to(make_conn_rm_msg_ctx, env);
+            if(!to)
+            {
+                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);
+            }
+        }
+        sender_bean_mgr = sandesha2_storage_mgr_get_retrans_mgr(storage_mgr, 
+            env);
+        /* This message should not be sent untils it is qualified. i.e. Till
+         * it is sent through the sandesha2_transport_sender
+         */
+        property = axis2_property_create(env);
+        AXIS2_PROPERTY_SET_VALUE(property, env, 
+            AXIS2_STRDUP(SANDESHA2_VALUE_FALSE, env));
+        AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_SESSION);
+        sandesha2_msg_ctx_set_property(make_conn_rm_msg_ctx, env, 
+            SANDESHA2_QUALIFIED_FOR_SENDING, property);
+        if(sender_bean_mgr)
+            sandesha2_sender_mgr_insert(sender_bean_mgr, env, 
+                make_conn_sender_bean);
+        sandesha2_util_execute_and_store(env, make_conn_rm_msg_ctx, 
+            make_conn_msg_store_key);
+    }
+    return NULL;
+}
+
+void AXIS2_CALL
+sandesha2_polling_mgr_set_poll(
+    sandesha2_polling_mgr_t *polling_mgr,
+    const axis2_env_t *env,
+    axis2_bool_t poll)
+{
+    polling_mgr->poll = poll;
+}
+
+axis2_bool_t AXIS2_CALL
+sandesha2_polling_mgr_is_poll(
+    sandesha2_polling_mgr_t *polling_mgr,
+    const axis2_env_t *env)
+{
+    return polling_mgr->poll;
+}
+
+void AXIS2_CALL
+sandesha2_polling_mgr_schedule_polling_request(
+    sandesha2_polling_mgr_t *polling_mgr,
+    const axis2_env_t *env,
+    axis2_char_t *internal_seq_id)
+{
+    if(AXIS2_ARRAY_LIST_CONTAINS(polling_mgr->scheduled_polling_reqs, env, 
+        internal_seq_id))
+    {
+        AXIS2_ARRAY_LIST_ADD(polling_mgr->scheduled_polling_reqs, env, 
+            internal_seq_id);
+    }
+}
+



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