diff options
author | Paul Jones <paulj@lshift.net> | 2009-08-06 11:59:01 +0100 |
---|---|---|
committer | Paul Jones <paulj@lshift.net> | 2009-08-06 11:59:01 +0100 |
commit | 13c4d8f8cea8635110d36f459c422a2ab04554bf (patch) | |
tree | 69d7c46e34ee8b6f92e209555e351d18540646ce | |
parent | 346824f5626614779a3093e57528e68437d3dbae (diff) | |
parent | ee06e07f561ef2760a3d97b7592b11a54cfc5001 (diff) | |
download | rabbitmq-server-13c4d8f8cea8635110d36f459c422a2ab04554bf.tar.gz |
Merged bug21335 into default
-rw-r--r-- | src/rabbit_basic.erl | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl index 2dc619c1..0f6aeb7a 100644 --- a/src/rabbit_basic.erl +++ b/src/rabbit_basic.erl @@ -35,6 +35,7 @@ -export([publish/1, message/4, properties/1, delivery/4]). -export([publish/4, publish/7]). +-export([build_content/2, from_content/1]). %%---------------------------------------------------------------------------- @@ -53,6 +54,8 @@ -spec(publish/7 :: (exchange_name(), routing_key(), bool(), bool(), maybe(txn()), properties_input(), binary()) -> publish_result()). +-spec(build_content/2 :: (amqp_properties(), binary()) -> content()). +-spec(from_content/1 :: (content()) -> {amqp_properties(), binary()}). -endif. @@ -72,16 +75,30 @@ delivery(Mandatory, Immediate, Txn, Message) -> #delivery{mandatory = Mandatory, immediate = Immediate, txn = Txn, sender = self(), message = Message}. +build_content(Properties, BodyBin) -> + {ClassId, _MethodId} = rabbit_framing:method_id('basic.publish'), + #content{class_id = ClassId, + properties = Properties, + properties_bin = none, + payload_fragments_rev = [BodyBin]}. + +from_content(#content{properties = Props, + properties_bin = none, + payload_fragments_rev = BodyList}) -> + {Props, list_to_binary(BodyList)}; + +from_content(#content{properties = none, + properties_bin = PropsBin, + payload_fragments_rev = BodyList}) -> + {ClassId, _MethodId} = rabbit_framing:method_id('basic.publish'), + Props = rabbit_framing:decode_properties(ClassId, PropsBin), + {Props, list_to_binary(BodyList)}. + message(ExchangeName, RoutingKeyBin, RawProperties, BodyBin) -> Properties = properties(RawProperties), - {ClassId, _MethodId} = rabbit_framing:method_id('basic.publish'), - Content = #content{class_id = ClassId, - properties = Properties, - properties_bin = none, - payload_fragments_rev = [BodyBin]}, #basic_message{exchange_name = ExchangeName, routing_key = RoutingKeyBin, - content = Content, + content = build_content(Properties, BodyBin), persistent_key = none}. properties(P = #'P_basic'{}) -> |