INT-786 initial cleanup, removed MetaPersister in favor of injecting a Map which could be anything (e.g., cache etc.)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package org.springframework.integration.feed;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sun.syndication.feed.synd.SyndEntry;
|
||||
|
||||
@Component
|
||||
public class FeedDeliveryEventServiceActivator {
|
||||
|
||||
@ServiceActivator
|
||||
public void activate(Message<SyndEntry> message) throws Exception {
|
||||
|
||||
MessageHistory history = MessageHistory.read(message);
|
||||
for (Properties properties : history) {
|
||||
System.out.println(properties);
|
||||
}
|
||||
SyndEntry syndEntry = message.getPayload();
|
||||
|
||||
System.out.println( "Publishing new SyndEntry " + syndEntry.getUri() +":"+
|
||||
syndEntry.getPublishedDate().toString()+ ":"+ syndEntry.getPublishedDate().getTime());
|
||||
|
||||
// System.out.println( syndEntry.toString());
|
||||
// System.out.println("Delivery! " + ToStringBuilder.reflectionToString(evtMsg));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:feed="http://www.springframework.org/schema/integration/feed"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/integration/feed http://www.springframework.org/schema/integration/feed/spring-integration-feed.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<int:message-history/>
|
||||
|
||||
<bean id="activator" class="org.springframework.integration.feed.FeedDeliveryEventServiceActivator"/>
|
||||
|
||||
|
||||
<!--
|
||||
this will keep state in /tmp/feedDemo.properties and not deliver anything until the feed has an updated pub date
|
||||
|
||||
to see the feed again, rm /tmp/feedDemo.properties
|
||||
-->
|
||||
<!-- <bean id="metadataPersister" class="org.springframework.integration.context.metadata.PropertiesBasedMetadataPersister">-->
|
||||
<!-- <property name="uniqueName" value="feedDemo"/>-->
|
||||
<!-- </bean>-->
|
||||
|
||||
<!--http://twitter.com/statuses/public_timeline.atom
|
||||
-->
|
||||
<feed:inbound-channel-adapter id="feedAdapter" channel="feedChanges" feedUrl="http://feeds.bbci.co.uk/news/rss.xml" >
|
||||
<int:poller fixed-rate="10000" max-messages-per-poll="-1"/>
|
||||
</feed:inbound-channel-adapter>
|
||||
|
||||
<int:channel id="feedChanges"/>
|
||||
|
||||
<int:service-activator input-channel="feedChanges" ref="activator" />
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,5 +1,21 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.integration.feed;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -10,27 +26,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
public class TestFeedEventDelivery {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testDeliveryOfFeed() throws Exception {
|
||||
Thread.sleep(1000 * 60);
|
||||
}
|
||||
|
||||
/* public static void main(String[] args) throws Throwable {
|
||||
String siweb = "http://twitter.com/statuses/public_timeline.atom"; //http://localhost:8080/siweb/foo.atom";
|
||||
FeedEntryReaderMessageSource feedEntryReaderMessageSource = new FeedEntryReaderMessageSource();
|
||||
feedEntryReaderMessageSource.setFeedUrl(siweb);
|
||||
feedEntryReaderMessageSource.afterPropertiesSet();
|
||||
feedEntryReaderMessageSource.start();
|
||||
|
||||
while (true) {
|
||||
Message<SyndEntry> entryMessage = feedEntryReaderMessageSource.receive();
|
||||
|
||||
if (entryMessage != null) {
|
||||
SyndEntry entry = entryMessage.getPayload();
|
||||
System.out.println((entry.getTitle() + "=" + entry.getUri()));
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user