[rabbitmq-discuss] In RabbitMQ-C Getting AMQP_CHANNEL_CLOSE_METHOD without closing channel

pawanksingh pawansingh68 at gmail.com
Mon Jun 3 07:43:55 BST 2013


I am Getting AMQP_CHANNEL_CLOSE_METHOD without closing any channel.
Because of this prob i have to run my program again and again for sending
and receiving msg.
Can anybody help me on this issue.
this is receiving and publishing code
while (1)
	{
		conn=Get_Server_Connection(index+MAX_CLIENTS);
		printf("\n__INDEX__%d CTM to client Entering while ........\n", index);
		amqp_maybe_release_buffers(conn);
		result = amqp_simple_wait_frame(conn, &frame);
		HU_ENABLE_DEBUG_INFO_PRINTS(("Result %d\n", result));
		if (result < 0)
		break;

		printf("__INDEX__%d CTM to client Frame type %d, channel %d\n", index,
frame.frame_type, frame.channel);
		if (frame.frame_type != AMQP_FRAME_METHOD)
		continue;

		printf("__INDEX__%d CTM to client Method %s\n", index,
amqp_method_name(frame.payload.method.id));
		if (frame.payload.method.id != AMQP_BASIC_DELIVER_METHOD)
		continue;

		d = (amqp_basic_deliver_t *) frame.payload.method.decoded;

		printf("__INDEX__%d CTM to client Delivery %u, exchange %.*s routingkey
%.*s\n",index,
		(unsigned) d->delivery_tag,
		(int) d->exchange.len, (char *) d->exchange.bytes,
		(int) d->routing_key.len, (char *) d->routing_key.bytes);

		result = amqp_simple_wait_frame(conn, &frame);
		if (result < 0)
		break;

		if (frame.frame_type != AMQP_FRAME_HEADER)
		{
			fprintf(stderr, "Expected header!");
			abort();
		}

		p = (amqp_basic_properties_t *) frame.payload.properties.decoded;
		if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG)
		{
			printf("__INDEX__%d Content-type: %.*s\n", index,(int)
p->content_type.len, (char *) p->content_type.bytes);
		}
		HU_ENABLE_DEBUG_INFO_PRINTS(("----\n"));

		body_target = frame.payload.properties.body_size;
		body_received = 0;

		msg.bytes=calloc(((frame.payload.properties.body_size)+1),1);
		msg.len=frame.payload.properties.body_size;
		while (body_received < body_target)
		{
			result = amqp_simple_wait_frame(conn, &frame);
			if (result < 0)
			break;

			if (frame.frame_type != AMQP_FRAME_BODY)
			{
				fprintf(stderr, "Expected body!");
				abort();
			}

			body_received += frame.payload.body_fragment.len;
			assert(body_received <= body_target);

		
strncat(msg.bytes,frame.payload.body_fragment.bytes,frame.payload.body_fragment.len);


		}

		if (body_received != body_target)
		{
			/* Can only happen when amqp_simple_wait_frame returns <= 0 */
			/* We break here to close the connection */
			break;
		}
		else
		{
			char *p;
			int Message_Type;
			printf("pawanread1\n");
			printf("routing=%s\n",(char *) d->routing_key.bytes);
			p = strtok (((char *) d->routing_key.bytes),"_");
			printf("pawanread2\n");
			p=strtok (NULL,"_");
			printf("pawanread3\n");
//			amqp_basic_ack(conn,
Client_Connect[index].Queue_Info[Message_Type].listner_channel,
d->delivery_tag, 0);// giving acknowledgment for consumer
			p=strtok (NULL,"_");
			printf("pawanread4\n");
			p=strtok (NULL,"_");
			printf("pawanread5\n");
			Message_Type=atoi(p);
			printf("CTM to client Message_Type=%d\n",Message_Type);

			{
				printf("CTM to client index=%d response=%d exchange=%s
routing=%s\n",index,Client_Connect[index].Queue_Info[Message_Type].response_channel,Client_Connect[index].exchange,Client_Connect[index].Queue_Info[Message_Type].routingkey);
				amqp_basic_properties_t props;
				props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG |
AMQP_BASIC_DELIVERY_MODE_FLAG;
				props.content_type = amqp_cstring_bytes("text/plain");
				props.delivery_mode = 2; // persistent delivery mode

				die_on_error(amqp_basic_publish(conn,
											Client_Connect[index].Queue_Info[Message_Type].response_channel,
											amqp_cstring_bytes(Client_Connect[index].exchange),
										
amqp_cstring_bytes(Client_Connect[index].Queue_Info[Message_Type].routingkey),
											1,
											0,
											&props,
											msg),
											"Publishing to Client");
			}
			amqp_basic_ack(conn, frame.channel, d->delivery_tag, 0);
			free(msg.bytes);

		}

	}/*End while*/



--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/In-RabbitMQ-C-Getting-AMQP-CHANNEL-CLOSE-METHOD-without-closing-channel-tp27158.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list