App Connect

App Connect

Join this online user group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Use App Connect Enterprise message flow to replace MQ Salesforce Bridge

By Kok Sing Khong posted Sun July 30, 2023 12:47 PM

  

This article is implementation to replace MQ Salesforce Bridge using App Connect Enterprise (ACE) Toolkit message flow. This is related to the first iteration of the topic where it is implemented using App Connect Designer event-driven flow (see here). The diagram below shows a high-level overview of the solution.

There are some prerequisites if you want to work on this solution.

  • Register for a Salesforce developer account
  • Red Hat Openshift (v4.12.x)
  • Cloud Pak for Integration installed (v2023.2.1)
  • App Connect dashboard installed (v12.0.8)
    • App Connect Enterprise Toolkit (v12.0.9) - following the instructions here.
  • MQ Queue manager installed (v9.3.3)

Configure the Salesforce and MQ environment

Refer to the previous article on how to do the following.

  1. Configure connection details to connect to Salesforce via OAuth
  2. Setup custom platform events and triggers
  3. Configure MQ queue manager

The following configurations are done on Eclipse-based ACE Toolkit.

Create MQ connection endpoint:

  1. Create a New Policy Project (e.g. SalesforceBridgePolicy)
  2. Create a New Policy for MQ (e.g. MQPolicy)
  3. Use the following settings (you can get this from your MQ queue manager configuration)
    1. Type: MQEndpoint
    2. Template. MQEndpoint
    3. Connection: CLIENT
    4. Queue manager name: SMALLQM
    5. Queue manager host name: smallqm-ibm-mq.mq.svc.cluster.local (this is the hostname of the Kubernetes service, assuming ACE integration server and MQ queue manager runs on the same OpenShift cluster)
    6. Listener port number: 1414
    7. Channel name: SMALLQMCHL_NOTLS
    8. Use SSL: false
    9. MQ application name: SalesforceBridge


Create the integration application and message flow:

  1. Create a New Application (e.g. SalesforceBridge).
  2. Create a New Message Flow (e.g. MF_SalesforceBridge).
  3. Drag the nodes and wiring according to the following diagram. You may omit the Trace nodes (it's for debugging).  

Configure Salesforce Input node:

  1. Click on the SalesforceInput node - and on the Properties > Basic tab, click the Launch Connector Discovery button. Then select the Policy Project you have just created previously and select Work directory for the Use an integration server vault. Specify the Vault Key.
  2. This will bring up the Connector Discovery wizard. Then click on Connect to Salesforce to see more items to find MQ platform events.
  3. Fill the connection details for Salesforce and click Connect button

  4. After it is connected, click on Configure more events ...
  5. Select MQ Event (Platform event) > New mq event.
  6. Finally, specify the Replay ID and click Save button. Close Discovery mode.

The Salesforce1.policyxml file is generated in the Policy Project and the properties of the Salesforce Input node are automatically populated.

Code Compute  Node:

The following is the code that mapped the input JSON message to output JSON message.

CREATE COMPUTE MODULE MF_SalesforceBridge_Compute
	CREATE FUNCTION Main() RETURNS BOOLEAN
	BEGIN
		CALL CopyMessageHeaders();
	 	SET OutputRoot.Properties.MessageFormat = 'Text1';
		CREATE LASTCHILD OF OutputRoot DOMAIN 'JSON';
		CREATE FIELD OutputRoot.JSON.Data IDENTITY(JSON.Object)Data;
		DECLARE refIn REFERENCE TO InputRoot.JSON.Data;
		DECLARE refOut REFERENCE TO OutputRoot.JSON.Data;
		SET refOut.ReplayId = refIn.ReplayId;
		SET refOut.CreatedDate = refIn.CreatedDate;
		SET refOut.CreatedById = refIn.CreatedById;
		SET refOut.Name = refIn.Name__c;
		SET refOut.Phone = refIn.Phone__c;
		RETURN TRUE;
	END;

	CREATE PROCEDURE CopyMessageHeaders() BEGIN
		DECLARE I INTEGER 1;
		DECLARE J INTEGER;
		SET J = CARDINALITY(InputRoot.*[]);
		WHILE I < J DO
			SET OutputRoot.*[I] = InputRoot.*[I];
			SET I = I + 1;
		END WHILE;
	END;

	CREATE PROCEDURE CopyEntireMessage() BEGIN
		SET OutputRoot = InputRoot;
	END;
END MODULE;

Configure MQ Output node:

  1. In the Properties > Basic tab, specify the Queue name (e.g. APPQ).

  2. In the Properties > Policy tab, specify the Policy with the one you defined previously (e.g. {SalesforceBridgePolicy}:MQPolicy)

Note: You can find the source code here (https://github.com/khongks/salesforce-bridge-toolkit)

Deploy artefacts to ACE integration server.

  1. Create a BAR that includes the Application SalesforceBridge.
  2. Create a ZIP file of the Policy Project SalesforcePolicy.
  3. Find the vault folder (e.g. /Users/<user>/IBM/ACET12/vault/config/vault), and ZIP up the folder.
  4. Go to the ACE dashboard and upload the BAR file.
  5. Also create the configurations for the Policy Project, Vault and Vault Key.
  6. Finally, deploy the Integration Server using the BAR file and the 3 configurations.
0 comments
20 views

Permalink