For introduction to ABAP Channels please refer to Introduction to ABAP Channels.For tangible examples in the system see also the blog ABAP Channels Examples. See also FAQ - ABAP Channels.
This blog focuses on the collaboration scenario, i.e. using ABAP Push Channel (APC) and ABAP Messaging Channel (AMC) to push messages from ABAP sessions to WebSocket clients by binding publish/subscribe channels to a WebSocket connection.
For live demonstration and step-by-step implementation look at Collaboration Video.
Figure 2.0: Simple interaction model of collaboration scenario.
Figure 2.1 illustrates the technical interaction model for pushing messages between a WebSocket
In order to pass an event from an ABAP session to a WebSocket client and vice-versa the publish/subscribe infrastructure of the ABAP Messaging Channels is used. As in the figure 2.1 depicted the APC frame with the binding manager interface offers the possibility to bind an AMC channel to the underlying WebSocket connection to act as message consumer (receiver) for the corresponding channel. After a successful binding to an AMC channel, here <application>/<channel>, any messages published to the channel will
be forwarded by the AMC broker to the WebSocket client using corresponding WebSocket connection.
First, the APC application will be extended:
METHOD if_apc_ws_extension~on_start.
TRY.
* bind the WebSocket connection to the AMC channel
DATA(lo_binding) = i_context->get_binding_manager( ).
lo_binding->bind_amc_message_consumer( i_application_id = 'YAMC_TEST'
i_channel_id = '/ping' ).
CATCH cx_apc_error INTO DATA(lx_apc_error).
DATA(lv_message) = lx_apc_error->get_text( ).
MESSAGE lx_apc_error->get_text( ) TYPE 'E'.
ENDTRY.
ENDMETHOD.
METHOD if_apc_ws_extension~on_message.
DATA: lo_producer TYPE REF TO if_amc_message_producer_text.
TRY.
* retrieve the text message
DATA(lv_text) = i_message->get_text( ).
lo_producer ?= cl_amc_channel_manager=>create_message_producer(
i_application_id = 'YAMC_TEST'
i_channel_id = '/ping' ).
lo_producer->send( i_message = lv_text ).
CATCH cx_amc_error INTO DATA(lx_amc_error).
MESSAGE lx_amc_error->get_text( ) TYPE 'E'.
CATCH cx_apc_error INTO DATA(lx_apc_error).
MESSAGE lx_apc_error->get_text( ) TYPE 'E'.
ENDTRY.
ENDMETHOD.
Open the definition of application YAMC_TEST and click Insert line (see figure 3.1).
Figure 3.1
Open the value help in the Authorized Program field (see figure 3.2).
Figure 3.2
Insert the class YCL_APC_WS_EXT_YAPC_WS_TESTand click Accept (see figure 3.3).
Figure 3.3
Select the entry C Receive via APC WebSocket (see figure 3.4).
Figure 3.4
Insert additional line as above and select the entry S Send (see figure 3.5).
Figure 3.5
Optionally a Virus Scan ID (outgoing) can be specified (see figure 3.6).
Figure 3.6
Click Save (see figure 3.7).
Figure 3.7
And Activate. (see figure 3.8).
Figure 3.8
Click Continue .(see figure 3.9)..
Figure 3.9
To test the application just press the Test icon (see figure 3.10).
Figure 3.10
This action launches the Web Dynpro application WDR_TEST_APC in a browser (see figure 3.11) which supports the WebSocket protocol (RFC 6455) (e.g. Chrome version >= 16, Firefox version >= 11, Internet Explorer version >= 10 and Safari on iOS version >= 6). If it does not launch, double check the Web Dynpro service path /sap/bc/webdynpro/sap/wdr_test_apc" in the transaction SICF is active.
Figure 3.11
Just starts a second time the Web Dynpro test application for APC application YAMC_TEST in browser (see figure 3.12) .After a successful connection setup any messages send in a browser will be received also by the second browser.
Figure 3.12
Furthermore any report which apply any actions on the AMC application YAMC_TEST and channel “/ping” will be involved in the collaboration interaction. In other words the execution of the AMC send report YRS_AMC_SEND_MESSAGE (refer [2] figure 3.15) will lead to receiving the send message by the browser(see figure 3.13)
Figure 3.13
And the execution of the AMC receive report YRS_AMC_RECEIVE_MESSAGE (refer blog [2]figure 3.25) will lead to receiving the send message by the browser(see figure 3.14).
Figure 3.14
Figure 4.0
Figure 4.1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |