Skip to content

Post_Outbound_Message

The Post_Outbound_Message procedures automatically create an application message with the supplied message body record or document attached as an XML document. Some versions of the method accept XML or JSON document as CLOB data instead of record/document. The XML and JSON documents are stored in a text column (CLOB). When the message is processed by the Plsql Access Provider, pre-routing is done placing the message in the proper queue. When the message is processed in the connect container the final routing is done.

These functions have been created specifically for the purpose of sending outbound messages asynchronously. Users should construct the message body as a document or XML or JSON that corresponds to its definition. Specifying sender, receiver, message_type and message_function is optional.

The post is done as a part of the current transaction. If a rollback occurs after a call to Post_Outbound_Message the posted message is also rolled back.

NOTE: Failure to find a queue for an in-order message will throw an exception rather then putting the message to the ERROR queue.

PROCEDURE Post_Outbound_Message (     
   message_body_             IN OUT <one of: type_record_ or Plsqlap_Document_API.Document>,  
   sender_                   IN VARCHAR2 DEFAULT NULL,  
   receiver_                 IN VARCHAR2 DEFAULT default_recevier_,  
   message_type_             IN VARCHAR2 DEFAULT default_media_code_,  
   message_function_         IN VARCHAR2 DEFAULT default_class_id_,  
   subject_                  IN VARCHAR2 DEFAULT NULL,  
   in_order_                 IN BOOLEAN DEFAULT FALSE,  
   rest_                     IN BOOLEAN DEFAULT FALSE,  
   parameters_               IN CLOB DEFAULT NULL );

PROCEDURE Post_Outbound_Message (     
   message_body_            IN OUT <one of: type_record_ or Plsqlap_Document_API.Document>,  
   message_id_              IN OUT NOCOPY NUMBER,  
   sender_                  IN VARCHAR2 DEFAULT NULL,  
   receiver_                IN VARCHAR2 DEFAULT default_recevier_,  
   message_type_            IN VARCHAR2 DEFAULT default_media_code_,  
   message_function_        IN VARCHAR2 DEFAULT default_class_id_,  
   subject_                 IN VARCHAR2 DEFAULT NULL,  
   in_order_                IN BOOLEAN DEFAULT FALSE,  
   rest_                    IN BOOLEAN DEFAULT FALSE,  
   parameters_              IN CLOB DEFAULT NULL );

PROCEDURE Post_Outbound_Message (  
   xml_                      IN CLOB,  
   sender_                   IN VARCHAR2 DEFAULT NULL,  
   receiver_                 IN VARCHAR2 DEFAULT default_recevier_,  
   message_type_             IN VARCHAR2 DEFAULT default_media_code_,  
   message_function_         IN VARCHAR2 DEFAULT default_class_id_,  
   subject_                  IN VARCHAR2 DEFAULT NULL,  
   external_message_id_      IN VARCHAR2 DEFAULT NULL,  
   in_order_                 IN BOOLEAN DEFAULT FALSE,  
   rest_                     IN BOOLEAN DEFAULT FALSE,  
   parameters_               IN CLOB DEFAULT NULL );

PROCEDURE Post_Outbound_Message (     
   xml_                      IN CLOB,  
   message_id_               IN OUT NOCOPY NUMBER,  
   sender_                   IN VARCHAR2 DEFAULT NULL,  
   receiver_                 IN VARCHAR2 DEFAULT default_recevier_,  
   message_type_             IN VARCHAR2 DEFAULT default_media_code_,  
   message_function_         IN VARCHAR2 DEFAULT default_class_id_,  
   subject_                  IN VARCHAR2 DEFAULT NULL,  
   external_message_id_      IN VARCHAR2 DEFAULT NULL,  
   in_order_                 IN BOOLEAN DEFAULT FALSE,  
   rest_                     IN BOOLEAN DEFAULT FALSE,  
   parameters_               IN CLOB DEFAULT NULL );  

PROCEDURE Post_Outbound_Message (  
   json                      IN OUT CLOB,  
   sender_                   IN     VARCHAR2 DEFAULT NULL,  
   receiver_                 IN     VARCHAR2 DEFAULT default_recevier_,  
   message_type_             IN     VARCHAR2 DEFAULT default_media_code_,  
   message_function_         IN     VARCHAR2 DEFAULT default_class_id_,  
   subject_                  IN     VARCHAR2 DEFAULT NULL,  
   external_message_id_      IN     VARCHAR2 DEFAULT NULL,  
   in_order_                 IN     BOOLEAN DEFAULT FALSE,  
   rest_                     IN     BOOLEAN DEFAULT FALSE,  
   parameters_               IN     CLOB DEFAULT NULL,
   is_json_                  IN     BOOLEAN);

PROCEDURE Post_Outbound_Message (     
   json                      IN OUT CLOB,  
   message_id_               IN OUT NOCOPY NUMBER,  
   sender_                   IN     VARCHAR2 DEFAULT NULL,  
   receiver_                 IN     VARCHAR2 DEFAULT default_recevier_,  
   message_type_             IN     VARCHAR2 DEFAULT default_media_code_,  
   message_function_         IN     VARCHAR2 DEFAULT default_class_id_,  
   subject_                  IN     VARCHAR2 DEFAULT NULL,  
   external_message_id_      IN     VARCHAR2 DEFAULT NULL,  
   in_order_                 IN     BOOLEAN DEFAULT FALSE,  
   rest_                     IN     BOOLEAN DEFAULT FALSE,  
   parameters_               IN     CLOB DEFAULT NULL,
   is_json_                  IN     BOOLEAN);  

Parameters

message_body_
    A Record or Document that corresponds to the entity definition. This record/document will automatically be converted to XML and attached as a binary body to the message before it is sent.

xml_
    An XML document that corresponds to the entity definition. The XML is attached as a binary body to the message before it is sent.

json
    A JSON structure that corresponds to its definition. The JSON is attached as a binary body to the message before it is sent.

sender_
    Optional identity of sending organization. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.SENDER.

receiver_
    Optional identity of receiving organization. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.RECEIVER.

message_type_
    Optional. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.MESSAGE_TYPE.

message_function_
    CURRENTLY NOT USED.

message_id_
    Returns the message id in the Middleware Server queue, FNDCN_APPLICATION_MESSAGE_TAB.APPLICATION_MESSAGE_ID.

subject_
    Optional subject. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.SUBJECT.

external_message_id_
    Optional reference to an external message. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.EXTERNAL_MESSAGE_ID.

in_order_
    Flag denoting if the message should be put to an InOrder queue. Default FALSE. If TRUE and it is not possible to find a queue or the found queue is not InOrder, an exception will be raised.

rest_
   A Flag denoting if the message is sent as a REST Outbound message via plsql_rest_sender_api.

parameters_
   If the message is REST outbound message some parameters has to be passed with the message to be used at the application side.

*is_json_

  • This should be set to TRUE when invoking methods used to send the data in JSON format

Record handling

Post_Outbound_Message will automatically issue a PLSQLAP_Record_API.Clear_Record procedure call removing the input record. If working with Documents (recommended) the cleaning is not required.

Example

DECLARE  
   appl_user_ PLSQLAP_Document_API.Document;  
BEGIN  
   -- create a document corresponding to the view  
   appl_user_ := PLSQLAP_Document_API.New_Document('APPLICATION_USER.APPLICATION_USER');  
   PLSQLAP_Document_API.Add_Attribute(appl_user_, 'APPLICATION_USER_ID', 'TESTID');  

   -- post the message to IFS Connect. A correct application message with the given document as XML body will  
   -- be created. The application message will then be routed according to configured message routing.  
   PLSQLAP_Server_API.Post_Outbound_Message(appl_user_);  
END;  
/  
COMMIT  
/
DECLARE  
   tf_ VARCHAR2(30) := 'yyyy-mm-dd-hh24.mi.ss';  
   id_ NUMBER := 1029;  
   xml_ XMLType;  
   CURSOR c_invoices (customer_id_ NUMBER) IS  
      SELECT xmlelement("TRN_CUSTOMER_INVOICES",  
                xmlelement("INVOICES",  
                   xmlagg(  
                      xmlelement("TRN_CUSTOMER_INVOICE",  
                         xmlelement("COMPANY_ID", a.company_id),  
                         xmlelement("BRANCH_ID", a.branch_id),  
                         xmlelement("CUSTOMER_ID", a.customer_id),  
                         xmlelement("INVOICE_ID", a.invoice_id),  
                         xmlelement("INVOICE_DATE", TO_CHAR(a.invoice_date,tf_)),  
                         xmlelement("DUE_DATE", TO_CHAR(a.due_date,tf_)),  
                         xmlelement("INVOICE_AMOUNT", a.invoice_amount),  
                         xmlelement("COMMENTS", a.comments),  
                         xmlelement("PAYMENT_TERMS", a.payment_terms),  
                         xmlelement("ORDER_ID", a.order_id),  
         (SELECT xmlelement("ITEMS",  
                    xmlagg(  
                       xmlelement("TRN_CUSTOMER_INVOICE_ITEM",  
                          xmlelement("ITEM_NO", b.item_no),  
                          xmlelement("DESCRIPTION",b.description),  
                          xmlelement("PRICE", b.price),  
                          xmlelement("QUANTITY", b.quantity),  
                          xmlelement("AMOUNT", b.amount),  
                          xmlelement("PRODUCT_ID", b.product_id) )))  
          FROM  trn_customer_invoice_item b  
          WHERE b.company_id = a.company_id  
            AND b.branch_id  = a.branch_id  
            AND b.invoice_id = a.invoice_id) )))) xml_data  
      FROM  trn_customer_invoice a  
      WHERE a.customer_id = customer_id_;  
BEGIN  
   FOR rec_ IN c_invoices(id_) LOOP  
      xml_ := rec_.xml_data;  
   END LOOP;  
   PLSQLAP_Server_API.Post_Outbound_Message(  
      xml_          => xml_.getClobVal(),  
      message_type_ => 'EVENT_BIZAPI');  
END;  
/  
COMMIT  
/