Skip to content

Instantly share code, notes, and snippets.

@hamidreza-s
Last active August 11, 2017 14:16
Show Gist options
  • Save hamidreza-s/10966969 to your computer and use it in GitHub Desktop.
Save hamidreza-s/10966969 to your computer and use it in GitHub Desktop.
How to send direct message to RabbitMQ through Erlang console instead of AMQP protocol.
-module(direct_msg_to_rabbit).
%% Define Record
-record('P_basic', {
content_type,
content_encoding,
headers,
delivery_mode, priority,
correlation_id,
reply_to,
expiration,
message_id,
timestamp,
type,
user_id,
app_id,
cluster_id
}).
%% Message Body
Body = <<"Hi rabbit!\n">>.
%% Message Properties
Properties = {'P_basic',<<"text/plain">>,undefined,undefined,2,
undefined,undefined,undefined,undefined,undefined,
undefined,undefined,undefined,undefined,undefined}.
%% Routing Key
RoutingKeyBin = <<"foo">>.
%% Exchange Name
Exchange = {resource,<<"/">>,exchange,<<"bar">>}.
%% Publish Message
rabbit_basic:publish(Exchange, RoutingKeyBin, Properties, Body).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment