renaming interface

This commit is contained in:
Ekaterina Galkina 2018-11-12 14:57:44 +05:00
parent 261694815a
commit d81cb4a874
5 changed files with 29 additions and 88 deletions

View File

@ -16,13 +16,10 @@ import org.springframework.integration.dsl.IntegrationFlow;
@EnableIntegration
@IntegrationComponentScan
public class PublishSubscibeChannelExample {
@MessagingGateway
public interface I {
public interface NumbersClassifier {
@Gateway(requestChannel = "flow.input")
void flow(Collection<Integer> is);
void flow(Collection<Integer> numbers);
}
@Bean
@ -43,30 +40,24 @@ public class PublishSubscibeChannelExample {
@Bean
public IntegrationFlow flow() {
return flow -> flow.split()
.publishSubscribeChannel(s ->
s.subscribe(f -> f.<Integer> filter(p -> p % 3 == 0).channel("multipleof3Channel"))
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 1).channel("remainderIs1Channel"))
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 2).channel("remainderIs2Channel"))
);
.publishSubscribeChannel(s -> s.subscribe(f -> f.<Integer> filter(p -> p % 3 == 0)
.channel("multipleof3Channel"))
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 1)
.channel("remainderIs1Channel"))
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 2)
.channel("remainderIs2Channel")));
}
public static void main(String[] args) {
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(PublishSubscibeChannelExample.class);
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
ctx.getBean(I.class)
ctx.getBean(NumbersClassifier.class)
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
ctx.close();
}
}

View File

@ -16,13 +16,10 @@ import org.springframework.integration.dsl.IntegrationFlow;
@EnableIntegration
@IntegrationComponentScan
public class RouteToRecipientsExample {
@MessagingGateway
public interface I {
public interface NumbersClassifier {
@Gateway(requestChannel = "flow.input")
void flow(Collection<Integer> is);
void flow(Collection<Integer> numbers);
}
@Bean
@ -43,7 +40,6 @@ public class RouteToRecipientsExample {
@Bean
public IntegrationFlow flow() {
return flow -> flow.split()
.routeToRecipients(r -> r.<Integer> recipient("multipleof3Channel", p -> p % 3 == 0)// filter
.<Integer> recipient("remainderIs1Channel", p -> p % 3 == 1)
.recipientFlow(sf -> sf.<Integer> filter(p -> p % 3 == 2)
@ -52,20 +48,14 @@ public class RouteToRecipientsExample {
public static void main(String[] args) {
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(RouteToRecipientsExample.class);
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
ctx.getBean(I.class)
ctx.getBean(NumbersClassifier.class)
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
ctx.close();
}
}

View File

@ -16,10 +16,8 @@ import org.springframework.integration.dsl.IntegrationFlow;
@EnableIntegration
@IntegrationComponentScan
public class SeparateFlowsExample {
@MessagingGateway
public interface I {
public interface NumbersClassifier {
@Gateway(requestChannel = "multipleof3Flow.input")
void multipleof3(Collection<Integer> is);
@ -27,8 +25,7 @@ public class SeparateFlowsExample {
void remainderIs1(Collection<Integer> is);
@Gateway(requestChannel = "remainderIs2Flow.input")
void remainderIs2(Collection<Integer> is);
void remainderIs2(Collection<Integer> numbers);
}
@Bean
@ -51,7 +48,6 @@ public class SeparateFlowsExample {
return f -> f.split()
.<Integer> filter(p -> p % 3 == 0)
.channel("multipleof3Channel");
}
@Bean
@ -59,7 +55,6 @@ public class SeparateFlowsExample {
return f -> f.split()
.<Integer> filter(p -> p % 3 == 1)
.channel("remainderIs1Channel");
}
@Bean
@ -67,33 +62,22 @@ public class SeparateFlowsExample {
return f -> f.split()
.<Integer> filter(p -> p % 3 == 2)
.channel("remainderIs2Channel");
}
public static void main(String[] args) {
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(SeparateFlowsExample.class);
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
ctx.getBean(I.class)
ctx.getBean(NumbersClassifier.class)
.multipleof3(Arrays.asList(1, 2, 3, 4, 5, 6));
ctx.getBean(I.class)
ctx.getBean(NumbersClassifier.class)
.remainderIs1(Arrays.asList(1, 2, 3, 4, 5, 6));
ctx.getBean(I.class)
ctx.getBean(NumbersClassifier.class)
.remainderIs2(Arrays.asList(1, 2, 3, 4, 5, 6));
ctx.close();
}
}

View File

@ -16,13 +16,10 @@ import org.springframework.integration.dsl.IntegrationFlow;
@EnableIntegration
@IntegrationComponentScan
public class FilterExample {
@MessagingGateway
public interface I {
public interface NumbersClassifier {
@Gateway(requestChannel = "flow.input")
void flow(Collection<Integer> is);
void flow(Collection<Integer> numbers);
}
@Bean
@ -43,33 +40,21 @@ public class FilterExample {
@Bean
public IntegrationFlow flow() {
return flow -> flow.split()
.<Integer> filter(x -> x % 3 == 0, sf -> sf.discardFlow(subf -> subf
.<Integer> filter(x -> x % 3 == 1, ssf -> ssf.discardChannel("remainderIs2Channel"))
.channel("remainderIs1Channel")
))
.<Integer> filter(x -> x % 3 == 0, sf -> sf.discardFlow(subf -> subf.<Integer> filter(x -> x % 3 == 1, ssf -> ssf.discardChannel("remainderIs2Channel"))
.channel("remainderIs1Channel")))
.channel("multipleof3Channel");
}
public static void main(String[] args) {
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(FilterExample.class);
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
ctx.getBean(I.class)
ctx.getBean(NumbersClassifier.class)
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
ctx.close();
}
}

View File

@ -17,11 +17,9 @@ import org.springframework.integration.dsl.IntegrationFlow;
@IntegrationComponentScan
public class RouterExample {
@MessagingGateway
public interface I {
public interface NumbersClassifier {
@Gateway(requestChannel = "flow.input")
void flow(Collection<Integer> is);
void flow(Collection<Integer> numbers);
}
@Bean
@ -50,21 +48,14 @@ public class RouterExample {
public static void main(String[] args) {
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(RouterExample.class);
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
ctx.getBean(I.class)
ctx.getBean(NumbersClassifier.class)
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
ctx.close();
}
}