简体   繁体   English

将Twitter Streaming API集成到Java Web应用程序中

[英]Integrating twitter streaming API into a java web application

I have a java web app deployed on jboss, this is a war file that produces and consumes json data. 我在jboss上部署了一个Java Web应用程序,这是一个产生并使用json数据的war文件。 I would like to integrate twitter into the application, it would only needs to consume data from twitter so I was thinking the best approach would be to create a twitter account and use the streaming api to consume data. 我想将twitter集成到应用程序中,它只需要使用来自twitter的数据,因此我认为最好的方法是创建一个twitter帐户并使用流式api消费数据。

I like the look of twitter4j . 我喜欢twitter4j的外观。

How should I build this? 我应该如何构建呢? should it be as a part of my existing webapp and start it when I deploy my war or would it be more appropriate to make an ear and add this as an ejb service? 它应该是现有Web应用程序的一部分,并在我部署war时启动它吗?还是更适合ear并将其添加为ejb服务?

Using EJB makes sense if you can make use of its advantages: support for automaticly managed transactions, clustering, thread safety, etc. In case of "typical" web application this is usually an overkill. 如果您可以利用EJB的优点,那么使用EJB就很有意义:支持自动管理的事务,集群,线程安全性等。对于“典型”的Web应用程序,这通常是过大的。

So I would go with plain web application, if you want easier database integration you might use db stack from Spring Framework. 因此,我将使用普通的Web应用程序,如果您想更轻松地进行数据库集成,则可以使用Spring Framework中的db stack。

On the other hand, if you work on the Java EE 6 compliant server, you might pack EJBs inside WAR or use CDI beans to make application as lightweight as possible. 另一方面,如果在兼容Java EE 6的服务器上工作,则可以将EJB打包在WAR内,或使用CDI bean使应用程序尽可能轻量。

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

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