[rabbitmq-discuss] Publish to exchange that doesn't bind to any queue in trunsaction mode
Haster
haster2004 at yandex.ru
Mon Jul 1 15:10:19 BST 2013
All magic is in function GetMethodOnChannel that is called from BasicPublish:
void Channel::BasicPublish(const std::string& exchange_name,
const std::string& routing_key,
const BasicMessage::ptr_t message,
bool mandatory,
bool immediate)
{
m_impl->CheckIsConnected();
amqp_channel_t channel = m_impl->GetChannel();
m_impl->CheckForError(amqp_basic_publish(m_impl->m_connection, channel,
amqp_cstring_bytes(exchange_name.c_str()),
amqp_cstring_bytes(routing_key.c_str()),
mandatory,
immediate,
message->getAmqpProperties(),
message->getAmqpBody()));
// If we've done things correctly we can get one of 4 things back from the
broker
// - basic.ack - our channel is in confirm mode, messsage was 'dealt with'
by the broker
// - basic.return then basic.ack - the message wasn't delievered, but was
dealt with
// - channel.close - probably tried to publish to a non-existant exchange,
in any case error!
// - connection.clsoe - something really bad happened
const boost::array<boost::uint32_t, 2> PUBLISH_ACK = { {
AMQP_BASIC_ACK_METHOD, AMQP_BASIC_RETURN_METHOD } };
amqp_frame_t response;
m_impl->GetMethodOnChannel(channel, response, PUBLISH_ACK);
if (AMQP_BASIC_RETURN_METHOD == response.payload.method.id)
{
MessageReturnedException message_returned =
m_impl->CreateMessageReturnedException(*(reinterpret_cast<amqp_basic_return_t*>(response.payload.method.decoded)),
channel);
const boost::array<boost::uint32_t, 1> BASIC_ACK = { {
AMQP_BASIC_ACK_METHOD } };
m_impl->GetMethodOnChannel(channel, response, BASIC_ACK);
m_impl->ReturnChannel(channel);
m_impl->MaybeReleaseBuffers();
throw message_returned;
}
m_impl->ReturnChannel(channel);
m_impl->MaybeReleaseBuffers();
}
I will try to understand, thanks a lot !!!
--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/Publish-to-exchange-that-doesn-t-bind-to-any-queue-in-trunsaction-mode-tp27706p27720.html
Sent from the RabbitMQ mailing list archive at Nabble.com.
More information about the rabbitmq-discuss
mailing list