<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: kaul-vineet</title>
    <description>The latest articles on DEV Community by kaul-vineet (@kaulvineet).</description>
    <link>https://dev.to/kaulvineet</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F514498%2Fd533a915-b14f-4579-8377-9f996d4211ca.jpeg</url>
      <title>DEV Community: kaul-vineet</title>
      <link>https://dev.to/kaulvineet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kaulvineet"/>
    <language>en</language>
    <item>
      <title>Crypto Exchange: Supercharge customer apps with streaming data.</title>
      <dc:creator>kaul-vineet</dc:creator>
      <pubDate>Wed, 25 Nov 2020 07:53:30 +0000</pubDate>
      <link>https://dev.to/kaulvineet/crypto-exchange-supercharge-customer-apps-with-streaming-data-40bd</link>
      <guid>https://dev.to/kaulvineet/crypto-exchange-supercharge-customer-apps-with-streaming-data-40bd</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Team: Vineet Kaul, Ajay Kumar&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  What are we talking about?
&lt;/h1&gt;

&lt;p&gt;We are talking about streams. Streams of data originating from applications, social media, sensors, devices, websites, blah, blah, blah. The great book of &lt;a href="https://en.wikipedia.org/wiki/Streaming_data"&gt;Wikipedia&lt;/a&gt; describes streaming data as &lt;em&gt;...data that is continuously generated by different sources&lt;/em&gt;. Streaming data is ubiquitous and if you've never seen it in action, think again...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sensors in transportation vehicles, industrial equipment, and farm machinery.&lt;/li&gt;
&lt;li&gt;Stock market data, portfolios, and value-at-risk calculation in real-time.&lt;/li&gt;
&lt;li&gt;Clickstream records from digital content.&lt;/li&gt;
&lt;li&gt;Data about player-game interactions in online gaming.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All this sounds interesting, but managing streaming data does not come without its fair share of challenges. Broadly speaking,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Processing: Streaming data requires real-time data pipelines for managing the flow; correlations, aggregations, filtering, and sampling. &lt;/li&gt;
&lt;li&gt;Storage: Business requires a view to the data, aggregated or over sliding time windows. But it is commercially prohibitive to store everything as the growth is algorithmic. &lt;/li&gt;
&lt;li&gt;Display: Business needs an aggregated window view but it can't be saved, so how to view it? Hence a need for a dynamic unified interface to give a view window on data.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Houston, do we have a problem?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Not exactly. There is a way to supercharge customer apps with streaming data by using the technology components that take care of the underlying complexities so developers can manage on delivering value to the business. &lt;/p&gt;

&lt;h1&gt;
  
  
  Business use case:
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Personae:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Art Vandalay&lt;/strong&gt; is an investor with interests in cryptocurrency trading. Art trades on various crypto exchanges across various cryptocurrencies. Art is also a customer of &lt;strong&gt;Chemical Bank&lt;/strong&gt; and would prefer if his banking app would help him track cryptocurrency exchange rates. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chemical Bank&lt;/strong&gt; is just about to that with their app &lt;strong&gt;Crypto Exchange&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cryptocurrency trade basics:
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://www.investopedia.com/terms/c/currencypair.asp"&gt;Source: Investopedia&lt;/a&gt;&lt;/em&gt;&lt;br&gt;
Trading cryptocurrencies requires a currency pair. In other words, the value of one currency being quoted against the other. The first listed currency of a currency pair is called the &lt;strong&gt;base currency&lt;/strong&gt;, and the second currency is called the &lt;strong&gt;quote currency&lt;/strong&gt;. It indicates how much of the quote currency is needed to purchase one unit of the base currency. Currencies are identified by an ISO currency code. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z_M--EUt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jv9pn33qylcspl4d9w1h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z_M--EUt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jv9pn33qylcspl4d9w1h.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The trading rates of cryptocurrencies change in real-time. To develop &lt;strong&gt;Crypto Exchange&lt;/strong&gt;, &lt;strong&gt;Chemical Bank&lt;/strong&gt; would need to hook up to an exchange, ingest &lt;em&gt;streaming data&lt;/em&gt; on exchange rates of hundreds of pairs, and display it in a dynamic unified interface for Mr. Vandalay's trading pleasure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chemical Bank&lt;/strong&gt; is going to do just that using &lt;strong&gt;Salesforce technology stack&lt;/strong&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  Architecture:
&lt;/h1&gt;

&lt;p&gt;The solution takes &lt;a href="https://coincap.io"&gt;CoinCap&lt;/a&gt; as a source of cryptocurrency trading data. Why? Just convenient. It could be any of many data sources over the internet streaming exchange data. &lt;/p&gt;
&lt;h3&gt;
  
  
  Commentary:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CmXV6HqS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xcjlv2a8nf3x7g48q3wt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CmXV6HqS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xcjlv2a8nf3x7g48q3wt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mulesfot WebSockets Connector&lt;/strong&gt; connects to the CoinCap WebSocket. The CoinCap trade WebSocket streams exchange rate data from other cryptocurrency exchange WebSockets. Because the system is designing for streaming data and not API callouts, Mulesoft WebSockets Connector opes &amp;amp; maintains the TCP connection between a client (Crypto Exchange) and server (CoinCap) until the app closes it. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The streaming data from any source could be overwhelming. Downstream systems might not be able to process or store data at a very high rate. The design alternative is to aggregate or throttle the data as long as it does not affect the business use case. &lt;strong&gt;Mulesoft Aggregators Module&lt;/strong&gt; stores the exchange values and releases the most recent message based on the configuration (count or time). As long as the lag is acceptable, the downstream flow could be optimized. Remember, Mr. Vandalay just wants to &lt;em&gt;track cryptocurrency exchange rates&lt;/em&gt;, and not trade through the app. The current strategy does not implement aggregation in principle but throttling. That said, the same strategy could be used to implement other use cases that require aggregation e.g. calculating the mean of exchange rates over a time duration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Post-processing, Mulesoft sends the data for display to downstream app i.e. Crypto Exchange. As there is neither need nor technical feasibility to store data, the app would graphically display the exchange data. Mulesoft sends a Salesforce platform event to the app that is subscribed to by the UI components. The &lt;strong&gt;lightning:empApi&lt;/strong&gt; component receives the event and displays it on Chart.js graphs. The use of Salesforce Platform events simplifies communication by decoupling event producers from aggregator and subscriber. In addition, it is possible for multiple apps to subscribe to a single solution.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And in three simple steps, we have an end to end flow that connects to a crypto exchange and displays data on a customer app.&lt;/p&gt;
&lt;h3&gt;
  
  
  Mulesoft:
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The Listener&lt;/strong&gt;: &lt;em&gt;On New Inbound Message&lt;/em&gt; listens to the connection requests and calls the flow to open the connection through &lt;em&gt;Open outbound socket&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PxC4qOlC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wxuogq65stpwjp0xprtr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PxC4qOlC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wxuogq65stpwjp0xprtr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The Aggregator&lt;/strong&gt;: &lt;em&gt;Group based aggregator&lt;/em&gt; collects the exchange rates based on a combination of base and quote currencies and releases the latest rate every "x" messages (where "x" could be any suitable batch size). This scheme is called &lt;em&gt;Size-based aggregation&lt;/em&gt;. Similar to the approach, &lt;em&gt;Time-based aggregation&lt;/em&gt; could be designed as well. &lt;/p&gt;

&lt;p&gt;Once again, this is done to throttle the message stream so as to make it easier for downstream systems to ingest and process the exchange rate messages. Mulesoft orchestration imposes a sliding window on the data stream of which on one and the latest message is sent downstream. This chunking of data enables the architecture to accommodate customer-facing applications that are either not designed for streaming data or have platform governance limitations.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fZMRrBqE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l39tc60tjq3e1cqf4i44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fZMRrBqE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l39tc60tjq3e1cqf4i44.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A single pair message:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;{exchange=binance, base=litecoin, quote=tether, direction=buy, price=68.03, volume=12.82018, timestamp=1606478960197, priceUsd=68.14666514408307}&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Aggregated message for throttle. Only the latest message in a time/count window would be passed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[TypedValue[value: '{exchange=binance, base=litecoin, quote=tether, direction=buy, price=67.65, volume=1.16843, timestamp=1606479662239, priceUsd=67.75263835061388}', dataType: 'MapDataType{type=java.util.LinkedHashMap, keyType=SimpleDataType{type=java.lang.Object, mimeType='&lt;/em&gt;/&lt;em&gt;'}, valueType=SimpleDataType{type=java.lang.Object, mimeType='&lt;/em&gt;/&lt;em&gt;'}, mimeType='application/java; charset=UTF-8'}']]&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pnwm8O4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/esedcalpbw7l5t1hct0o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pnwm8O4L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/esedcalpbw7l5t1hct0o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The Publisher&lt;/strong&gt;: Once the throttled messages are released, &lt;em&gt;Salesforce connector&lt;/em&gt; publishes a Salesforce platform event to the connected Org. A custom platform event definition is described in the connected Org. &lt;br&gt;
Platform events are built for handling streaming data. Platform events also allow for the processing and display of data without storing the data and hence avoiding costly DB operations. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WpGkk4E4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/73602ioq57a545psx5rz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WpGkk4E4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/73602ioq57a545psx5rz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Salesforce:
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The Consumer&lt;/strong&gt;: Display of data on dynamic graphs requires the UI component to receive the published messages. This is implemented by the &lt;em&gt;lightning:empApi&lt;/em&gt; component that provides access to methods for subscribing to a streaming channel and listening to event messages. The lightning:empApi component uses a shared CometD connection, enabling dynamic display of streaming data on UI components. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xuRcwHb_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/omn5v36prp61gt8qsu43.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xuRcwHb_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/omn5v36prp61gt8qsu43.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Watch it work:
&lt;/h1&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/NygRJOKnCHA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Can I get you the code? Yeah, sure.
&lt;/h1&gt;

&lt;p&gt;So, you are not faint-hearted. Fair enough. We have published the code and full setup-up and test instructions on GitHub. Follow the lead. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For the Salesforce app code and detailed instructions to set up and test the hack, refer to the repo below. This covers the full hack i.e. Salesforce &amp;amp; Mulesoft part.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kaul-vineet"&gt;
        kaul-vineet
      &lt;/a&gt; / &lt;a href="https://github.com/kaul-vineet/StreamingCurrency-sf"&gt;
        StreamingCurrency-sf
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Crypto Exchange&lt;/h1&gt;
&lt;h2&gt;
How to integrate you Salesforce application with streaming data from Crypto Exchange.&lt;/h2&gt;
&lt;h2&gt;
Part 1: Setup the Salesforce Org.&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Click on the button below to install the DriveSafe application package. The Salesforce Org should be Enterprise and above.&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="https://githubsfdeploy.herokuapp.com?owner=kaul-vineet&amp;amp;repo=StreamingCurrency-sf" rel="nofollow"&gt;
  &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4GZhIWUM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/src/main/webapp/resources/img/deploy.png" alt="Deploy to Salesforce"&gt;
&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;Import seed data into the Org
&lt;ul&gt;
&lt;li&gt;Use the &lt;a href="https://github.com/kaul-vineet/StreamingCurrency-sf/blob/master/data/Trade_Asset__c-plan.json"&gt; plan file &lt;/a&gt; and &lt;a href="https://github.com/kaul-vineet/StreamingCurrency-sf/blob/master/data/Trade_Asset__cs.json"&gt; data file &lt;/a&gt; to load data into Trade_Asset__c object in the Org. Use the sf:dx command to import data:&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;sfdx force:data:tree:import -p data/Trade_Asset__c-plan.json -u &amp;lt;Org Alias&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Another alternative is to convert data file to CSV and upload the Trade_Asset__c.Name field by using DataLoader, Workbench or your favorite data management tool&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open Salesforce1 app and go to App Launcher.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/kaul-vineet/StreamingCurrency-sf/blob/master/images/24899C74-328D-48E5-8C55-F756E1AAFD3E.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YhjnRYPD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/kaul-vineet/StreamingCurrency-sf/raw/master/images/24899C74-328D-48E5-8C55-F756E1AAFD3E.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Search and select &lt;strong&gt;Crypto Exchange&lt;/strong&gt; app.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/kaul-vineet/StreamingCurrency-sf/blob/master/images/BB7369D3-5BFA-4D26-8C39-44381A01DBA6.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XpLEUpya--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/kaul-vineet/StreamingCurrency-sf/raw/master/images/BB7369D3-5BFA-4D26-8C39-44381A01DBA6.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to &lt;strong&gt;trades&lt;/strong&gt; and click on the &lt;strong&gt;New&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/kaul-vineet/StreamingCurrency-sf/blob/master/images/9E495286-E6D0-4CC0-A644-21047D83B442.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--06FASrWE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/kaul-vineet/StreamingCurrency-sf/raw/master/images/9E495286-E6D0-4CC0-A644-21047D83B442.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A form appears for adding a new trade. Select the &lt;strong&gt;Base Asset&lt;/strong&gt; and &lt;strong&gt;Quote Asset&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/kaul-vineet/StreamingCurrency-sf/blob/master/images/35B622F5-0E3E-4E76-ABD4-C53BDA03851E.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6PTkZHvW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/kaul-vineet/StreamingCurrency-sf/raw/master/images/35B622F5-0E3E-4E76-ABD4-C53BDA03851E.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If Trade_Asset__c data has been properly uploaded, options would appear.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/kaul-vineet/StreamingCurrency-sf/blob/master/images/5CDE6986-8C59-4E17-9256-A3C112BD8F0A.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HHZbuwq9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/kaul-vineet/StreamingCurrency-sf/raw/master/images/5CDE6986-8C59-4E17-9256-A3C112BD8F0A.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Any possible…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/kaul-vineet/StreamingCurrency-sf"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;If you are interested in the Mulesoft project, refer to the repo below.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kaul-vineet"&gt;
        kaul-vineet
      &lt;/a&gt; / &lt;a href="https://github.com/kaul-vineet/StreamingCurrency-mule"&gt;
        StreamingCurrency-mule
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
StreamingCurrency-mule&lt;/h1&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/kaul-vineet/StreamingCurrency-mule"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;&lt;strong&gt;Have fun trying out the hack and do let us know if you face issues or general feedback.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>mulesofthackathon</category>
      <category>techtalks</category>
      <category>analytics</category>
    </item>
    <item>
      <title>🚖 DriveSafe: An IoT use case for auto industry 🚖 </title>
      <dc:creator>kaul-vineet</dc:creator>
      <pubDate>Mon, 23 Nov 2020 10:52:25 +0000</pubDate>
      <link>https://dev.to/kaulvineet/drivesafe-an-iot-use-case-for-auto-industry-44f3</link>
      <guid>https://dev.to/kaulvineet/drivesafe-an-iot-use-case-for-auto-industry-44f3</guid>
      <description>&lt;p&gt;📟📟 COLLECT BUSINESS INTELLIGENCE FROM PHONE OR ANY IoT ENABLED DEVICE LEVERAGING SALESFORCE PLATFORM. 📟📟&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Team: Vineet Kaul, Ajay Kumar, Alekhya&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;IoT Is Mainstream.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;All technology professionals are increasingly being inundated with customer requirements to connect devices to CRM and/or customer engagement solutions. It is not just important to connect devices with CE systems, but the systems should ingest the streaming data and produce actionable insights into business behavior. IoT today is no longer technology, but a business problem and requires a business-centric solution. Today, companies use IoT data for operational performance in internal silos. &lt;/p&gt;

&lt;p&gt;While the goals are simple, orchestrating such a system is could be an architectural mix of multiple technologies. By using the Salesforce technology stack, architects can design and deliver a seamless system that translates IoT data streams to data intelligence driving business decisions.&lt;/p&gt;

&lt;p&gt;One way to accomplish this That is what we have tried to achieve in this submission. &lt;/p&gt;

&lt;p&gt;The post takes two business scenarios and provides a detailed description of one of the many technology solutions to address them. For the more adventurous readers, it provides a description of code (GitHub repository included) and a self assist guide to implement a technology demonstrator on their own.  &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Uses In The CRM Industry.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;🚑 &lt;em&gt;Emergency Services:&lt;/em&gt; Track sudden change in altitudes of cars outside of safe envelop to detect accidents.&lt;/p&gt;

&lt;p&gt;🚫 &lt;em&gt;Insurance:&lt;/em&gt; Track driving behavior to determine insurance claims and renewal benefits.&lt;/p&gt;

&lt;p&gt;📢 &lt;em&gt;Marketing:&lt;/em&gt; Track gradual changes in altitude to send contextual notifications.&lt;/p&gt;

&lt;p&gt;🚙 &lt;em&gt;Automotive:&lt;/em&gt; Track vehicle acceleration, orientation to determine service plan.&lt;/p&gt;

&lt;p&gt;And other amazing things you can think of !!!!!!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Business Scenarios&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Usecase # 1&lt;/em&gt;:  The same insurance company provides value-added services like emergency assistance and pick up to its insurance holders. The errant drivers for one would certainly need it.  &lt;/p&gt;

&lt;p&gt;In case of an emergency, the customer engagement application would track beacon messages from IoT-enabled devices to get the real-time location (static or kinetic) of the vehicle. While the application gets the immediate coordinates of the distressed vehicle(static), it also tracks the beacons of the moving vehicle. A combination of these could be used for emergency response or guiding drivers to the nearest workshop or gas station. And yes, you've read it right, everything is real-time. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xAzKMR7Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h5nfn1ol0dzs8jxry649.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xAzKMR7Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h5nfn1ol0dzs8jxry649.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Usecase # 2&lt;/em&gt;:  An insurance company wants to link premium with driving behavior. It provides its customers with a device or mobile-based app that is kept on while driving. The solution pings sensor output (linear X velocity) to the insurance application. &lt;/p&gt;

&lt;p&gt;If the speed exceeds a threshold value (let's say 20 miles/hr), the platform event engine automatically creates a "Violation" record with violation details i.e. excess speed, location, etc (yes, everything is real-time). The violation is attached to the customer policy record and each violation results in an additional surcharge at the time of policy renewal. Or in other words, no violation means no surcharge and less costly insurance renewal.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Technology &amp;amp; Architecture.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mW7YeopS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o9eii4o3dob05iclczjf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mW7YeopS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o9eii4o3dob05iclczjf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While it looks like complex architecture, with Salesforce technology stack, this could be orchestrated with &lt;strong&gt;clicks not code.&lt;/strong&gt; Below, we describe the moving parts of the solution in detail. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MOBILE:&lt;/strong&gt; &lt;br&gt;
A simple app is required that sends a stream of sensor values as the customer is driving. &lt;em&gt;MQTT&lt;/em&gt; is the best protocol for sending lightweight messages from a mobile device. In real life scenario, mobile could be replaced with an in-car appliance, satellite tracker, or anything that has a battery and connects to the net. In the solution, we transmit a stream of linear X velocity of the mobile phone to simulate vehicle speed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HEROKU:&lt;/strong&gt;&lt;br&gt;
*CloudMQTT: The streams of sensor pings require a broker. This is provided by CloudMQTT, a Heroku based message broker. The broker receives the message stream that any customer based system can subscribe to. Such a pub-sub architecture has the following advantages&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It de-couples the devices with customer engagement systems. Any new system can just plug into the stream rather than being hard-wired to it.&lt;/li&gt;
&lt;li&gt;It allows message streams to be published under different topics e.g. speed, tilt, acceleration, etc. In the case of multiple systems, each customer engagement system could subscribe to the topic based on its business requirements.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yXTp4xVT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/09cvlqv32k8d0n3qtk3c.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Node-RED + MULESOFT&lt;/strong&gt; &lt;br&gt;
Once the MQTT broker receives a message, it is to be consumed and routed. This is termed as &lt;strong&gt;IoT orchestration&lt;/strong&gt;. A combination of &lt;br&gt;
Node-RED &amp;amp; Mulesoft flow forms the ESB backbone that does the following: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node-RED: Integrates with the MQTT broker and collects the message stream. It throttles the message stream to ensure that downstream systems are not overwhelmed by the &lt;em&gt;data overflows&lt;/em&gt;. Many customer engagement systems have data ingestion limits and strategies like throttling ensure downstream stability. There is no business sense as well to create multiple violation records for the same speeding instance, is it? Node-RED also strips the complex JSON message and creates a simpler message with limited values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ULGGQuxy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6hfdkbcrvy8n9izh4b9o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ULGGQuxy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6hfdkbcrvy8n9izh4b9o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mulesoft: Works as a messaging glue between the message stream and the subscriber systems. Mulesoft is the ESB backbone that publishes the message stream as a &lt;strong&gt;Salesforce platform event&lt;/strong&gt; (we assume for this solution that our customer engagement platform is built on Salesforce). Multiple Salesforce Orgs can subscribe to the message and use it for their individual business logic. Mulesoft provides an inbuilt connector that publishes custom or generic platform events described in Salesforce. The advantages of an event-based approach are&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Events order of delivery for a specific channel is guaranteed.&lt;/li&gt;
&lt;li&gt;Event subscribers can be defined and integrated with the platform business logic through clicks not code.&lt;/li&gt;
&lt;li&gt;Platform Events are non-transactional thereby resulting in no database overhead (an important factor for multi-tenant systems) and have &lt;strong&gt;high volume&lt;/strong&gt; support. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ztZuuKx0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a3ncr3pca81m3i4dzx6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ztZuuKx0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a3ncr3pca81m3i4dzx6u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SALESFORCE PLATFORM:&lt;/strong&gt; &lt;br&gt;
&lt;em&gt;(we assume for this solution that our customer engagement platform is built on Salesforce)&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Usecase #1: Everything revolves around the subscription of platform events published by Mulesoft. For this use case, an &lt;em&gt;empApi&lt;/em&gt; aura component displays the real-time message stream from Mulesoft. The component dynamically sets the map markers on receipt of each platform event thereby dynamically tracking the message source. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Usecase #2: Salesforce &lt;em&gt;Flow&lt;/em&gt; subscribes to the specified platform event published by Mulesoft. When a platform event message with sensor event is received, the flow orchestrates and implements the business process i.e. check the speed value and create a "violation" record.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dUKJkqoy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mtg0xewaqanf5b2jox3z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dUKJkqoy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mtg0xewaqanf5b2jox3z.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Watch the demonstration (Usecase # 1).&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/RCd4t4Znz8c"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Watch the demonstration (Usecase # 2).&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/aplQDD1iX9k"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Want to give it a test drive?.&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Complete installation and demo steps are documented in the README.md of repository &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kaul-vineet"&gt;
        kaul-vineet
      &lt;/a&gt; / &lt;a href="https://github.com/kaul-vineet/DriveSafe"&gt;
        DriveSafe
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
DriveSafe: An IoT use case for auto industry.&lt;/h1&gt;
&lt;h2&gt;
Built and orchestrated on Salesforce platform.&lt;/h2&gt;
&lt;p&gt;All technology professionals are increasingly being inundated with customer requirements to connect devices to CRM and/or customer engagement solutions. It is not just important to connect devices with CE systems, but the systems should ingest the streaming data and produce actionable insights into business behavior. IoT today is no longer technology, but a business problem and requires a business-centric solution. Today, companies use IoT data for operational performance in internal silos.&lt;/p&gt;
&lt;p&gt;That is what we have tried to achieve in this submission.&lt;/p&gt;
&lt;h3&gt;
There are 4 parts to the setup, fron setup to test. They might look complicated but everything is point &amp;amp; click configuration.&lt;/h3&gt;
&lt;h2&gt;
Step 1: Deploy Salesforce application.&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Click on the button below to install the DriveSafe application package. The Salesforce Org should be Enterprise and above.&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="https://githubsfdeploy.herokuapp.com?owner=kaul-vineet&amp;amp;repo=DriveSafe" rel="nofollow"&gt;
  &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4GZhIWUM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/src/main/webapp/resources/img/deploy.png" alt="Deploy SriveSafe to Salesforce"&gt;
&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;On successful completion of the deployment, log-in into…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/kaul-vineet/DriveSafe"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A separate repository for Mulesoft flow could be referenced (&lt;em&gt;this repository is not required for setup&lt;/em&gt;) at &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kaul-vineet"&gt;
        kaul-vineet
      &lt;/a&gt; / &lt;a href="https://github.com/kaul-vineet/DriveSafe-mule"&gt;
        DriveSafe-mule
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;
 &lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are 4 parts to the setup, fron setup to test. They might look complicated but everything is point &amp;amp; click configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In case of trouble, post a comment on GitHub or this post.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Design Considerations:&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As discussed in the architecture explanation, Platform Events are not unlimited. Even the High Volume Platform Events are governed by daily limits. For use cases where the message stream volume is very high, follow strategies that would limit the production &amp;amp; consumption of events and events.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Use throttle while delivering IoT events:&lt;/em&gt; Process each message in the message stream at a fixed rate. This rate could be based on the volume, size, or time. &lt;strong&gt;We have followed this strategy in this solution.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Use Report By Exception strategy:&lt;/em&gt; Block messages unless its value has changed.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>mulesofthackathon</category>
      <category>techtalks</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
