Code Monkey home page Code Monkey logo

esb-inbound-salesforce's Introduction

Salesforce EI Inbound Endpoint

The Salesforce streaming Inbound Endpoint allows you to perform various operations on Salesforce streaming data via WSO2 ESB.

  1. The Salesforce streaming API receives notifications based on the changes that happen to Salesforce data with respect to an SQQL (Salesforce Object Query Language) query you define, in a secured and scalable way. For more information, go to Salesforce streaming documentation.

  2. Platform events

Reliable message delivery is only available from the Salesforce API version 37.0 and above.

Compatibility

Inbound version Supported Salesforce API version Supported WSO2 ESB/EI version
2.0.1 22.0 EI 6.1.0, 6.2.0, 6.3.0, 6.4.0
2.0.0 22.0 EI 6.1.0, 6.2.0, 6.3.0, 6.4.0
1.0.0 22.0 ESB 5.00, EI 6.1.0, 6.1.1, 6.2.0, 6.3.0, 6.4.0

How to use

  1. Either download the inbound endpoit JAR file or build the project by executing the mvn clean install command to get the jar and by adding it in the /dropin directory.

  2. Create a Sequence to print the logs as follows.

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="test" onError="fault" xmlns="http://ws.apache.org/ns/synapse">
    <log level="full"/>
    <drop/>
</sequence>
  1. Create a Push Topic and then retrieve information or configure a Platform Event.

Building From the Source

Follow the steps given below to build the Salesforce EI Inbound Endpoint from the source code:

  1. Get a clone or download the source from Github.
  2. Run the following Maven command from the esb-inbound-salesforce directory: mvn clean install.
  3. The Salesforce inbound endpoint jar file is created in the esb-inbound-salesforce/target directory

Creating a Push Topic

First, create a custom object in Salesforce and then create a Push Topic that contains an SOQL query. Next, go to the Developer Console of your Salesforce account and click Debug->Open Execute Anonymous Window.. Then, add the following entry in the Enter Apex Code window.

PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'InvoiceStatementUpdates';
pushTopic.Query = 'SELECT Id, Name, wso2__Status__c, wso2__Description__c FROM InvoiceStatement__c';
pushTopic.ApiVersion = 37.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationUndelete = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;

Click Execute.

Retrieving account information

WSO2 ESB Salesforce Inbound Endpoint acts as a message consumer. It creates a connection to the Salesforce account, consumes the Salesforce data and injects the data to the ESB Sequence. Now, that you have configured the Salesforce streaming Inbound Endpoint, use the following ESB Inbound Endpoint configuration to retrieve account details from your Salesforce account.

<?xml version="1.0" encoding="UTF-8"?>
<inboundEndpoint xmlns="http://ws.apache.org/ns/synapse"
                 name="SaleforceInboundEP"
                 sequence="test"
                 onError="fault"
                 class="org.wso2.carbon.inbound.salesforce.poll.SalesforceStreamData"
                 suspend="false">
   <parameters>
      <parameter name="inbound.behavior">polling</parameter>
      <parameter name="interval">100</parameter>
      <parameter name="sequential">true</parameter>
      <parameter name="coordination">true</parameter>
      <parameter name="connection.salesforce.replay">false</parameter>
      <parameter name="connection.salesforce.EventIDStoredFilePath">/Users/nalaka/Desktop/a.txt</parameter>
      <parameter name="connection.salesforce.packageVersion">37.0</parameter>
      <parameter name="connection.salesforce.salesforceObject">/topic/InvoiceStatementUpdates</parameter>
      <parameter name="connection.salesforce.loginEndpoint">https://login.salesforce.com</parameter>
      <parameter name="connection.salesforce.userName">MyUsername</parameter>
      <parameter name="connection.salesforce.password">MyPassword</parameter>
      <parameter name="connection.salesforce.waitTime">5000</parameter>
      <parameter name="connection.salesforce.connectionTimeout">20000</parameter>
      <parameter name="connection.salesforce.soapApiVersion">22.0</parameter>
   </parameters>
</inboundEndpoint>
  • connection.salesforce.replay: replay enable or disable. Enabling this will read the event ID stored in the Registry DB or from the text file stored in the local machine.
  • connection.salesforce.EventIDStoredFilePath:
    • when replay is enabled, do not define any value for this property (i.e., keep it blank), to replay from the last event ID stored in the config Registry DB (property- name of the Salesforce object (follow the example below for more understanding) resource path - connector/salesforce/event).
    • when replay is enabled, specify the directory path of a text file to start replaying from the event ID stored in it.
    E.g., if the Salesforce object is `/topic/reading__e`, the property name is `reading__e`.
    In case of a failure, the default value will be used to retrieve IDs from current events. Create the property for each platform event and each pushtopic in the config Registry DB in the connector/salesforce/event resource path.
    
  • connection.salesforce.packageVersion: The version of the Salesforce API.
  • connection.salesforce.salesforceObject : The name of the Push Topic or the Platform Event that is added to the Salesforce account.
  • connection.salesforce.loginEndpoint: The Endpoint of the Salesforce account.
  • connection.salesforce.userName: The username for accessing the Salesforce account.
  • connection.salesforce.password: The password provided here is a concatenation of the user password and the security token provided by Salesforce. For more information, see[information on creating a security token in Salesforce].(https://help.salesforce.com/articleView?id=user_security_token.htm&type=5).
  • connection.salesforce.waitTime: The time to wait to connect to the Salesforce account(default : 5 * 1000 ms).
  • connection.salesforce.connectionTimeout: The time to wait to connect to the client(default : 20 * 1000 ms).
  • connection.salesforce.soapApiVersion: The version of the Salesforce SOAP API.

Platform Event

Define a Platform Event in the same way you define a custom object in Salesforce.

In the ESB configuration, specify the Event to which you need to subscribe.

<parameter name="connection.salesforce.salesforceObject">/event/InvoiceStatementReading1s__e</parameter>

Go to the Developer Console of your Salesforce account and click Debug->Open Execute Anonymous Window. Add the following entry in the Enter Apex Code window. For instructions, go to Publish Event Messages with Apex..

InvoiceStatementReading1s__e event = new InvoiceStatementReading1s__e(Status__c='nnn24');

// Publish event.
Database.SaveResult sr = EventBus.publish(event);

// Inspect publishing result for each event
if (sr.isSuccess()) {
    System.debug('Successfully published event.');
} else {
    for(Database.Error err : sr.getErrors()) {
        System.debug('Error returned: ' +
                    err.getStatusCode() +
                    ' - ' +
                    err.getMessage());
    }
}

Click Execute. The Event will be triggered in the ESB in real time.

To subscribe to multiple platform events or push topics, add the separate inbound endpoint to the corresponding sequences for push topics and platform events. Make sure to create a resource in the config registry DB for each object to store the event ID when you need to use the replay option.

Run tests

  1. Create pushtopic or platform event.
  2. Set properties in src/test/resources/Property.properties.
  3. Run "mvn test -Dskip-tests=false".

How to contribute

  • As an open source project, WSO2 extensions welcome contributions from the community.Check the issue tracker for open issues that interest you. We look forward to receiving your contributions.

esb-inbound-salesforce's People

Contributors

biruntha avatar chanikag avatar hmrajas avatar keerthu avatar kesavany avatar kirishikesan avatar maheshika avatar praneesha avatar sameeragunarathne avatar thusharasampath avatar wso2-jenkins-bot avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esb-inbound-salesforce's Issues

Outdated Connector Documentation

Description:

The salesforce inbound endpoint connector documentation is outdated. It is missing some critical information such as

  • connection.salesforce.packageVersion ->35->37
  • connection.salesforce.salesforceObject -> format changed(->/topic/)

Without these changes, the connector doesn't work.

Suggested Labels:

Suggested Assignees:

Affected Product Version:

OS, DB, other environment details and versions:

Steps to reproduce:

Related Issues:

Inbound salesforce version incompatability with wso2 integrator

Description:
I am using wso2 integrator 7.1.0 version. The salesforce inbound edpoint (org.apache.synapse.salesforce.poll.class-2.0.1.jar) listener is failing due to registry exception. Suspecting the version incompatability.

Suggested Labels:

Suggested Assignees:

Affected Product Version:

OS, DB, other environment details and versions:

Steps to reproduce:

  1. Create one integration project for sales force using WSO2 integration studio 7.1.0.
  2. Steps are available in this example link "https://ei.docs.wso2.com/en/7.2.0/micro-integrator/references/connectors/salesforce-connectors/sf-inbound-endpoint-example/"
  3. Start the server by exporting car file.
  4. When org.wso2.carbon.inbound.salesforce.poll.SalesforceStreamData is started error will be displayed.

Error
java.lang.ClassNotFoundException: org.wso2.carbon.registry.core.Registry cannot be found by org.apache.synapse.salesforce.poll.class_2.0.1_1.0.0
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:512)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:423)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:415)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:155)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)

Related Issues:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.