zoukankan      html  css  js  c++  java
  • MQTT的学习研究(九)基于HTTP GET MQTT 抓取消息服务端使用

    官方参看文档:


    HTTP GET 接收主题请求协议和响应协议
    http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21230_.htm


    HTTP POST 发布主题请求协议和响应协议
    http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21220_.htm

    HTTP DELETE 订阅主题请求协议和响应协议
    http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21240_.htm

    请求响应头各个字段的含义的讲解
    http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21250_.htm


    响应错误处理
    http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzau.doc/ts21340_.htm

    HTTP GET: WebSphere MQ bridge for HTTP command

    The HTTP GET operation gets a message from a WebSphere® MQ queue. The message is left on the queue. The HTTP GET operation is equivalent to browsing a WebSphere MQ queue.

    Syntax

    Request
    
    >>-+-DELETE-+-- --| Path |-- --HTTP version--CRLF--------------->
       '-GET----'                                       
    
       .-CRLF---------------.  .-CRLF---------------.   
       V                    |  V                    |   
    >----+----------------+-+----+----------------+-+--------------->
         '-general-header-'      '-request-header-'     
    
       .-CRLF----------------------------.   
       V                                 |   
    >----+-----------------------------+-+-------------------------><
         '-| Entity-header (Request) |-'     
    
    Path
    
    |--/--contextRoot--/-------------------------------------------->
    
    >--msg/--+-queue/--queueName--+-------------+-+--/--------------|
             |                    '-@--qMgrName-' |      
             '-topic/--topicName------------------'      
    
    entity-header (Request)
    
    |--+----------------------------------------------+-------------|
       +-standard entity-header-- --entity-value------+   
       +-x-msg-correlId - --correlation ID------------+   
       +-x-msg-msgId - --message ID-------------------+   
       +-x-msg-range-- --range------------------------+   
       +-x-msg-require-headers-- --entity header name-+   
       '-x-msg-wait - --wait time---------------------'   
    
    
    Note:
    1. If a question mark (?) is used it must be substituted with %3f. For example, orange?topic should be specified as orange%3ftopic.
    2. @qMgrName is only valid on an HTTP POST
    Response
    
    >>-HTTP version-- --HTTP Status-Code-- --HTTP Reason-Phrase--CRLF-->
    
       .-CRLF---------------.  .-CRLF----------------.   
       V                    |  V                     |   
    >----+----------------+-+----+-----------------+-+-------------->
         '-general-header-'      '-response-header-'     
    
       .-CRLF-----------------------------.                      
       V                                  |                      
    >----+------------------------------+-+--+---------------+-----><
         '-| Entity-header (Response) |-'    '-CRLF--Message-'   
    
    entity-header (Response)
    
    |--+-----------------------------------------+------------------|
       +-standard entity-header-- --entity-value-+   
       +-x-msg-class-- --message type------------+   
       +-x-msg-correlId-- --correlation ID-------+   
       +-x-msg-encoding-- --encoding type--------+   
       +-x-msg-expiry-- --duration---------------+   
       +-x-msg-format-- --message format---------+   
       +-x-msg-msgId-- --message ID--------------+   
       +-x-msg-persistence-- --persistence-------+   
       +-x-msg-priority-- --priority class-------+   
       +-x-msg-replyTo-- --reply-to queue--------+   
       +-x-msg-timestamp-- --HTTP-date-----------+   
       '-x-msg-usr-- --user properties-----------'   
    

    HTTP GET example

    HTTP GET gets a message from a queue. The message remains on the queue. In WebSphere MQ terms, HTTP GET is a browse request. You could create an HTTP DELETE request using a Java client, a browser form, or an AJAX toolkit.

    Figure 1 is an HTTP request to browse the next message on queue called myQueue.

    The request contains the HTTP request header x-msg-wait, which instructs WebSphere MQ bridge for HTTP how long to wait for a message to arrive on the queue. The request also contains the x-msg-require-headersrequest header, which specifies that the client is to receive the message correlation ID in the response.

    Figure 1. Example of an HTTP GET request
    GET /msg/queue/myQueue/ HTTP/1.1
    Host: www.example.org
    x-msg-wait: 10
    x-msg-require-headers: correlID

    Figure 2 is the response returned to the client. The correlation ID is returned to the client, as requested in x-msg-require-headers of the request.

    Figure 2. Example of an HTTP GET response
    HTTP/1.1 200 OK
    Date: Wed, 2 Jan 2007 22:38:34 GMT
    Server: Apache-Coyote/1.1 WMQ-HTTP/1.1 JEE-Bridge/1.1
    Content-Length: 50
    Content-Type: text/plain; charset=utf-8
    x-msg-correlId: 1234567890
    
    Here's my message body that will appear on the queue.
  • 相关阅读:
    Contiki学习笔记  第一个程序:Hello World
    contiki学习笔记---process结构体
    MYSQL碰到The total number of locks exceeds the lock table size 问题解决记录
    navicat连接mysql查询结果中文都是?号(C#)
    C#使用OracleBulkCopy
    解决IIS应用程序池默认回收导致程序崩溃
    构建可读性更高的 ASP.NET Core 路由机制
    .Net(C#)汉字和Unicode编码互相转换
    聊聊c#字符串拼接
    VS2010到VS2019各个版本的密钥
  • 原文地址:https://www.cnblogs.com/yudar/p/4614689.html
Copyright © 2011-2022 走看看