[rabbitmq-discuss] Send message from erlang client problem

Robert Raschke rtrlists at googlemail.com
Wed Jun 29 16:20:12 BST 2011


On Wed, Jun 29, 2011 at 2:57 PM, Alexander Kuleshov
<kuleshovmail at gmail.com>wrote:

> Hello,
>
> I try to send messsage to rabbitmq-server:
>
> send_message(Channel, Host, Password, Message) ->
>    % TODO maybe change routing_key on sit_in_reply
>    amqp_channel:cast(Channel, #'basic.publish'{exchange = <<"">>},
> routing_key = <<"test">>,
>                      #amqp_msg{payload = Message}).
>
> But get error:
>
> Error in process <0.431.0> with exit value:
> {function_clause,[{gen_server,cast, [2,{cast,{'basic.publish',0,<<0
> bytes>>,<<7 bytes>>,false,false},
>
> {amqp_msg,{'P_basic',undefined,undefined,undefined,undefined,undefined,undefined,
> undefined,undefined,undefined,undefined,undefined...
>
> How can i fix it? How can i correctly send message to rabbitmq-server?
>
>
It looks like the closing curly brace is in the wrong place. The following
should work (I tend to use call instead of cast, but I think they're
equivalent in this case):

send_message(Channel, Host, Password, Message) ->
    amqp_channel:call(Channel,
        #'basic.publish'{exchange = <<"">>, routing_key = <<"test">>},
        #amqp_msg{payload = Message}
    ).


Robby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110629/5ae0a971/attachment-0001.htm>


More information about the rabbitmq-discuss mailing list