You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by contactreji <co...@gmail.com> on 2014/12/20 08:41:51 UTC

Camel Twitter Consumer - DirectMessage

Hi friends

I was trying integrate an application with Twitter. My use case demands that
I should read DirectMessages of a user and store it into a DB containing 2
columns. SenderScreeName and MessageText.

I am using Camel 2.13.0 version and I have following route
<from
<b>			
uri="twitter://directmessage?type=polling&amp;delay=120000&amp;consumerKey=******&amp;consumerSecret=*****&amp;accessToken=****&amp;accessTokenSecret=****&amp;useSSL=true"
/>

<to uri="bean:Handleposts" />
		</route>*

While using a debugger, I noticed that it returns object of type
twitter4j.internal.json.DirectMessageJSONImpl .. now I am trying to
instantiate that class in my Java Processor it looks like it cannot find the
"*DirectMessageJSONImpl*" in the classpath.

I have camel-twitter dependency in my POM file.
*<dependency>
			<groupId>org.apache.camel</groupId>
			<artifactId>camel-twitter</artifactId>
			<version>2.13.0</version>
		</dependency>*


Where can I get the *DirectMessageJSONImpl.class* now. Which maven
dependency should I use here? I tried using *twitter4j-core* dependency but
when I start the route I get error as follows.

*[d #0 - twitter://directmessage] TwitterConsumerPolling         WARN 
Consumer
Consumer[twitter://directmessage?accessToken=***-****&accessTokenSecret=*****&consumerKey=*****&consumerSecret=********&delay=120000&type=polling&useSSL=true]
failed polling endpoint:
Endpoint[twitter://directmessage?accessToken=******-******&accessTokenSecret=*****&consumerKey=*****&consumerSecret=*******&delay=120000&type=polling&useSSL=true].
Will try again at next poll. Caused by: [java.lang.NoSuchMethodError -
twitter4j.conf.ConfigurationBuilder.setUseSSL(Z)Ltwitter4j/conf/ConfigurationBuilder;]
java.lang.NoSuchMethodError:
twitter4j.conf.ConfigurationBuilder.setUseSSL(Z)Ltwitter4j/conf/ConfigurationBuilder;
*



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Twitter-Consumer-DirectMessage-tp5760940.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Twitter Consumer - DirectMessage

Posted by Taariq Levack <ta...@gmail.com>.
That's no problem either. The body type is DirectMessage which provides methods for that.
Check the camel-twitter component page for the body types, and the Twitter4j api for details.

Taariq


> On 20 Dec 2014, at 14:42, contactreji <co...@gmail.com> wrote:
> 
> Thanks Taariq. 
> 
> When I print the exchange I see details of sender and text in the log.
> 
> What if I want to access or print the PostId or createdDate inside a Java
> processor. Can you give me a sample code snippet for that?
> 
> Cheers
> Reji
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Twitter-Consumer-DirectMessage-tp5760940p5760951.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Twitter Consumer - DirectMessage

Posted by contactreji <co...@gmail.com>.
Thanks Taariq. 

When I print the exchange I see details of sender and text in the log.

What if I want to access or print the PostId or createdDate inside a Java
processor. Can you give me a sample code snippet for that?

Cheers
Reji





--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Twitter-Consumer-DirectMessage-tp5760940p5760951.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Twitter Consumer - DirectMessage

Posted by Taariq Levack <ta...@gmail.com>.
Hi Reji

camel-twitter already includes twitter4j-core so no need to include it, the
version is 3.0.5 to avoid the error you got.

The class itself is included in the jar, but you can't import it because
it's not public.
No need for the internal api anyway, the responses/tweets already have what
you need.


Taariq

On Sat, Dec 20, 2014 at 10:15 AM, contactreji <co...@gmail.com> wrote:

> As of now I have  made a temporary work around on this.
> I copied the source of the class from following link into my project and I
> am not isntantiating the object to access members. Wondering if there is
> any
> better method by playing around on POM.xml file
>
>
> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.servicemix.bundles/org.apache.servicemix.bundles.twitter4j/3.0.1_1/twitter4j/internal/json/DirectMessageJSONImpl.java?av=h
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-Twitter-Consumer-DirectMessage-tp5760940p5760943.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel Twitter Consumer - DirectMessage

Posted by contactreji <co...@gmail.com>.
As of now I have  made a temporary work around on this. 
I copied the source of the class from following link into my project and I
am not isntantiating the object to access members. Wondering if there is any
better method by playing around on POM.xml file

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.servicemix.bundles/org.apache.servicemix.bundles.twitter4j/3.0.1_1/twitter4j/internal/json/DirectMessageJSONImpl.java?av=h 



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Twitter-Consumer-DirectMessage-tp5760940p5760943.html
Sent from the Camel - Users mailing list archive at Nabble.com.