I am creating a flow that is issuing twitter search request, looping through each tweet, and pushing to a target connector (file, jdbc, etc). There are properties such as the user.screenName, text, and id that I would like to use in more than one step in the flow. Without DataWeave, my initial reaction would be to use a Message Properties transformation step to set flowVars.
So my question is that for the following Json payload, is there a more elegant way in DataWeave to set a flowVar so that I can leverage the variable throughout the scope of the flow? Or should I continue to leverage the Message Properties transformation step to set flowVars?
Twitter Response JSON:
{
"sinceId": 0,
"maxId": 677174121147604994,
"refreshUrl": "?since_id=677174121147604994&q=%23MuleSoft&include_entities=1",
"count": 1,
"completedIn": 0.034,
"query": "#MuleSoft",
"tweets": [
{
"createdAt": 1450285866000,
"id": 677174121147604994,
"text": "Connectivity Benchmark Report | New opportunities in #DigitalEra #MuleSoft https://t.co/bmHKJAkTy1",
"source": "<a href=\"http://www.hootsuite.com\" rel=\"nofollow\">Hootsuite</a>",
"inReplyToStatusId": -1,
"inReplyToUserId": -1,
"inReplyToScreenName": null,
"geoLocation": null,
"place": null,
"retweetCount": 0,
"retweetedStatus": null,
"userMentionEntities": [],
"hashtagEntities": [
{
"start": 53,
"end": 64,
"text": "DigitalEra"
},
{
"start": 65,
"end": 74,
"text": "MuleSoft"
}
],
"mediaEntities": [],
"currentUserRetweetId": -1,
"user": {
"id": 228823277,
"name": "Nitor Group Ltd.",
"screenName": "nitorgroup",
"location": "Washington, DC",
"description": "Connecting the whole world of healthcare with standards-based solutions. #Direct #SecureMessaging #HealthBus #Interoperability #MovingMedicalRecords #HealthIT",
"descriptionURLEntities": [],
"profileImageUrlHttps": "https://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128_normal.jpg",
"url": "http://t.co/FTsfFWQcsw",
"followersCount": 364,
"status": null,
"profileBackgroundColor": "1A1B1F",
"profileTextColor": "666666",
"profileLinkColor": "F19E4F",
"profileSidebarFillColor": "333333",
"profileSidebarBorderColor": "000000",
"profileUseBackgroundImage": true,
"showAllInlineMedia": false,
"friendsCount": 1371,
"createdAt": 1292873952000,
"favouritesCount": 2,
"utcOffset": -18000,
"timeZone": "Eastern Time (US & Canada)",
"profileBackgroundImageUrl": "http://pbs.twimg.com/profile_background_images/323688620/nitor_twitter_bkgd.jpg",
"profileBackgroundImageUrlHttps": "https://pbs.twimg.com/profile_background_images/323688620/nitor_twitter_bkgd.jpg",
"profileBackgroundTiled": false,
"lang": "en",
"statusesCount": 305,
"translator": false,
"listedCount": 15,
"protected": false,
"contributorsEnabled": false,
"profileImageURL": "http://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128_normal.jpg",
"biggerProfileImageURL": "http://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128_bigger.jpg",
"miniProfileImageURL": "http://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128_mini.jpg",
"originalProfileImageURL": "http://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128.jpg",
"profileImageURLHttps": "https://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128_normal.jpg",
"biggerProfileImageURLHttps": "https://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128_bigger.jpg",
"miniProfileImageURLHttps": "https://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128_mini.jpg",
"originalProfileImageURLHttps": "https://pbs.twimg.com/profile_images/1195068249/Nitor_Logo_128x128.jpg",
"geoEnabled": true,
"profileBackgroundImageURL": "http://pbs.twimg.com/profile_background_images/323688620/nitor_twitter_bkgd.jpg",
"profileBannerURL": null,
"profileBannerRetinaURL": null,
"profileBannerIPadURL": null,
"profileBannerIPadRetinaURL": null,
"profileBannerMobileURL": null,
"profileBannerMobileRetinaURL": null,
"verified": false,
"followRequestSent": false,
"urlentity": {
"start": 0,
"end": 22,
"url": "http://t.co/FTsfFWQcsw",
"expandedURL": "http://nitorgroup.com",
"displayURL": "nitorgroup.com"
},
"accessLevel": 0,
"rateLimitStatus": null
},
"truncated": false,
"urlentities": [
{
"start": 75,
"end": 98,
"url": "https://t.co/bmHKJAkTy1",
"expandedURL": "http://ow.ly/VSHvk",
"displayURL": "ow.ly/VSHvk"
}
],
"favorited": false,
"retweet": false,
"retweetedByMe": false,
"possiblySensitive": false,
"contributors": [],
"accessLevel": 0,
"rateLimitStatus": null
}],
"refreshURL": "?since_id=677174121147604994&q=%23MuleSoft&include_entities=1",
"accessLevel": 2,
"rateLimitStatus": {
"remaining": 179,
"limit": 180,
"resetTimeInSeconds": 1450293371,
"secondsUntilReset": 899,
"remainingHits": 179
}
}
DataWeave:
%dw 1.0
%output application/json
---
{
screenName: payload.user.screenName,
tweetId: payload.id,
tweetText: payload.text
}