Sie sind auf Seite 1von 5

BLOB Message Manipulation

Using
Message Broker

Author: Ravi Kiran V

2012. HCL Technologies Ltd. No information may be reproduced or retransmitted


without explicit permission from the company.

Introduction
The document intends to give an overview of BLOB messages and the implementation of BLOB
message types in Message Broker.

Objective
At the end of the lab, you should be able to:
Understand the usage of BLOB message types in message broker.
Understand the implementation steps of BLOB messages in Message broker.
Understand how to convert from BLOB to XML message data format.

Overview of BLOB Messages


What is BLOB?
BLOB is a message whose message format is unstructured or undetermined. That means, the BLOB
message domain includes all messages with content that cannot be interpreted and subdivided into
smaller sections of information. If you have no need to interrogate the structure, you can work with
BLOB messages
If the input node cannot determine the message characteristics, the message is considered to be in
the BLOB domain, and the BLOB parser is invoked. You can process messages in the BLOB
domain in the following ways:
You can refer to the message content if you know the location (offset) of particular information
within the message. You can specify offset values in ESQL statements within nodes in a
message flow to manipulate the information.
You can store the message in an external database, in whole or in part (where the part is
identified by the offset of the data to be stored).
The BLOB message body parser does not create a tree structure in the same way that other message
body parsers do. It has a root element BLOB that has a child element, also called BLOB, which
contains the data.
Short for binary large object, a collection of binary data stored as a single entity in a database
management systems (DBMS). BLOBs are used primarily to hold multimedia objects such as
images, videos, and sound, though they can also be used to store programs or even fragments of
code. Not all DBMSs support BLOBs.
Back in the "old days", the types of data that databases were required to store were fairly straight
forward--text, numbers, maybe a true/false field. Modern database users, however, want to store all
sorts of things in databases. Music files, specialized graphics, even video footage can be stored as
fields in a database. How do DBMSs (Database Management Systems) handle all these different
file types? One solution is to store data as a BLOB--a binary large object. Data stored as a BLOB is
stored in the database in binary format, the same format used to represent the data in computer
memory. Because every type of data can be expressed in binary format, any type of data can be
stored as a BLOB, making the format extremely flexible and popular for storing diversely formatted
data.

2012. HCL Technologies Ltd. No information may be reproduced or retransmitted


without explicit permission from the company.

You cannot manipulate the contents of a BLOB message, because it has no predefined structure.
However, you can refer to its contents using its known position within the bit stream, and process
the message with a minimum of knowledge about its contents. For example,
InputBody.BLOB.BLOB[10]
identifies the tenth byte
of the message
body;
substring(InputBody.BLOB.BLOB from 10 for 10) references 10 bytes of the message data starting
at offset 10.

Overview of scenario
This scenario depicts how to implement and parse the BLOB message in Message Broker flows.
This sample flow will read an input XML message as BLOB message and accesses some values in
this BLOB message and afterwards use these values to create a new XML message from the BLOB
message.
In this example; message flow will accept an XML message and parse it as BLOB. In the input
BLOB message, looks for the values of name and class fields and creates a new XML message
using those values. Finally, the XML message is put into an MQOutput node.

Message flows and their components


There is a single message flow used to demonstrate the BLOB messages implementation.

1. BLOB_Manipulation Flow:

Steps to configure message flow


The nodes those need configurations are mentioned below:
INPUT
This node is an MQInput node that will receive the XML input message data and parse it in
BLOB domain. The configurations for this node are as follows:

2012. HCL Technologies Ltd. No information may be reproduced or retransmitted


without explicit permission from the company.

Queue name: IN
Message Domain: BLOB
BLOB_Manipulation
This node is a Compute node that will receive the BLOB input message data .Extracts the value
from the name field and class field in the incoming XML message and create new XML
message from the input BLOB message and put it in to the output queue. The configurations for
this node are as follows:
ESQL Module: BLOB_Manipulation_BlobManipulation
Compute Mode: Message
ESQL code:
CREATE COMPUTE MODULE BLOB_Manipulation_BlobManipulation
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
DECLARE outmess BLOB;
DECLARE find_name CHARACTER;
DECLARE find_class CHARACTER;
SET outmess = InputRoot.BLOB.BLOB;
SET find_name = CAST (SUBSTRING(outmess FROM 19 FOR 4)AS CHARACTER CCSID 1208);
SET find_class = CAST (SUBSTRING(outmess FROM 43 FOR 2)AS CHARACTER CCSID 1208);
SET OutputRoot.XMLNSC.Test.name = find_name;
SET OutputRoot.XMLNSC.Test.class = find_class;
RETURN TRUE;
END;

END MODULE;

OUTPUT
This node is an MQOutput node that will send the XML output message to the output queue
OUT. The configurations for this node are as follows:
Queue name: OUT

Testing the message flow


1. Deploy the message & Message set and ensure that the flow is up and running.
2. Put message (SampleRequest.xml) to the MQInput node (IN) of message flow using RFHUTIL
Tool.
3. Check the Output message from Output queue (OUT) of message flow using RFHUTIL Tool.

2012. HCL Technologies Ltd. No information may be reproduced or retransmitted


without explicit permission from the company.

Reference
1. Message Broker Esql. PDF (From IBM Information center of Message Broker).

Appendix
1. Project workspace containing source code for the POC.

BLOB_Manipulation.zi
p

SampleRequest.xml

2012. HCL Technologies Ltd. No information may be reproduced or retransmitted


without explicit permission from the company.

Das könnte Ihnen auch gefallen