Hi, i was rewrite the example amqp_rpc_sendstring_client to use direct reply-to with this code:
{
/*
set properties
*/
reply_to_queue = amqp_cstring_bytes("amq.rabbitmq.reply-to");
amqp_basic_properties_t props;
props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG |
AMQP_BASIC_DELIVERY_MODE_FLAG |
AMQP_BASIC_REPLY_TO_FLAG |
AMQP_BASIC_CORRELATION_ID_FLAG;
props.content_type = amqp_cstring_bytes("text/plain");
props.delivery_mode = 2; /* persistent delivery mode */
props.reply_to = amqp_bytes_malloc_dup(reply_to_queue);
if (props.reply_to.bytes == NULL) {
fprintf(stderr, "Out of memory while copying queue name");
return 1;
}
props.correlation_id = amqp_cstring_bytes("1");
/*
publish
*/
die_on_error(amqp_basic_publish(conn,
1,
amqp_cstring_bytes(exchange),
amqp_cstring_bytes(routingkey),
1,
0,
&props,
amqp_cstring_bytes(messagebody)),
"Publishing");
amqp_bytes_free(props.reply_to);
}
but when i run the new amqp_rpc_sendstring_client on my rabbitmq-server 3.6.10, it report error:
Consuming: server channel error 406h, message: PRECONDITION_FAILED - fast reply consumer does not exist
You need to setup a consumer using amqp_basic_consume on the amq.rabbitmq.reply-to queue before attempting to publish the message.
thanks for your reply!
and yes, i was using amqp_basic_consume on the amq.rabbitmq.reply-to queue. but it aways report the PRECONDITION_FAILED error. am i miss sth.?
OH, you mean use amqp_basic_consume before pulish
THANK YOU!
Hi jiangrzh,
Can you please share psuedo code for direct reply to client-server here.
I have tried only one way communication is happening, not getting the reply.
If required I will share my sample code which I have rewrite.
Thanks,
Most helpful comment
You need to setup a consumer using
amqp_basic_consumeon theamq.rabbitmq.reply-toqueue before attempting to publish the message.See: https://www.rabbitmq.com/direct-reply-to.html