+

Search Tips | Advanced Search

Message formats for the IBM MQ Bridge to blockchain

Information on formatting of the messages that are sent and received by the IBM MQ Bridge to blockchain.

An application requests that the IBM MQ Bridge to blockchain performs a query or update of information that is held on the blockchain. The application does this by placing a request message on the bridge request queue. The results of the query or the update are formatted by the bridge into a reply message. The bridge uses information that is contained in the ReplyToQ and ReplyToQMgr fields from the MQMD of the request message as the destination for the reply message.

The messages that are consumed and produced by the bridge are text (MQSTR) messages in JSON format. The input message is a simple JSON and programs can use string concatenation to generate it. All the fields except args are required, the argument list for that field requires knowledge of the functions of the stored chaincode.


Request Message Format

Input message format:
{ "function": functionName,
    "channel" : chainName,
    "chaincodeName" : codeName,
    "args" : [ argument list]
}
For the local hyperledger network example with the working Fabcar sample.

For the Kubernetes cluster network example with the working example02 demo.


Reply Message Format

Response messages have their correlation ID set to the message ID of the inbound message. Any user-defined properties are copied from the input to the output messages. The user ID in the reply is set to the originator's user ID through the set-identity context.

An example of successful processing:
{ "data": "500", "message": "OK", "statusCode": 200, "statusType": "SUCCESS" }
The response data in this message is whatever is generated from the chaincode response (bytes converted to a UTF-8 string). All error responses have the same fields, regardless of whether they are generated by the bridge itself, from the calls to blockchain, or from the chaincode invocation. For example:

Applications can tell whether the request succeeded or failed by either looking at the statusType string, or from the existence of the data field. When there is an error in processing the input message, and the bridge does not send it to blockchain, the value that is returned from the bridge is an MQRC value, usually MQRC_FORMAT_ERROR.