Rss Feed无法显示数据

时间:2015-05-27 11:35:19

标签: java rss activemq

我有一个项目,其中我需要来自activemq的数据需要在rss feed上显示为通知用户显示正在运行的程序的当前状态,但不知何故整个过程运行但rss feed仍然为空并且作为过程完成然后Feed根据需要自动消失..问题是为什么Feed是空的。我已经包含了如下负责的代码和堆栈跟踪

当我进行调试时,控件从

跳转

reader = new XmlReader(url);

直接if(reader!= null)

没有进入列表和所有的整个添加值,可能是什么原因。

@Controller
@RequestMapping(value = "/rssFeedReader")
public class RssFeedReaderController {

@Value(value = "#{'${activemq.ip}'}")
private String ipaddress;
@Value(value = "#{'${activemq.port}'}")
private String port;

@SuppressWarnings("unchecked")
@RequestMapping(value = "/readRssFeeds/{sourceName}", method = RequestMethod.POST)
@ResponseBody
public List<RssFeedMessage> readRssFeeds(@PathVariable String sourceName) {
    XmlReader reader = null;
    RssFeedMessage rssFeedMessage = null;
    StringBuffer feedUrl = new StringBuffer("http://").append(ipaddress).append(":")
            .append(port).append("/admin/queueBrowse/").append(sourceName).append("?view=rss&feedType=rss_2.0");
    List<RssFeedMessage> rssFeedMessages = new ArrayList<RssFeedMessage>();
    try {
        URL url = new URL(feedUrl.toString());

        reader = new XmlReader(url);

        SyndFeed feedMsg= new SyndFeedInput().build(reader);

        List<SyndEntry> feedEntries = feedMsg.getEntries();
        for (SyndEntry entry : feedEntries) {
            rssFeedMessage = new RssFeedMessage();
            rssFeedMessage.setTitle(entry.getTitle());
            rssFeedMessage.setDescription(entry.getDescription().getValue());
            rssFeedMessage.setDate(OptimerUtil.simpleDateHourTimeInd.format(entry.getPublishedDate()));

            rssFeedMessages.add(rssFeedMessage);

        }
    } catch(IOException e){
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (FeedException e) {
        e.printStackTrace();
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException e) {
            }
        }
    }

    return rssFeedMessages;
}
}

这是堆栈跟踪:初始行java.io.IOException: Invalid Http response at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1343) at com.sun.syndication.io.XmlReader.<init>(XmlReader.java:174) at com.sun.syndication.io.XmlReader.<init>(XmlReader.java:151) at com.optimer.util.RssFeedReaderController.readRssFeeds(RssFeedReaderController.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

0 个答案:

没有答案