Good news: the basic.return actually comes back with full headers and
body, as well as the return frame itself. So if you make sure that all
outgoing messages are uniquely identifiable -- adding a field to the
user-defined headers can do this, as for example my "sender" and "line"
entries -- we should be able to do this right. I want to integrate it
with support for basic.ack. Seems like it could be as simple as
extending the possible parameters of on_failure callback.
For example, here's a quote from a dumped return message, printed with
->verbose.
Unfortunately if you try to send to a nonexistent exchange Rabbit just
closes your connection and makes you start over. Impolite. But if the
exchange exists, you get the below. Also unfortunately, it seems that
the Return frame does NOT include the message_id you used when sending.
Which is silly.
EV: error in callback (ignoring): {
body => bless( {
channel => 1,
payload => "hello",
type_id => 3
}, 'Net::AMQP::Frame::Body' ),
header => bless( {
content_type => "application/octet-stream",
delivery_mode => 2,
headers => {
line => 1,
sender => "feed_xxx_3393"
},
priority => 1,
timestamp => "1347152061",
user_id => "guest"
}, 'Net::AMQP::Protocol::Basic::ContentHeader' ),
return => bless( {
channel => 1,
method_frame => bless( {
exchange => "nowhere",
reply_code => 312,
reply_text => "NO_ROUTE",
routing_key => "mand1"
}, 'Net::AMQP::Protocol::Basic::Return' ),
payload => "",
type_id => 1
}, 'Net::AMQP::Frame::Method' )
}
at lib/AnyEvent/RabbitMQ/Channel.pm line 665.