Corporate Info | News | Solutions | Products | Partners | Services | Events | Download | How To Buy
eLink Information Integrator Doc Home | eLink Information Integrator User Guide | Previous Topic | Next Topic | Contents | Index

Message Explosion Example

This section illustrates a message explosion process. In this example, you need to take an input FML buffer containing a single city name and a variable number of state names and "explode" the buffer into the multiple buffers. Each of these buffers is an FML buffer containing one city name and one state name. These buffers will then be enqueued onto a queue named Test1Q.

The following topics are discussed:

- Input Buffer Contents

- MFL File Definitions

- Rule Definitions

Input Buffer Contents

The contents of the input buffer is shown in Table B-1.

####

Table B-1 Input Buffer Contents

FIELD | VALUE
--- | ---
CITY | San Jose
STATE | CA
STATE | TX
STATE | CO

The contents of the three buffers that would result from "exploding" the input message is shown in Table B-2.

####

Table B-2 Exploded Buffer Contents

FIELD | VALUE
--- | ---
Buffer1
CITY | San Jose
STATE | CA
Buffer2
CITY | San Jose
STATE | TX
Buffer3
CITY | San Jose
STATE | CO

MFL File Definitions

This section describes the MFL files that need to be created for this message explosion example. Listing B-1 shows the MFL file required to create the appropriate input format to parse the input buffer.

Listing B-1 explode_msg1.xml

>     <?xml version='1.0'?>
>     <!DOCTYPE MessageFormat SYSTEM 'mfl.dtd'>
>     <MessageFormat name="II_explode_msg1">
>         <FieldFormat name="CITY" type="String"/>
>         <FieldFormat name="$RSTATE" type="BigEndian2" />
>         <StructFormat name="State_Rep" repeatField="$RSTATE">
>         <FieldFormat name="STATE" type="String" accessMode="Controlling" />
>         </StructFormat>
>     </MessageFormat>

In the input buffer, the STATE field repeats a variable number of times. To account for this, a flat input format containing the single field STATE needs to be defined. The StructFormat statement in the MFL file creates this flat input format named "State_Rep". The field $RSTATE is the repeatField for this format; that is, it indicates the number of times that format appears in the message. The "$R" prefix in the name of the field tells Information Integrator to populate the repeatField by using the FML function Foccur(). The Foccur() function determines the number of occurrences of the given field. Taking advantage of the functionality supplied by FML allows you the freedom to include an arbitrary number of occurrences of a given field in the input buffer, without having to explicitly assign a value to a field that indicates the number of occurrences of that field.

Because the input format II_explode_msg1 defined in the above MFL file contains a flat input format, it must be a compound format. Only compound formats can contain other formats. Since compound formats cannot contain fields that are not included in other defined formats, MsgDefAdmin creates a flat input format with the fields CITY and $RSTATE. The name of this flat input format begins with "$STRUCT_", and it is visible only under the compound format II_explode_msg1 in the Formatter window (see Using the Formatter Window).

Now you need to define an output format into which the input message will be reformatted. This output format must allow for the fact that there will be a variable number of CITY/STATE pairs in the reformatted message. MFL file that could be used to create the appropriate output format.

Listing B-2 explode_msg2.xml

<?xml version='1.0'?>
<!DOCTYPE MessageFormat SYSTEM 'mfl.dtd'>
<MessageFormat name="II_explode_msg2">
<FieldFormat name="$RSTATE" type="BigEndian2" />
<StructFormat name="State2_Rep" repeatField="$RSTATE">
<FieldFormat name="CITY" type="String"/>
<FieldFormat name="STATE" type="String" accessMode="Controlling"/>
</StructFormat>
</MessageFormat>

As with the input format definition, there is a flat output format named "State2_Rep" which contains the fields CITY and STATE. This is created using the StructFormat statement in the MFL file. $RSTATE is the repeatField for this structure. There are two reasons for this:

- The State2_Rep output format occurs exactly as many times as the STATE field occurs.

- Information Integrator maps fields with the same name to each other by default. The value in the $RSTATE field in the input buffer should be exactly the same in the output buffer.

The format II_explode_msg2 contains other formats, so it must be a compound format. Since compound formats cannot contain fields that are not included in other defined formats, MsgDefAdmin creates a flat output format with a name beginning with "$STRUCT$_" to contain the field $RSTATE.

Note: You may want to use the Formatter application to view the format definitions created by II_explode_msg1 and II_explode_msg2. For more information, refer to Building Format Definitions.

For more information on MFL files and the MsgDefAdmin utility, refer to Using MsgDefAdmin.

Rule Definitions

Now you need to define the necessary rules, following the steps below. For detailed instructions on performing these tasks, refer to Building Rules.

1. Create an Application Group named ME.

2. Add a new Message Type named II_explode_msg1_I to the Application Group.

   Note: Remember that the Message Type is always the same as the Input Format used to parse the input message.

3. Add a Rule called NewRule1 to the Message Type.

4. Define the Expression for the new Rule to be TRUE, because you always want NewRule1 to "fire" when a request is made to a service with Application Group ME and Input Message II_explode_msg1_I.

5. Create a subscription that causes the IISERVER to perform the necessary Actions. This subscription is illustrated in Figure B-1.

   Figure B-1 Figure 3: NewSubscription1

The above subscription contains three actions:

- Reformat - The Reformat takes the original input buffer passed in by the client and parses it using the II_explode_msg1_I compound input format. It reformats the message using the compound output format II_explode_msg2_O and produces an FML32 buffer. If the input message contained a CITY field and three STATE fields, after the reformat, the resulting buffer would contain three CITY/STATE pairs of fields.

- Explode - The result of the Reformat serves as input to the Explode action. This is because the Input Message for the Explode is defined as "2", which is the Output Message for the Reformat. The Explode action separates the single message containing multiple CITY/STATE pairs into multiple messages containing one CITY/STATE pair each. This is accomplished by using State2_Rep_I as the Explode Format.

- Enqueue - Since the Enqueue action immediately follows the Explode action, each one of the separate buffers produced by the Explode action is enqueued on the queue Test1Q in the queue space II_QueueSpace.

Copyright © 2000 BEA Systems, Inc. All rights reserved. Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.