RabbitMQ Web管理端口是15672服务器
RabbitMQ example例子中默认链接端口是5672。
第一次启动example,测试链接服务器,端口填写错误,链接失败,返回 connection closed unexpectedlysocket
die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN,"guest", "guest")
使用用户名guest ,密码guest。登录出现以下的错误:User can only log in via localhost
默认状况下guest是没法发送数据的,必须进行修改ide
amqp_consumer和amqp_producer例子中并无指定交换机的类型,说明当前交换机的建立权力交给其余的建立者在这里,并无并无指定队列名称,而是经过指定routing_key,来关联相应的队列名。匹配的方式根据交换机的类型来肯定函数
amqp_consume_message函数执行的返回值保存在amqp_rpc_reply_t ret;测试
/**
* Response type
*
* \since v0.1
*/orm
typedef enum amqp_response_type_enum_
{
AMQP_RESPONSE_NONE = 0, /**< the library got an EOF from the socket */
AMQP_RESPONSE_NORMAL, /**< response normal, the RPC completed successfully */
AMQP_RESPONSE_LIBRARY_EXCEPTION, /**< library error, an error occurred in the
library, examine the library_error */
AMQP_RESPONSE_SERVER_EXCEPTION /**< server exception, the broker returned an
error, check replay */
} amqp_response_type_enum;
默认状况下ret.reply_type等于AMQP_RESPONSE_NORMAL说明回复正常,RPC正确执行。AMQP_RESPONSE_LIBRARY_EXCEPTION说明在函数
调用过程当中返回结果异常(并非说编译的库出现问题,而是在跟服务器通讯的时候,遇到其余的异常,例如接收超时,例如链接断开等等)server
例如,当接收超时的时候ret.library_error的返回值是-13,操做超时
AMQP_STATUS_TIMEOUT = -0x000D, /**< Operation timed out */队列
AMQP_STATUS_SOCKET_ERROR = -0x0009, /**< A socket error
occurred */
当跟服务器断开链接的时候,会返回-9错误码,在例子中并无处理这种异常状况,实际上须要进行重连rpc