Spring Batch:从数据库读取并发布到第三方webserivce

时间:2017-05-27 02:35:48

标签: spring spring-integration spring-batch

我需要使用Spring Batch开发一个应用程序来执行以下活动。从数据库中读取数据 - >处理数据并准备休息API请求 - >写入或发布到第三方的宁静服务。

我已经看过很多从数据库读取以写入CSV,DB,JMS的示例。 但我找不到任何可以写入Web服务的选项。是否可以使用弹簧批次执行此活动或请建议其他一些技术。

1 个答案:

答案 0 :(得分:1)

Spring Batch没有RestTemplate,因为我们需要发送的内容可能性太大了。话虽如此,编写自己的使用 <?xml version="1.0" encoding="UTF-8"?> <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:EngineerApp" x:Class="EngineerApp.GigsPage" NavigationPage.HasNavigationBar="false" xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"> <ContentPage Title="Gigs" Icon="icon.png"> <StackLayout Orientation="Vertical"> <local:HeaderBar LeftButtonText="Back" RightButtonText="Leave" LeftButtonClickEvent="Back" RightButtonClickEvent="Back"></local:HeaderBar> <local:ButtonBar LeftButtonText="Add Gig" RightButtonText="Month View" LeftButtonClickEvent="AddGig" RightButtonClickEvent="Back"></local:ButtonBar> <ActivityIndicator IsRunning="{Binding IsBusy}" IsVisible="{Binding IsBusy}"></ActivityIndicator> <ListView HasUnevenRows="true" SeparatorVisibility="Default" ItemsSource="{Binding gigs}" ItemSelected="Handle_ItemSelected"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Frame Padding="20,20,20,20"> <Frame.Content> <Frame Padding="15,15,15,15" OutlineColor="Gray" BackgroundColor="White"> <Frame.Content> <StackLayout Padding="20,0,0,0" Orientation="Vertical" HorizontalOptions="CenterAndExpand"> <Label Text="{Binding venue}" HorizontalTextAlignment="Center" TextColor="#69add1"/> <Label Text="{Binding date}" HorizontalTextAlignment="Center" FontFamily="OpenSans-Light" FontSize="9" TextColor="#69add1"/> <local:AuthorisationBar SelectedGig="{Binding .}"></local:AuthorisationBar> </StackLayout> </Frame.Content> </Frame> </Frame.Content> </Frame> </ViewCell> <local:GigCard /> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout> </ContentPage> </TabbedPage> 发送数据的 <?xml version="1.0" encoding="UTF-8"?> <ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="EngineerApp.AuthorisationBar"> <ContentView.Content> <StackLayout BackgroundColor="Red" HeightRequest="50" x:Name="barcontent" Orientation="Horizontal" HorizontalOptions="FillAndExpand"> <Label HorizontalOptions="FillAndExpand" VerticalOptions="Center" Text="I want to show some data here once the bindings are working"></Label> </StackLayout> </ContentView.Content> </ContentView> 实现将非常简单。