Erlang Mailing Lists

Author Message

<  RabbitMQ mailing list  ~  pub-sub erlang problem

Guest
Posted: Sun Apr 06, 2008 9:53 pm Reply with quote
Guest
I am trying to get pub-sub model to work in rabbitmq.
0x6e6562
Posted: Tue Apr 08, 2008 12:01 pm Reply with quote
User Joined: 12 Jul 2007 Posts: 250
Joe,

Sorry about the delay in answering your question.

It looks like you're trying to publish to an exchange that doesn't
exist, although the server diagnostic could be a little clearer on
this point.

To fix your test, precede the exchange declare command before the
publish command, i.e. put this code before the publish call:

ExchangeDeclare = #'exchange.declare'{ticket = Ticket, exchange = X,
type = <<"topic">>,
passive = false, durable =
false, auto_delete = false, internal = false,
nowait = false, arguments =
[]},
#'exchange.declare_ok'{} = amqp_channel:call(Channel, ExchangeDeclare)

We should probably take on board better server diagnostics as an
improvement item.

HTH,

Ben

On 6 Apr 2008, at 22:53, Joe Lee wrote:

> I am trying to get pub-sub model to work in rabbitmq. My
> understanding is that you still have to perform
> amqp_connection:start, amqp_connection:open_channel,
> amqp_channel:call(Channel, Access), channel close and connection
> close on each async call.
> I am not sure what payload_fragments_rev = [Payload] is for. I have
> searched through amqp xml specs and pdf. Maybe I am not hitting the
> right keywords. For pub-sub model, how do you assign the message,
> assign it to Payload variable?
>
> I am new to erlang. This shouldn't be a show stopper. I just need
> to get this working. I am getting following error:
>
> (rabbit@home)1> amqp_async:amqp_lifecycle().
> Connection: {<0.217.0>,direct}
>
> =ERROR REPORT==== 6-Apr-2008::16:33:51 ===
> Lax ticket check mode: ignoring cross-realm access for ticket 101
> ** exception exit: {{amqp,not_found,'basic.publish'},
> {gen_server,call,
> [<0.218.0>,
> {call,{'channel.close',200,<<"Goodbye">>,
> 0,0}}]}}
> in function gen_server:call/2
> in call from amqp_async:amqp_lifecycle/0
>
> my pub-sub code:
>
> -module(amqp_async).
>
> -include_lib("rabbitmq_server/include/rabbit_framing.hrl").
> -include_lib("rabbitmq_server/include/rabbit.hrl").
>
> -export([amqp_lifecycle/0]).
>
> amqp_lifecycle() ->
> User = Password = "guest",
> Realm = <<"/data">>,
>
> %% Start a connection to the server
>
> Connection = amqp_connection:start(User, Password),
> io:format("Connection: ~p~n",[Connection]),
> %% Once you have a connection to the server, you can start an
> AMQP channel gain access to a realm
>
> Channel = amqp_connection:open_channel(Connection),
> Access = #'access.request'{realm = Realm,
> exclusive = false,
> passive = true,
> active = true,
> write = true,
> read = true},
> #'access.request_ok'{ticket = Ticket} =
> amqp_channel:call(Channel, Access),
>
> X = <<"x">>,
> RoutingKey = <<"a.b.c.*">>,
> Payload = <<"foobar">>,
> BasicPublish = #'basic.publish'{ticket = Ticket,
> exchange = X,
> routing_key = RoutingKey,
> mandatory = false,
> immediate = false},
> Content = #content{class_id = 60,
> properties = amqp_util:basic_properties(),
> properties_bin = none,
> payload_fragments_rev = [Payload]
> },
> amqp_channel:cast(Channel, BasicPublish, Content),
>
> %% After you've finished with the channel and connection you
> should close them down
>
> ChannelClose = #'channel.close'{reply_code = 200, reply_text =
> <<"Goodbye">>,
> class_id = 0, method_id = 0},
> #'channel.close_ok'{} = amqp_channel:call(Channel, ChannelClose),
> ConnectionClose = #'connection.close'{reply_code = 200,
> reply_text = <<"Goodbye">>,
> class_id = 0, method_id =
> 0},
> #'connection.close_ok'{} = amqp_connection:close(Connection,
> ConnectionClose),
> ok.
>
> Thank you,
> Joe
>
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss@lists.rabbitmq.com
> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist
View user's profile Send private message
alexis
Posted: Tue Apr 08, 2008 8:51 pm Reply with quote
User Joined: 06 Sep 2007 Posts: 80 Location: London
Joe

To add to Ben's comment: If you are new to erlang you may wish to use
the Java client. There are quite a few documented examples for that,
or you can try the .NET client docs.

Please keep the questions coming!

Best wishes

alexis



On Tue, Apr 8, 2008 at 1:00 PM, Ben Hood <0x6e6562@gmail.com> wrote:
> Joe,
>
> Sorry about the delay in answering your question.
>
> It looks like you're trying to publish to an exchange that doesn't
> exist, although the server diagnostic could be a little clearer on
> this point.
>
> To fix your test, precede the exchange declare command before the
> publish command, i.e. put this code before the publish call:
>
> ExchangeDeclare = #'exchange.declare'{ticket = Ticket, exchange = X,
> type = <<"topic">>,
> passive = false, durable =
> false, auto_delete = false, internal = false,
> nowait = false, arguments =
> []},
> #'exchange.declare_ok'{} = amqp_channel:call(Channel, ExchangeDeclare)
>
> We should probably take on board better server diagnostics as an
> improvement item.
>
> HTH,
>
> Ben
>
>
>
> On 6 Apr 2008, at 22:53, Joe Lee wrote:
>
> > I am trying to get pub-sub model to work in rabbitmq. My
> > understanding is that you still have to perform
> > amqp_connection:start, amqp_connection:open_channel,
> > amqp_channel:call(Channel, Access), channel close and connection
> > close on each async call.
> > I am not sure what payload_fragments_rev = [Payload] is for. I have
> > searched through amqp xml specs and pdf. Maybe I am not hitting the
> > right keywords. For pub-sub model, how do you assign the message,
> > assign it to Payload variable?
> >
> > I am new to erlang. This shouldn't be a show stopper. I just need
> > to get this working. I am getting following error:
> >
> > (rabbit@home)1> amqp_async:amqp_lifecycle().
> > Connection: {<0.217.0>,direct}
> >
> > =ERROR REPORT==== 6-Apr-2008::16:33:51 ===
> > Lax ticket check mode: ignoring cross-realm access for ticket 101
> > ** exception exit: {{amqp,not_found,'basic.publish'},
> > {gen_server,call,
> > [<0.218.0>,
> > {call,{'channel.close',200,<<"Goodbye">>,
> > 0,0}}]}}
> > in function gen_server:call/2
> > in call from amqp_async:amqp_lifecycle/0
> >
> > my pub-sub code:
> >
> > -module(amqp_async).
> >
> > -include_lib("rabbitmq_server/include/rabbit_framing.hrl").
> > -include_lib("rabbitmq_server/include/rabbit.hrl").
> >
> > -export([amqp_lifecycle/0]).
> >
> > amqp_lifecycle() ->
> > User = Password = "guest",
> > Realm = <<"/data">>,
> >
> > %% Start a connection to the server
> >
> > Connection = amqp_connection:start(User, Password),
> > io:format("Connection: ~p~n",[Connection]),
> > %% Once you have a connection to the server, you can start an
> > AMQP channel gain access to a realm
> >
> > Channel = amqp_connection:open_channel(Connection),
> > Access = #'access.request'{realm = Realm,
> > exclusive = false,
> > passive = true,
> > active = true,
> > write = true,
> > read = true},
> > #'access.request_ok'{ticket = Ticket} =
> > amqp_channel:call(Channel, Access),
> >
> > X = <<"x">>,
> > RoutingKey = <<"a.b.c.*">>,
> > Payload = <<"foobar">>,
> > BasicPublish = #'basic.publish'{ticket = Ticket,
> > exchange = X,
> > routing_key = RoutingKey,
> > mandatory = false,
> > immediate = false},
> > Content = #content{class_id = 60,
> > properties = amqp_util:basic_properties(),
> > properties_bin = none,
> > payload_fragments_rev = [Payload]
> > },
> > amqp_channel:cast(Channel, BasicPublish, Content),
> >
> > %% After you've finished with the channel and connection you
> > should close them down
> >
> > ChannelClose = #'channel.close'{reply_code = 200, reply_text =
> > <<"Goodbye">>,
> > class_id = 0, method_id = 0},
> > #'channel.close_ok'{} = amqp_channel:call(Channel, ChannelClose),
> > ConnectionClose = #'connection.close'{reply_code = 200,
> > reply_text = <<"Goodbye">>,
> > class_id = 0, method_id =
> > 0},
> > #'connection.close_ok'{} = amqp_connection:close(Connection,
> > ConnectionClose),
> > ok.
> >
> > Thank you,
> > Joe
> >
> >
> >
> >
> > _______________________________________________
> > rabbitmq-discuss mailing list
> > rabbitmq-discuss@lists.rabbitmq.com
> > http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss@lists.rabbitmq.com
> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>



--
Alexis Richardson
+44 20 7617 7339 (UK)
+44 77 9865 2911 (cell)
+1 650 206 2517 (US)

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist
View user's profile Send private message Yahoo Messenger
Guest
Posted: Wed Apr 09, 2008 7:33 pm Reply with quote
Guest
Ben,

Ben Hood wrote:
> It looks like you're trying to publish to an exchange that doesn't
> exist, although the server diagnostic could be a little clearer on
> this point.
> [...]
> We should probably take on board better server diagnostics as an
> improvement item.

Definitely. It's already on the list.


Matthias.

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum