简体   繁体   English

在春季使用Twitter4J获取推文

[英]Fetch tweets using Twitter4J in Spring

I'm interested in use Twitter4J to fetch tweets from Twitter streaming API. 我对使用Twitter4J从Twitter流API获取推文感兴趣。 This library would be used from a Spring class annotated with @Service and would received updates in a StatusListener to store it in a DB later. 该库将在带有@Service注释的Spring类中使用,并会在StatusListener接收更新,以稍后将其存储在数据库中。 My question is, would I stop other actions while receiving updates or users would be able to interact with the website? 我的问题是,在接收更新时我是否将停止其他操作,否则用户将能够与该网站进行交互?

Users should still be able to use the website. 用户仍然应该能够使用该网站。 You could do the twitter4j parsing in a bean with scope marked as prototype so it wouldn't be a singleton and therefore wouldn't create any threading issues with other users logged into the system if it was marked as @Service. 您可以在范围标记为“ prototype”的bean中进行twitter4j解析,这样就不会成为单例,因此如果将其标记为@Service,则不会与登录系统的其他用户产生任何线程问题。

Remember, Spring beans are singletons by default. 请记住,默认情况下,Spring bean是单例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM