restfeed-client-spring


Лицензия

Лицензия

Категории

Категории

CLI Взаимодействие с пользователем
Группа

Группа

org.restfeeds
Идентификатор

Идентификатор

restfeed-client-spring
Последняя версия

Последняя версия

0.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

restfeed-client-spring
restfeed-client-spring
Ссылка на сайт

Ссылка на сайт

https://github.com/rest-feeds/rest-feeds
Система контроля версий

Система контроля версий

http://github.com/rest-feeds/restfeed-client-spring/tree/master

Скачать restfeed-client-spring

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.restfeeds/restfeed-client-spring/ -->
<dependency>
    <groupId>org.restfeeds</groupId>
    <artifactId>restfeed-client-spring</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.restfeeds/restfeed-client-spring/
implementation 'org.restfeeds:restfeed-client-spring:0.0.1'
// https://jarcasting.com/artifacts/org.restfeeds/restfeed-client-spring/
implementation ("org.restfeeds:restfeed-client-spring:0.0.1")
'org.restfeeds:restfeed-client-spring:jar:0.0.1'
<dependency org="org.restfeeds" name="restfeed-client-spring" rev="0.0.1">
  <artifact name="restfeed-client-spring" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.restfeeds', module='restfeed-client-spring', version='0.0.1')
)
libraryDependencies += "org.restfeeds" % "restfeed-client-spring" % "0.0.1"
[org.restfeeds/restfeed-client-spring "0.0.1"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.restfeeds : restfeed-client jar 0.0.2
org.springframework.boot : spring-boot-starter-web jar 2.2.2.RELEASE

test (1)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter-test jar 2.2.2.RELEASE

Модули Проекта

Данный проект не имеет модулей.

restfeed-client-spring

Maven Central

Client library to consume REST Feeds with Spring Boot.

Getting Started

Go to start.spring.io and create an new application. Select this dependency for RestTemplate and HttpMessageConverters:

  • Spring Web

Then add this library to your pom.xml:

    <dependency>
      <groupId>org.restfeeds</groupId>
      <artifactId>restfeed-client-spring</artifactId>
      <version>0.0.1</version>
    </dependency>

Add the base URL of the feed endpoint to your application.properties:

restfeed.client.url=https://example.rest-feeds.org/movies

And implement a FeedItemConsumer:

@Component
public class SimpleFeedItemConsumer implements FeedItemConsumer{

  @Override
  public void accept(FeedItem feedItem) {
    System.out.println(feedItem);
  }
}

Now run the application, you should see all feed items printed to your console.

Components

FeedReader

The FeedReader is the core class that polls the feed endpoint for new items in an endless loop.

Call the read() method to start reading the feed.

When shutting down the application, call the stop() method to end the endless loop.

The Spring RestFeedClientAutoConfiguration starts and stops the FeedReader on application startup and shutdown.

FeedItemConsumer

Implement FeedItemConsumer interface to handle feed items.

NextLinkRepository

Provide an implementation how the next link is stored. The save() method is called directly after a feed item was consumed.

Typically, the NextLinkRepository is implemented as a SQL or NoSQL database.

An InMemoryNextLinkRepository is provided for testing.

The Spring RestFeedClientAutoConfiguration configures an InMemoryNextLinkRepository, when no other NextLinkRepository bean was created.

FeedReaderRestClient

Implement this interface to perform the HTTP connection to the feed endpoint, authenticate, negotiate the content type, and do the unmarshalling.

The Spring RestFeedClientAutoConfiguration configures a RestTemplateFeedReaderRestClient, when no other FeedReaderRestClient bean was created. Consider configuring the RestTemplateBuilder for your needs.

Spring Properties

RestFeedClientAutoConfiguration uses these properties:

Key Default Value Description
restfeed.client.enabled true Enable REST feed client auto configuration and run FeedReader on application start.
restfeed.client.url The base URL of the feed endpoint to consume. Required.
restfeed.client.username The username for basic authentication. Optional.
restfeed.client.password The password for basic authentication. Optional.

FAQ

How to disable the embedded web server

Spring Web automatically starts up a Tomcat server on port 8080.

Set this property to disable:

spring.main.web-application-type=none

Версии библиотеки

Версия
0.0.1