Mohammad Abu Shaera
Mohammad Abu Shaera

Reputation: 21

Twitter Stream with Filter

I created a twitter stream to extract a tweet info that I created, the stream is below:

xd:>stream create --name twitter2  --definition "twittersearch --consumerSecret=xxx --consumerKey=xxx --query='#SpringXDisSunnyThisEvening' | file" --deploy

The stream worked fine, I ended up with a file.out "JSON" which contains my tweet info.

I tried to add a filer to my stream like the below:

xd:>stream create --name twitter2  --definition "twittersearch --consumerSecret=xxx --consumerKey=xxx --query='#SpringXDisSunnyThisEvening' | filter --expression=#jsonPath(payload,'$.name').contains('moha') | file" --deploy

It did not work, no output file.

Log:

015-07-04T16:32:48-0500 1.2.0.RELEASE ERROR inbound.twitter2.0-redis:queue-inbound-channel-adapter1 redis.RedisMessageBus$1 - Failed to deliver message; retries exhausted; message sent to queue 'ERRORS:twitter2.0' org.springframework.messaging.MessageHandlingException: Expression evaluation failed: #jsonPath(payload,'$.name').contains('mohammad'); nested exception is java.lang.reflect.InvocationTargetException

Upvotes: 1

Views: 175

Answers (1)

Ilayaperumal Gopinathan
Ilayaperumal Gopinathan

Reputation: 4179

I think you need to use this expression

--expression=#jsonPath(payload,'$.user.screen_name').contains('something')

Note it is user.screen_name instead of just name from the twitter response.

Upvotes: 1

Related Questions