Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
bhalchandraswcg
Contributor

Previous – Message Store | Index | Next – Test Message


This week, we'll explore yet another system management pattern known as Smart Proxy.

When do I use this pattern?


Smart Proxy is used when we want to monitor the Request-Reply scenario. Especially, when the Return Address pattern is applied. The Smart Proxy receives the Request and changes the Return Address to itself so that it can monitor the response. When the response arrives, Smart Proxy sends the response back to the original Return Address once the monitoring steps are complete.

Smart Proxy in CPI


Unfortunately, I could not implement the pattern in CPI. This is what I tried.

Implementation Summary


The implementation for Smart Proxy uses the example from Return Address blog. However, instead of using the Microsoft Azure Service Bus, this blog will use SAP Enterprise Messaging.

The scenario in the Return Address blog is as follows. Customer Data is sent from a sender system. However, the sender system wants a response in a separate queue. So, the sender system sets the JMSReplyTo header. The processor of customer data puts the response in the queue specified by the JMSReplyTo header. Finally, the sender can process the response.

In the Smart Proxy, we'll intercept the first step, i.e., the request message is sent to Smart Proxy instead of directly to the queue. Smart Proxy will store the JMSReplyTo header in the Data Store with JMSCorrelationId as the Entry Id and overwrite the JMSReplyTo with its own address. In response, Smart Proxy will fetch the original message using JMSCorrelationId and put the message in the original queue specified by JMSReplyTo header.

1. Enqueueing the Customer



Enqueueing the Customer


This flow starts immediately using the Timer Start Event. Prepare Input Message Content Modifier sets the body. Set JMS Headers Content Modifier sets the JMSCorrelationId, JMSDestination, and JMSReplyTo headers. ProcessDirect Receiver Adapter will invoke the Smart Proxy flow.

Configuration of Set JMS Headers Content Modifier


The Headers tab has these entries.



































Action Name Type Data Type Value Default
Create JMSCorrelationId XPath String /Customer/Id
Create JMSDestination Constant queue:Customers
Create JMSReplyTo Constant queue:CustomerResponses

2. Smart Proxy - Processing the Request Messages



Processing the Request Messages


This flow simply accepts the request message using the ProcessDirect Sender Adapter. Puts it in the Data Store with Entry Id as JMSCorrelationId using Data Store Write Operation. Next, the Set JMS Headers Content Modifier will overwrite the JMSReplyTo header with 'queue:SmartProxy'. The AMQP Receiver Adapter will enqueue the message in the queue specified by JMSDestination header.

The headers JMSCorrelationId, JMSDestination, and JMSReplyTo are listed in the Allowed Header(s) under the Runtime Configuration tab.

Configuration of Data Store Write Operation









































Property Value
Data Store Name SmartProxy
Visibility Integration Flow
Entry ID ${header.JMSCorrelationId}
Retention Threshold for Alerting (in d) 2
Expiration Period (in d) 90
Encrypt Stored Message Unchecked
Overwrite Existing Message Unchecked
Include Message Headers Checked

Configuration of Set JMS Headers Content Modifier





















Action Name Type Data Type Value Default
Create JMSReplyTo Constant queue:SmartProxy

Configuration of the AMQP Receiver Adapter






































































Tab Property Value
Connection Host enterprise-messaging-messaging-gateway.cfapps.eu10.hana.ondemand.com
Connection Port 443
Connection Path /protocols/amqp10ws
Connection Proxy Type Internet
Connection Connect with TLS Checked
Connection Authentication OAuth2 Client Credentials
Connection Credential Name Enterprise Messaging
Processing Destination Type Queue
Processing Destination Name ${header.JMSDestination}
Processing Expiration Period (in s)
Processing Delivery Persistent
Processing Message Type Automatic

3. Processing the Customer



Processing the Customer


This flow receives the Customer data using AMQP Sender Adapter. For simplicity, we always set the body to Successful payload using Content Modifier. Finally, the AMQP Receiver Adapter will enqueue the response in the queue specified by JMSReplyTo header.

The headers JMSCorrelationId and JMSReplyTo are listed in the Allowed Header(s) under the Runtime Configuration tab.

Configuration of the AMQP Sender Adapter


The connection tab is exactly the same as that specified in section "2. Smart Proxy - Processing the Request Messages". The Processing tab is configured as follows:

































Tab Property Value
Processing Queue Name queue:Customers
Processing Number of Concurrent Processes 1
Processing Max. Number of Prefetched Messages 5
Processing Max. Number of Retries 0
Processing Delivery Status After Max. Retries REJECTED

Configuration of the AMQP Receiver Adapter


The configuration is exactly the same as that specified in section "2. Smart Proxy - Processing the Request Messages" except the Destination Name. Destination Name is set to ${header.JMSDestination}.













Tab Property Value
Processing Destination Name ${header.JMSDestination}

4. Smart Proxy - Processing the Response Messages



Processing the Response Messages


This flow consumes the messages from the SmartProxy queue using AMQP Sender Adapter. The message body is backed up to exchange property using a Content Modifier. Data Store Get Operation is used to restore the value of the original JMSReplyTo header. Next, the body is restored using another Content Modifier. Finally, AMQP Receiver Adapter enqueues the response message into queue specified by the JMSReplyTo header.

The headers JMSCorrelationId and JMSReplyTo are listed in the Allowed Header(s) under the Runtime Configuration tab.

Configuration of the AMQP Sender Adapter


The configuration is exactly the same as that specified in section 3. Processing the Customer except for the Queue Name. Queue Name is set to queue:SmartProxy.













Tab Property Value
Processing Queue Name queue:SmartProxy

Configuration of the Data Store Get Operation





























Property Value
Data Store Name SmartProxy
Visibility Integration Flow
Entry ID ${header.JMSCorrelationId}
Delete On Completion Checked
Throw Exception on Missing Entry Unchecked

Configuration of the AMQP Receiver Adapter


The configuration is exactly the same as that specified in section "2. Smart Proxy - Processing the Request Messages" except the Destination Name. Destination Name is set to ${header.JMSReplyTo}.













Tab Property Value
Processing Destination Name ${header.JMSReplyTo}

5. Processing the Customer Response



Processing the Customer Response


This flow simply consumes the responses using AMQP Sender Adapter and Logs the payload using the famous Log Groovy Script.

Configuration of the AMQP Sender Adapter


The configuration is exactly the same as that specified in section 3. Processing the Customer except for the Queue Name. Queue Name is set to queue:CustomerResponses.













Tab Property Value
Processing Queue Name queue:CustomerResponses

The Issue and Alternatives


The issue happens in step 3. The SAP Enterprise Messaging does not return the JMSCorrelationId header. As a result, step 4 does not receive the JMSCorrelationId and fails to restore the JMSReplyTo header.

Alternative 1: Use Standard JMS


The Standard JMS does not support dynamic Queue Name in JMS Receiver Adapter. As a result, step 2 could not be implemented. In turn, Smart Proxy cannot be implemented with Standard JMS.

Alternative 2: Test other providers supported by AMQP Adapter


Perhaps, Smart Proxy could be implemented with other providers supported by AMQP Adapter like Microsoft Azure Service Bus, Solace PubSub+, Apache Qpid Broker-J, Apache ActiveMQ 5 and ActiveMQ Artemis, IBM MQ, RabbitMQ.

Please comment below if you know how to resolve the issue or if you know if any of the alternatives work :).

EIPinCPI Rating


Unfortunately, I could not implement the Smart Proxy pattern. So, I would have to rate 0 out of 10 for this pattern.

Conclusion


Smart Proxy is used to monitor messages when Return Address pattern is used.

References/Further Readings



Hope this helps,
Bala

Previous – Message Store | Index | Next – Test Message

Labels in this area