{"action":"created","issue":{"url":"https://api.github.com/repos/shopgun/turtle/issues/15","repository_url":"https://api.github.com/repos/shopgun/turtle","labels_url":"https://api.github.com/repos/shopgun/turtle/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/shopgun/turtle/issues/15/comments","events_url":"https://api.github.com/repos/shopgun/turtle/issues/15/events","html_url":"https://github.com/shopgun/turtle/issues/15","id":160649502,"number":15,"title":"how to use turtle:publish?","user":{"login":"dcy","id":1137238,"avatar_url":"https://avatars.githubusercontent.com/u/1137238?v=3","gravatar_id":"","url":"https://api.github.com/users/dcy","html_url":"https://github.com/dcy","followers_url":"https://api.github.com/users/dcy/followers","following_url":"https://api.github.com/users/dcy/following{/other_user}","gists_url":"https://api.github.com/users/dcy/gists{/gist_id}","starred_url":"https://api.github.com/users/dcy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcy/subscriptions","organizations_url":"https://api.github.com/users/dcy/orgs","repos_url":"https://api.github.com/users/dcy/repos","events_url":"https://api.github.com/users/dcy/events{/privacy}","received_events_url":"https://api.github.com/users/dcy/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-06-16T12:28:40Z","updated_at":"2016-07-14T01:57:02Z","closed_at":"2016-06-16T17:03:56Z","body":"Hi!\r\n```\r\n-module(rmqc).\r\n-export([send/0,\r\n\t\t gen_publish/0,\r\n\t\t publish/0\r\n\t\t]).\r\n-include_lib(\"amqp_client/include/amqp_client.hrl\").\r\n\r\ngen_publish() ->\r\n\tturtle_publisher:start_link(my_publisher, amqp_server,\r\n\t\t\t\t\t\t\t\t[#'exchange.declare' { exchange = <<\"test\">>},\r\n\t\t\t\t\t\t\t\t #'queue.declare' { queue = <<\"hello\">>},\r\n\t\t\t\t\t\t\t\t #'queue.bind' { queue = <<\"hello\">>, exchange = <<\"test\">>, routing_key = <<\"hello\">> }],\r\n\t\t\t\t\t\t\t\t#{ confirms => true} ),\r\n\tok.\r\n\r\npublish() ->\r\n\tResult = turtle:publish(my_publisher, <<\"test\">>, <<\"hello\">>, <<\"text/plain\">>, <<\"Hello World!\">>),\r\n\tlager:error(\"**********Result: ~p\", [Result]),\r\n\tok.\r\n\r\n\r\nsend() ->\r\n    {ok, Connection} =\r\n        amqp_connection:start(#amqp_params_network{host = \"localhost\"}),\r\n    {ok, Channel} = amqp_connection:open_channel(Connection),\r\n\r\n    %amqp_channel:call(Channel, #'queue.declare'{queue = <<\"hello\">>}),\r\n\r\n    amqp_channel:cast(Channel,\r\n                      #'basic.publish'{\r\n                        exchange = <<\"\">>,\r\n                        routing_key = <<\"hello\">>},\r\n                      #amqp_msg{payload = <<\"Hello World!\">>}),\r\n    io:format(\" [x] Sent 'Hello World!'~n\"),\r\n    ok = amqp_channel:close(Channel),\r\n    ok = amqp_connection:close(Connection),\r\n\tok.\r\n```\r\n```send/0``` use amqp_client, ```publish/0``` use turtle, it woks both.\r\nAm i right in using ```turtle:publish/5```?\r\n"},"comment":{"url":"https://api.github.com/repos/shopgun/turtle/issues/comments/232536373","html_url":"https://github.com/shopgun/turtle/issues/15#issuecomment-232536373","issue_url":"https://api.github.com/repos/shopgun/turtle/issues/15","id":232536373,"user":{"login":"dcy","id":1137238,"avatar_url":"https://avatars.githubusercontent.com/u/1137238?v=3","gravatar_id":"","url":"https://api.github.com/users/dcy","html_url":"https://github.com/dcy","followers_url":"https://api.github.com/users/dcy/followers","following_url":"https://api.github.com/users/dcy/following{/other_user}","gists_url":"https://api.github.com/users/dcy/gists{/gist_id}","starred_url":"https://api.github.com/users/dcy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcy/subscriptions","organizations_url":"https://api.github.com/users/dcy/orgs","repos_url":"https://api.github.com/users/dcy/repos","events_url":"https://api.github.com/users/dcy/events{/privacy}","received_events_url":"https://api.github.com/users/dcy/received_events","type":"User","site_admin":false},"created_at":"2016-07-14T01:57:02Z","updated_at":"2016-07-14T01:57:02Z","body":"Sorry! i forget these:\r\n```\r\n\tChildSpec = turtle_publisher:child_spec(my_publisher, amqp_server, AMQPDecls, #{ confirms => true}),\r\n\tsupervisor:start_child(turtle_sup, ChildSpec),\r\n```\r\nAfter these, it will create a process in turtle_sup, maybe this is better than ```turtle_publisher:start_link```"}}
{"actor":{"display_login":"dcy"}}