AXIS2_EXTERN int AXIS2_CALL axis2_amqp_util_msg_ctx_get_request_timeout( axis2_msg_ctx_t* msg_ctx, const axutil_env_t* env) { axis2_conf_ctx_t* conf_ctx = NULL; axutil_property_t* property = NULL; void* value = NULL; int request_timeout = AXIS2_QPID_DEFAULT_REQUEST_TIMEOUT; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(conf_ctx) { property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_REQUEST_TIMEOUT); if(property) { value = axutil_property_get_value(property, env); if(value) { request_timeout = *(int*)value; } } } return request_timeout; }
void AXIS2_CALL service_admin_counter_set_last_count ( const axutil_env_t *env, axis2_msg_ctx_t *msg_ctx, axis2_char_t *svc_name, axis2_char_t *op_name, int last_count) { int *count = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axutil_property_t *property = NULL; axutil_hash_t *last_counts = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(svc_name && op_name) { axis2_char_t *key = NULL; key = axutil_strcat(env, svc_name, "-", op_name, NULL); property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_OPERATION_COUNT); /* set_last_count is always called after get_last_count. So checking for existence of property * is not necessary here */ last_counts = axutil_property_get_value(property, env); count = axutil_hash_get(last_counts, key, AXIS2_HASH_KEY_STRING); *count = last_count; AXIS2_FREE(env->allocator, key); } else if(svc_name) { property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_SERVICE_COUNT); /* set_last_count is always called after get_last_count. So checking for existence of property * is not necessary here */ last_counts = axutil_property_get_value(property, env); count = axutil_hash_get(last_counts, svc_name, AXIS2_HASH_KEY_STRING); *count = last_count; } }
AXIS2_EXTERN axis2_char_t* AXIS2_CALL axis2_amqp_util_conf_ctx_get_dual_channel_queue_name( axis2_conf_ctx_t* conf_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; axis2_char_t* queue_name = NULL; axis2_char_t* value = NULL; /* Get property */ property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME); if(!property) /* Very first call */ { property = axutil_property_create(env); axis2_conf_ctx_set_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME, property); } /* Get queue name */ value = (axis2_char_t*)axutil_property_get_value(property, env); /* AMQP listener and the sender are the two parties that are * interested in the queue. Either party can create the queue. * If the queue is already created by one party, "value" is * not NULL. If "value" is NULL, that mean the caller of * this method is supposed to create the queue */ if(value) { queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, axutil_strlen(value) + 1); strcpy(queue_name, value); /*axutil_property_set_value(property, env, NULL);*/ } else { /* Create new queue name */ queue_name = axutil_stracat(env, AXIS2_AMQP_TEMP_QUEUE_NAME_PREFIX, axutil_uuid_gen(env)); /* Put queue name in the conf_ctx so that the sender will know */ axutil_property_set_value(property, env, (void*)queue_name); } return queue_name; }
AXIS2_EXTERN axis2_bool_t AXIS2_CALL axis2_amqp_util_conf_ctx_get_server_side( axis2_conf_ctx_t* conf_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; axis2_char_t* value = NULL; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_IS_SVR_SIDE); if(!property) return AXIS2_TRUE; value = (axis2_char_t*)axutil_property_get_value(property, env); if(!value) return AXIS2_TRUE; return (axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0) ? AXIS2_TRUE : AXIS2_FALSE; }
AXIS2_EXTERN int AXIS2_CALL axis2_amqp_util_conf_ctx_get_qpid_broker_port( axis2_conf_ctx_t* conf_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; void* value = NULL; int broker_port = AXIS2_QPID_DEFAULT_BROKER_PORT; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT); if(property) { value = axutil_property_get_value(property, env); if(value) { broker_port = *(int*)value; } } return broker_port; }
AXIS2_EXTERN axis2_char_t* AXIS2_CALL axis2_amqp_util_conf_ctx_get_qpid_broker_ip( axis2_conf_ctx_t* conf_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; void* value = NULL; axis2_char_t* broker_ip = AXIS2_QPID_DEFAULT_BROKER_IP; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP); if(property) { value = axutil_property_get_value(property, env); if(value) { broker_ip = (axis2_char_t*)value; } } return broker_ip; }
AXIS2_EXTERN axis2_amqp_destination_info_t* AXIS2_CALL axis2_amqp_util_msg_ctx_get_destination_info( axis2_msg_ctx_t* msg_ctx, const axutil_env_t* env) { /* The destination URI that is expected by this method * should be of one of the following formats * 1. amqp://IP:PORT/services/SERVICE_NAME * 2. jms:/SERVICE_NAME?java.naming.provider.url=tcp://IP:PORT... * 3. TempQueue... */ axis2_endpoint_ref_t* endpoint_ref = NULL; axis2_amqp_destination_info_t* destination_info = NULL; destination_info = (axis2_amqp_destination_info_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_amqp_destination_info_t)); destination_info->broker_ip = NULL; destination_info->broker_port = AXIS2_QPID_NULL_CONF_INT; destination_info->queue_name = NULL; endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env); if(endpoint_ref) { const axis2_char_t* endpoint_address_original = NULL; axis2_char_t* endpoint_address = NULL; char* substr = NULL; char* token = NULL; endpoint_address_original = axis2_endpoint_ref_get_address(endpoint_ref, env); if(!endpoint_address_original) return NULL; endpoint_address = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * axutil_strlen(endpoint_address_original)) + 1); strcpy((char*)endpoint_address, (char*)endpoint_address_original); if((substr = strstr(endpoint_address, AXIS2_AMQP_EPR_PREFIX))) /* Start with amqp: */ { if(strstr(endpoint_address, AXIS2_AMQP_EPR_ANON_SERVICE_NAME)) { /* Server reply to dual-channel client */ axutil_property_t* property = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO); if(property) { axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env); if(queue_name) { destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(queue_name)) + 1); strcpy(destination_info->queue_name, queue_name); } } } else { substr += strlen(AXIS2_AMQP_EPR_PREFIX) + 2; /* 2 -> "//" */ if(substr) /* IP:PORT/services/SERVICE_NAME */ { token = strtok(substr, ":"); if(token) /* IP */ { axis2_char_t* broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(token)) + 1); strcpy(broker_ip, token); destination_info->broker_ip = broker_ip; token = strtok(NULL, "/"); /* PORT */ if(token) { destination_info->broker_port = atoi(token); token = strtok(NULL, "#"); /* ... services/SERVICE_NAME */ if(token) { if((substr = strstr(token, AXIS2_AMQP_EPR_SERVICE_PREFIX))) { substr += strlen(AXIS2_AMQP_EPR_SERVICE_PREFIX) + 1; /* 1 -> "/" */ if(substr) { axis2_char_t* queue_name = (axis2_char_t*)AXIS2_MALLOC( env->allocator, (sizeof(axis2_char_t) * strlen(substr)) + 1); strcpy(queue_name, substr); destination_info->queue_name = queue_name; } } } } } } } } else if(0 == strcmp(endpoint_address, AXIS2_WSA_ANONYMOUS_URL)) /* Required to work with Sandesha2 */ { axutil_property_t* property = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO); if(property) { axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env); if(queue_name) { destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(queue_name)) + 1); strcpy(destination_info->queue_name, queue_name); } } } else if((substr = strstr(endpoint_address, "jms:/")) && (substr == endpoint_address)) { } AXIS2_FREE(env->allocator, endpoint_address); } else { /* Single-channel blocking */ axutil_property_t* property = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO); if(property) { axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env); if(queue_name) { destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(queue_name)) + 1); strcpy(destination_info->queue_name, queue_name); } } } /* Get broker IP/Port from conf_ctx if they are not * found in the destination URI */ if(!destination_info->broker_ip) { axis2_conf_ctx_t* conf_ctx = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(conf_ctx) { axutil_property_t* property = NULL; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP); if(property) { axis2_char_t* broker_ip = (axis2_char_t*)axutil_property_get_value(property, env); if(broker_ip) { destination_info->broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(broker_ip)) + 1); strcpy(destination_info->broker_ip, broker_ip); } } } } if(AXIS2_QPID_NULL_CONF_INT == destination_info->broker_port) { axis2_conf_ctx_t* conf_ctx = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(conf_ctx) { axutil_property_t* property = NULL; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT); if(property) { void* value = axutil_property_get_value(property, env); if(value) { destination_info->broker_port = *(int*)value; } } } } return destination_info; }
int AXIS2_CALL service_admin_counter_get_last_count ( const axutil_env_t *env, axis2_msg_ctx_t *msg_ctx, axis2_char_t *svc_name, axis2_char_t *op_name) { int *count = NULL; axutil_hash_t *last_counts = NULL; axutil_property_t *property = NULL; axis2_conf_ctx_t *conf_ctx = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(svc_name && op_name) { axis2_char_t *key = NULL; key = axutil_strcat(env, svc_name, "-", op_name, NULL); property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_OPERATION_COUNT); if(!property) { last_counts = axutil_hash_make(env); property = axutil_property_create_with_args(env, AXIS2_TRUE, AXIS2_SCOPE_APPLICATION, service_admin_counter_last_counts_free_void_arg, last_counts); axis2_conf_ctx_set_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_OPERATION_COUNT, property); } else { last_counts = axutil_property_get_value(property, env); } count = axutil_hash_get(last_counts, key, AXIS2_HASH_KEY_STRING); if(count) { AXIS2_FREE(env->allocator, key); } else { count = AXIS2_MALLOC(env->allocator, sizeof(int)); *count = 0; axutil_hash_set(last_counts, key, AXIS2_HASH_KEY_STRING, count); } } else if(svc_name) { property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_SERVICE_COUNT); if(!property) { last_counts = axutil_hash_make(env); property = axutil_property_create_with_args(env, AXIS2_TRUE, AXIS2_SCOPE_APPLICATION, service_admin_counter_last_counts_free_void_arg, last_counts); axis2_conf_ctx_set_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_SERVICE_COUNT, property); } else { last_counts = axutil_property_get_value(property, env); } count = axutil_hash_get(last_counts, svc_name, AXIS2_HASH_KEY_STRING); if(!count) { count = AXIS2_MALLOC(env->allocator, sizeof(int)); *count = 0; axutil_hash_set(last_counts, axutil_strdup(env, svc_name) , AXIS2_HASH_KEY_STRING, count); } } return *count; }