Use
Acknowledgments enable you to confirm that an asynchronous message has been received. You must explicitly request acknowledgments in the application program and can specify what kind of confirmation you want to receive.
- Positive or negative acknowledgments
- System acknowledgments used by the runtime environment to confirm that an asynchronous message has reached the receiver.
- Application acknowledgments used to confirm that the asynchronous message has been successfully processed at the receiver.
In the application program you can query and evaluate the status of an acknowledgment.
Prerequisites
The following receivers support acknowledgments:
- ABAP and Java proxies (XI 3.0 SP1 for the latter)
- Integration processes
- IDocs (note that IDocs only return acknowledgments when they have been configured using the ALE audit)
- Receiver adapters support system acknowledgments but not application acknowledgments
Features
Acknowledgment Types
To request acknowledgments you must set the corresponding fields in the PRX_ACK_REQUEST_DETAILS structure to X. The fields mean the following:
Details for Requesting Acknowledgements (Structure PRX_ACK_REQUEST_DETAILS)
You can set these fields individually. Furthermore, ABAP proxy runtime provides constants that you can use to make usual combinations of fields by means of a single assignment. The following table shows which fields you can set by using these constants.
Acknowledgment Constants of the Interface IF_WSPROTOCOL_ASYNC_MESSAGING
Querying and Evaluating Acknowledgments
Acknowledgment Methods of the Interface IF_WSPROTOCOL_ASYNC_MESSAGING
Querying the Acknowledgment Object
In the application program, you actively query the status of the acknowledgment by querying an acknowledgment object. You have the following options:
- If you can still access the client proxy instance, you can query an acknowledgment object in real-time by using the GET_ACKNOWLEDGMENTmethod.
- It is unlikely that you will still have access to the client proxy instance when you want to query the status of the acknowledgment. If this is the case, proceed as follows (also see the example below):
- After the proxy call, get the message ID of the message sent (see: Accessing the Message ID ).
- Using the message ID and the CL_PROXY_ACCESS=>GET_ACKNOWLEDGMENT( [Message ID] ) method you can get and evaluate the acknowledgment object.
Using the acknowledgment object you can query whether acknowledgments were received, and if so, which.
Evaluating the Acknowledgment Object
One message may have multiple acknowledgments for the following reasons:
- You have requested multiple acknowledgments for a single message. For example, if you have requested all acknowledgements and the message was processed and transferred successfully, a positive system acknowledgment (SYSTEM_OK) is sent before the positive application acknowledgment (APPLICATION_OK).
- If the sender message has multiple receivers in logical routing, the Integration Server copies the inbound message and sends a copy to each receiver (message branching). If the receiver requests acknowledgments for the message that the Integration Server has received, this request then applies for all new messages. These new messages can in turn trigger acknowledgments if multiple acknowledgments were requested for the original message.
To simplify the procedure for requesting acknowledgments, they are aggregated for each receiver. If a new acknowledgment renders an older one obsolete, the latter is 'overwritten' by the former. For example, when a positive application acknowledgment is received, it is clear that the receiver was reached successfully and therefore the positive system acknowledgment received previously is overwritten. The GET_STATUS_DETAIL method does not aggregate acknowledgments.
Acknowledgments are saved on the database. For the following three methods, you must set the READ_AGAIN parameter to read the current status from the database. To read a queried status again, do not set this parameter.
Acknowledgment Methods of the Interface IF_WS_ACKNOWLEDGMENT
Example
Requesting an Acknowledgment
Method sendWithACK.
DATA:
* Reference variables for proxy and exception class lo_clientProxy TYPE REF TO[Generated Proxy Class], lo_sys_exception TYPE REF TO cx_ai_system_fault, lo_async_messaging TYPE REF TO if_wsprotocol_async_messaging, lo_msg_id_protocol TYPE REF TO if_wsprotocol_message_id, l_msg_id TYPE SXMSGUID, l_ack_request TYPE PRX_ACK_REQUEST_DETAILS.
* Structures to set and get message content ls_request TYPE [Output Message Type],
TRY.
* create proxy client
CREATE OBJECT lo_clientProxy.
* get protocol for asynchronous messaging
lo_async_messaging ?= lo_clientProxy->get_protocol( if_wsprotocol=>async_messaging ).
* Ask for transport acknowledgment
clear l_ack_request. l_ack_request = IF_WSPROTOCOL_ASYNC_MESSAGING=>CO_TRANSPORT_ACKNOWLEDGMENT. lo_async_messaging->set_acknowledgment_requested( l_ack_request ).
* do asynchronous client proxy call
CALL METHOD lo_clientProxy->execute_asynchronous EXPORTING output = ls_request.
* get message id of sent message
lo_msg_id_protocol ?= lo_clientProxy->get_protocol( if_wsprotocol=>message_id ). l_msg_id = lo_msg_id_protocol->get_message_id( ).
* send message
COMMIT WORK.
CATCH cx_ai_system_fault INTO lo_sys_exception.
* Error handling
ENDTRY.
* Somehow pass the message ID to the caller for an evaluation* at a later point in time
Return lo_msg_id.
Endmethod.
Querying an Acknowledgment
You can query the acknowledgment object later by using the message ID:
Data:
lo_ack TYPE REF TO if_ws_acknowledgment,l_ack_status_simple type PRX_ACK_STATUS,l_ack_status_detail type PRX_ACK_STATUS_DETAIL_TABLE.
* read ack lo_ack = cl_proxy_access=>get_acknowledgment( l_msg_id ).l_ack_status_simple = lo_ack->get_status( ).l_ack_status_detail = lo_ack->get_status_detail( ).
Nenhum comentário:
Postar um comentário
Observação: somente um membro deste blog pode postar um comentário.