Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.77 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).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement