Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 1.07 KB | None | 0 0
  1. test() ->
  2.     AmqpParams = #amqp_params{username = ?USERNAME, password = ?PASSWORD,
  3.                   virtual_host = ?VIRTUAL_HOST, host = ?HOST,
  4.                   port = ?PORT},
  5.     Queue = <<?RESPONSE_QUEUE>>,
  6.     Connection = amqp_connection:start_network(AmqpParams),
  7.     Channel = amqp_connection:open_channel(Connection),
  8.    
  9.     Declare = #'queue.declare'{queue = Queue},
  10.     #'queue.declare_ok'{} = amqp_channel:call(Channel, Declare),
  11.  
  12.     % Now poll the queue for incoming messages.
  13.     Get = #'basic.get'{queue = Queue, no_ack = true},
  14.     {#'basic.get_ok'{}, Content} = amqp_channel:call(Channel, Get),
  15.     #amqp_msg{payload = Payload} = Content,
  16.     io:format("Received from queue ~p~n", [Payload]),
  17.    
  18.     amqp_channel:close(Channel),
  19.     amqp_connection:close(Connection).
  20.  
  21.  
  22. %% And here's the outpout
  23.  
  24. Erlang R13B03 (erts-5.7.4) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
  25.  
  26. Eshell V5.7.4  (abort with ^G)
  27. 1> amqp_test:test().
  28. ** exception error: undefined function amqp_connection:start_direct/0
  29.      in function  amqp_test:test/0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement