![]() |
![]() |
|
|
Messaging API Sample
The Messaging API sample shows how the WebLogic Integration Messaging API can be used. Specifically, it demonstrates the use of two message-delivery mechanisms available with the Messaging API and the logic plug-in feature of WebLogic Integration B2B.
This section includes the following topics:
Overview of the Messaging API Sample
WebLogic Integration supports two methods of sending business messages:
This sample uses the second method.
The WebLogic Integration Messaging API supports two message-delivery mechanisms:
The sample demonstrates the use of both the synchronous and deferred synchronous message delivery mechanisms.
The Messaging API sample contains three trading partners (Partner1, Partner2, and Partner3) that send business messages. The Messaging API sample contains four Java source code files: MdmTp1Servlet.java, MdmTp2Servlet.java, MdmTp3Servlet.java, and WaiterPlugin.java.
For more information about the WaiterPlugIn.java code, see Tracing the Execution Flow. Before Running the Messaging API Sample Before running the Messaging API sample, complete the following steps:
Running the Messaging API Sample
To run the Messaging API sample, complete the following steps:
Choose Start
a) Make sure your PATH environment variable includes the directory in which the Netscape (netscape) executable resides.
b) Go to the WebLogic Integration home directory (the directory in which you installed WebLogic Integration). For example:
cd /home/me/bea/wlintegration2.1
c) Run the setenv script to set the top-level WebLogic Integration environment variables:
. setenv.sh
d) Run the RunSamples script:
cd samples/bin
RunSamples
Warning: For UNIX systems, the directory in which the netscape executable resides must be included in your PATH environment variable. If it is not included, the samples launcher page cannot be displayed.
The WebLogic Integration repository has already been
created and populated, possibly from a previous run
of this RunSamples script. Do you want to destroy all the
current data in the repository and create and populate the
WebLogic Integration repository, again? Y for Yes, N for No
If you answer N to this question, the RunSamples script skips the steps for creating and populating the repository and runs only the step for booting the sample instance of the WebLogic Server.
If you answer Y to this question, the RunSamples script recreates and repopulates the repository, and then it boots the sample instance of the WebLogic Server. When you answer Y the RunSamples script destroys all the data currently in the repository and loads an unaltered version of the sample data into the repository. Answer Y only when the current sample data has been altered or removed and you want a fresh or unaltered version of the sample data in the repository.
Now the RunSamples script starts an instance of the WebLogic Server as a background process and the samples launcher page is displayed.
If the Messaging API sample is executed successfully, the following output is displayed at the bottom of the right pane:
Partner1 process flow:
Starting XOCPAppplication... done.
Creating conversation : verifierConversation:1.0:
requestor_Partner1_1001029696695_341001029696695...done.
send string for Message 1 = FIRST MESSAGE
Sending message 1 using synchronous deferred delivery method to Partner 2
Sending a second message before checking for acknowledgment on the first
send string for Message 2 = SECOND MESSAGE
Sending message 2 using synchronous delivery method to Partner 3
success status for message 2
Waiting for Message 2 response... done.
Processing reply for Message 2:
Received string for Message 2 = partner3 -- second message
Verification for Message 2 SUCCESS
Doing something else... done
Waiting acknowledgment for Message 1... Acknowledgment received
Success status for message 1
Waiting for Message 1 response... done
Processing reply:
Received string for Message 1 = partner2 -- first message
Verification for Message 1 SUCCESS
Terminating conversation:verifierConversation:1.0:
requestor_Partner1_1001029696695_341001029696695
success
Shutting down session... done.
If you do not plan on running more B2B samples at this time, shut down the instance of the WebLogic Server by completing the procedure appropriate for your platform:
Choose Start
cd $WLI_HOME/config/samples
stopWebLogic
Tracing the Execution Flow
The following steps trace the execution flow of the Messaging API sample:
The following figure shows the sequence in which these business messages are most likely to be sent and received. (The exact sequence is timing related and depends on the thread scheduling of the Java virtual machine.)
Figure 6-1 Interactive Diagram of the Flow of Messages Among Trading Partners
The following sequence provides details about each of the steps indicated by a corresponding letter in Figure 6-1:
The nonblocking aspect of the message is represented in the Interaction diagram (Figure 6-1) by Partner1's Object lifeline. When Partner initially becomes active, the representation of Partner1's lifeline changes from a dashed line (indicating an inactive state) to a narrow rectangle (indicating an active state). The lifeline remains active after Partner1 sends the first message. By remaining active, Partner1 can do other tasks, such as sending another message, as shown in the next step.
All the messages sent in this sample are routed through the hub. A logic plug-in called WaiterPlugIn has been added to the filter chain of the hub. When messages are routed though the hub, the process method of the WaiterPlugIn class is executed. The process method checks the target recipient of the outgoing message. If the target recipient is Partner2, process sleeps for 15 seconds. Otherwise, it sends the message immediately. In the example shown in Figure 6-1, the first message, which was sent by Partner1 to Partner2, is delayed by 15 seconds.
The second message and all the reply messages of this sample are routed through the hub, where the process method of WaiterPlugIn is executed on them. Each of these messages passes through the hub without delay because the recipient of the message is not Partner2. Routing of these messages through the hub filter logic plug-in is not shown in Figure 6-1.
![]() |
![]() |
![]() |
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|