BEA Logo BEA Collaborate Release 2.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   Collaborate Documentation   |   Samples Guide   |   Previous Topic   |   Next Topic   |   Contents

Messaging API Sample

 

This section describes the Messaging API sample, which demonstrates two message delivery mechanisms built with the WebLogic Collaborate messaging API and logic plug-in features. It includes the following topics:

 


Overview of the Messaging API Sample

WebLogic Collaborate supports two message delivery methods:

Figure 4-1 illustrates the Messaging API sample conversation.

Figure 4-1 Diagram of the Messaging API Sample Conversation


 

  1. Partner1 sends a message (1, 2) to Partner2, who replies (3, 4).

  2. The logic plug-in holds the reply for 15 seconds.

  3. Before looking for a reply from Partner2, Partner1 sends a second message to Partner3 (5, 6).

  4. Partner3 replies to Partner1 (7, 8).

  5. Partner1 now retrieves the reply from Partner2 (9).

  6. The results are displayed by Partner1 in an HTML page (10).

A hub delivery channel (VerifierCSpace) is registered in the WebLogic Collaborate repository. The three trading partners in the delivery channel participate in a conversation (verifierConversation), assuming the following roles:

Message definitions are stored in two repository files: request.dtd and reply.dtd.

Partner1, the requestor trading partner, sends two different messages to Partner2 and Partner3. The first message contains the string FIRST MESSAGE, and is sent to Partner2 using the deferred synchronous delivery method.

Once the first message has been sent, and before checking for a reply from Partner2, Partner1 sends a second message containing the string SECOND MESSAGE to Partner3 using the synchronous delivery method.

At this point, Partner1 must wait for acknowledgment from Partner3 before performing any other action. When the acknowledgment from Partner3 is received and the reply is processed, Partner1 is able to retrieve the messageToken received when the first message was sent, and check for the acknowledgment received from Partner2.

The reply to the second message is then processed, and the results of the conversation are displayed for Partner1 in an HTML page produced by the Post method of the invoking servlet.

The invoking servlet used by Partner1 is represented by the examples.MessageDeliveryMethods.MdmTp1Servlet.java servlet, which is registered in the repository as MdmTp1. Partner2 and Partner3 use similar servlets, registered in their respective repositories as MdmTp2 and MdmTp3.

The servlets used by Partner2 and Partner3 are examples.MessageDeliveryMethods.MdmTp2Servlet.java and examples.MessageDeliveryMethods.MdmTp3Servlet.java. They are registered in WebLogic Collaborate as MdmTp2 and MdmTp3. These servlets are invoked by the HTML page MessageDeliveryMethods.html, which is located in the WebLogic Collaborate directory %WLC-HOME%\config\samples\applications\DefaultWebApp_myserver.

In order to simulate a delay in the reception of the first message by Partner2, a logic plug-in called WaiterPlugIn has been added to the WebLogic Collaborate filter chain; the WaiterPlugIn class checks for the target recipient of the outgoing message. If the target recipient is Partner2, the corresponding thread sleeps for 15 seconds; if the target recipient is not Partner2, the message is sent immediately to the target trading partner (Partner3).

The first message is sent to the target recipient using a deferred synchronous delivery method. As a result of the sending operation, an XOCPMessageToken object (token1) is returned to the sender. This token is used to check for the acknowledgment of the reception by Partner2, as follows:

// send the message in synchronous deferred mode 
XOCPMessageToken token1 = (XOCPMessageToken)smsg1.send();
debug("Sending message 1: conversation id="+c.getId()+" done");

 


Configuration of the Messaging API Sample

The following data is bulkloaded during samples installation and configuration:

 


Running the Messaging API Sample

  1. Install the samples as described in Installing the Samples.

    Make sure that you have bulkloaded the schemas and data, and have started WebLogic Collaborate.

  2. Start the Messaging API sample.

    Windows: Choose WebLogic Integration 2.0—>Collaborate—>Samples—>Run Samples—>Messaging API

    UNIX: Load the following HTML page:

    HTTP://localhost:7001/MsgDeliveryMethods.html

    A browser window is opened with a Messaging API screen, as shown in the following illustration.

    Figure 4-2 Messaging API Sample First Screen


     

  3. Submit a request to start WebLogic Collaborate for Partner3, Partner2, and Partner1.

  4. Click Join Partner 3 spoke.

    A WebLogic Collaborate session is started for Partner3, and Partner3 is registered in the replyer role for the verifierConversation conversation.

  5. Click Join Partner 2 spoke.

    A WebLogic Collaborate session is started for Partner2, who is registered with the replyer role for the verifierConversation conversation.

  6. Click Join Partner 1 spoke and send request.

    A WebLogic Collaborate session is started for Partner1, and Partner1 is registered with the requestor role for the verifierConversation conversation. Partner1 acts as the conversation initiator, and sends message1 and message2 to Partner2 and Partner3, respectively.

    Note: You can follow the progression of the sample by checking the weblogic.log file displayed in the WebLogic Collaborate Administration Console.

  7. The outgoing message is analyzed by the WaiterPlugIn logic plug-in. If the target recipient is Partner2, the corresponding thread sleeps for 15 seconds before delivering the message to the trading partner; otherwise the message is delivered immediately.

  8. Partner3 receives message2 from Partner1 in the form of a string: SECOND MESSAGE. Partner3 converts the string to lowercase, and adds the following prefix to it: partner3 -- . The result is the string partner3 -- second message. At this point, the string is added to a business document and sent back to Partner1.

  9. Partner1 receives the message, processes a response, and then loops for ten seconds.

  10. After the 10-second interval, Partner1 receives the token for sending message1, and then waits for a response from Partner2.

  11. Partner2 receives the response after WaiterPlugIn has slept for 15 seconds.

  12. Partner2 receives message1 from Partner1 in the form of a string: FIRST MESSAGE. Partner2 converts the string to lowercase, and adds the following prefix to it: partner2 -- . The result is the string partner2 -- first message. At this point the string is added to a business document and sent back to Partner1.

  13. Partner1 receives the message and processes the response.

  14. Partner1 terminates the conversation and shuts down the session. When the session is stopped, Partner2 and Partner3 automatically leave the conversation. The console displays a log message similar to the following:
    Wed Oct 25 17:47:42 PDT 2000:<I <WLC <XOCP-Hub INFO: Trading Partner, Partner1 left C-Space, VerifierCSpace 
    Wed Oct 25 17:47:42 PDT 2000:<I <WLC <User ***MdmTp1Servlet: done.

Messaging API Sample Output

When the Messaging API sample is executed successfully, the following output is displayed in the browser window:

Partner1 process flow: 
Starting enabler... done.
Creating conversation : verifierConversation:1.0:requestor_http://127.0.0.1:7001/Enabler1_0_972521242329...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_http://127.0.0.1:7001/Enabler1_0_972521242329
success
Shutting down session... done.

 

back to top previous page next page