renaming interface
This commit is contained in:
parent
261694815a
commit
d81cb4a874
|
@ -16,13 +16,10 @@ import org.springframework.integration.dsl.IntegrationFlow;
|
||||||
@EnableIntegration
|
@EnableIntegration
|
||||||
@IntegrationComponentScan
|
@IntegrationComponentScan
|
||||||
public class PublishSubscibeChannelExample {
|
public class PublishSubscibeChannelExample {
|
||||||
|
|
||||||
@MessagingGateway
|
@MessagingGateway
|
||||||
public interface I {
|
public interface NumbersClassifier {
|
||||||
|
|
||||||
@Gateway(requestChannel = "flow.input")
|
@Gateway(requestChannel = "flow.input")
|
||||||
void flow(Collection<Integer> is);
|
void flow(Collection<Integer> numbers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -43,30 +40,24 @@ public class PublishSubscibeChannelExample {
|
||||||
@Bean
|
@Bean
|
||||||
public IntegrationFlow flow() {
|
public IntegrationFlow flow() {
|
||||||
return flow -> flow.split()
|
return flow -> flow.split()
|
||||||
.publishSubscribeChannel(s ->
|
.publishSubscribeChannel(s -> s.subscribe(f -> f.<Integer> filter(p -> p % 3 == 0)
|
||||||
s.subscribe(f -> f.<Integer> filter(p -> p % 3 == 0).channel("multipleof3Channel"))
|
.channel("multipleof3Channel"))
|
||||||
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 1).channel("remainderIs1Channel"))
|
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 1)
|
||||||
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 2).channel("remainderIs2Channel"))
|
.channel("remainderIs1Channel"))
|
||||||
);
|
.subscribe(f -> f.<Integer> filter(p -> p % 3 == 2)
|
||||||
|
.channel("remainderIs2Channel")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(PublishSubscibeChannelExample.class);
|
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(PublishSubscibeChannelExample.class);
|
||||||
|
|
||||||
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
||||||
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
||||||
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
||||||
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
||||||
|
ctx.getBean(NumbersClassifier.class)
|
||||||
ctx.getBean(I.class)
|
|
||||||
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
|
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
|
||||||
|
|
||||||
ctx.close();
|
ctx.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,10 @@ import org.springframework.integration.dsl.IntegrationFlow;
|
||||||
@EnableIntegration
|
@EnableIntegration
|
||||||
@IntegrationComponentScan
|
@IntegrationComponentScan
|
||||||
public class RouteToRecipientsExample {
|
public class RouteToRecipientsExample {
|
||||||
|
|
||||||
@MessagingGateway
|
@MessagingGateway
|
||||||
public interface I {
|
public interface NumbersClassifier {
|
||||||
|
|
||||||
@Gateway(requestChannel = "flow.input")
|
@Gateway(requestChannel = "flow.input")
|
||||||
void flow(Collection<Integer> is);
|
void flow(Collection<Integer> numbers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -43,7 +40,6 @@ public class RouteToRecipientsExample {
|
||||||
@Bean
|
@Bean
|
||||||
public IntegrationFlow flow() {
|
public IntegrationFlow flow() {
|
||||||
return flow -> flow.split()
|
return flow -> flow.split()
|
||||||
|
|
||||||
.routeToRecipients(r -> r.<Integer> recipient("multipleof3Channel", p -> p % 3 == 0)// filter
|
.routeToRecipients(r -> r.<Integer> recipient("multipleof3Channel", p -> p % 3 == 0)// filter
|
||||||
.<Integer> recipient("remainderIs1Channel", p -> p % 3 == 1)
|
.<Integer> recipient("remainderIs1Channel", p -> p % 3 == 1)
|
||||||
.recipientFlow(sf -> sf.<Integer> filter(p -> p % 3 == 2)
|
.recipientFlow(sf -> sf.<Integer> filter(p -> p % 3 == 2)
|
||||||
|
@ -52,20 +48,14 @@ public class RouteToRecipientsExample {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(RouteToRecipientsExample.class);
|
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(RouteToRecipientsExample.class);
|
||||||
|
|
||||||
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
||||||
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
||||||
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
||||||
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
||||||
|
ctx.getBean(NumbersClassifier.class)
|
||||||
ctx.getBean(I.class)
|
|
||||||
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
|
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
|
||||||
|
|
||||||
ctx.close();
|
ctx.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,10 +16,8 @@ import org.springframework.integration.dsl.IntegrationFlow;
|
||||||
@EnableIntegration
|
@EnableIntegration
|
||||||
@IntegrationComponentScan
|
@IntegrationComponentScan
|
||||||
public class SeparateFlowsExample {
|
public class SeparateFlowsExample {
|
||||||
|
|
||||||
@MessagingGateway
|
@MessagingGateway
|
||||||
public interface I {
|
public interface NumbersClassifier {
|
||||||
|
|
||||||
@Gateway(requestChannel = "multipleof3Flow.input")
|
@Gateway(requestChannel = "multipleof3Flow.input")
|
||||||
void multipleof3(Collection<Integer> is);
|
void multipleof3(Collection<Integer> is);
|
||||||
|
|
||||||
|
@ -27,8 +25,7 @@ public class SeparateFlowsExample {
|
||||||
void remainderIs1(Collection<Integer> is);
|
void remainderIs1(Collection<Integer> is);
|
||||||
|
|
||||||
@Gateway(requestChannel = "remainderIs2Flow.input")
|
@Gateway(requestChannel = "remainderIs2Flow.input")
|
||||||
void remainderIs2(Collection<Integer> is);
|
void remainderIs2(Collection<Integer> numbers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -51,7 +48,6 @@ public class SeparateFlowsExample {
|
||||||
return f -> f.split()
|
return f -> f.split()
|
||||||
.<Integer> filter(p -> p % 3 == 0)
|
.<Integer> filter(p -> p % 3 == 0)
|
||||||
.channel("multipleof3Channel");
|
.channel("multipleof3Channel");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -59,7 +55,6 @@ public class SeparateFlowsExample {
|
||||||
return f -> f.split()
|
return f -> f.split()
|
||||||
.<Integer> filter(p -> p % 3 == 1)
|
.<Integer> filter(p -> p % 3 == 1)
|
||||||
.channel("remainderIs1Channel");
|
.channel("remainderIs1Channel");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -67,33 +62,22 @@ public class SeparateFlowsExample {
|
||||||
return f -> f.split()
|
return f -> f.split()
|
||||||
.<Integer> filter(p -> p % 3 == 2)
|
.<Integer> filter(p -> p % 3 == 2)
|
||||||
.channel("remainderIs2Channel");
|
.channel("remainderIs2Channel");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(SeparateFlowsExample.class);
|
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(SeparateFlowsExample.class);
|
||||||
|
|
||||||
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
||||||
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
||||||
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
||||||
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
||||||
|
ctx.getBean(NumbersClassifier.class)
|
||||||
ctx.getBean(I.class)
|
|
||||||
.multipleof3(Arrays.asList(1, 2, 3, 4, 5, 6));
|
.multipleof3(Arrays.asList(1, 2, 3, 4, 5, 6));
|
||||||
|
ctx.getBean(NumbersClassifier.class)
|
||||||
ctx.getBean(I.class)
|
|
||||||
.remainderIs1(Arrays.asList(1, 2, 3, 4, 5, 6));
|
.remainderIs1(Arrays.asList(1, 2, 3, 4, 5, 6));
|
||||||
|
ctx.getBean(NumbersClassifier.class)
|
||||||
ctx.getBean(I.class)
|
|
||||||
.remainderIs2(Arrays.asList(1, 2, 3, 4, 5, 6));
|
.remainderIs2(Arrays.asList(1, 2, 3, 4, 5, 6));
|
||||||
|
|
||||||
ctx.close();
|
ctx.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
|
@ -16,13 +16,10 @@ import org.springframework.integration.dsl.IntegrationFlow;
|
||||||
@EnableIntegration
|
@EnableIntegration
|
||||||
@IntegrationComponentScan
|
@IntegrationComponentScan
|
||||||
public class FilterExample {
|
public class FilterExample {
|
||||||
|
|
||||||
@MessagingGateway
|
@MessagingGateway
|
||||||
public interface I {
|
public interface NumbersClassifier {
|
||||||
|
|
||||||
@Gateway(requestChannel = "flow.input")
|
@Gateway(requestChannel = "flow.input")
|
||||||
void flow(Collection<Integer> is);
|
void flow(Collection<Integer> numbers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -43,33 +40,21 @@ public class FilterExample {
|
||||||
@Bean
|
@Bean
|
||||||
public IntegrationFlow flow() {
|
public IntegrationFlow flow() {
|
||||||
return flow -> flow.split()
|
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"))
|
||||||
.<Integer> filter(x -> x % 3 == 0, sf -> sf.discardFlow(subf -> subf
|
.channel("remainderIs1Channel")))
|
||||||
|
|
||||||
.<Integer> filter(x -> x % 3 == 1, ssf -> ssf.discardChannel("remainderIs2Channel"))
|
|
||||||
.channel("remainderIs1Channel")
|
|
||||||
|
|
||||||
))
|
|
||||||
|
|
||||||
.channel("multipleof3Channel");
|
.channel("multipleof3Channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(FilterExample.class);
|
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(FilterExample.class);
|
||||||
|
|
||||||
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
||||||
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
||||||
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
||||||
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
||||||
|
ctx.getBean(NumbersClassifier.class)
|
||||||
ctx.getBean(I.class)
|
|
||||||
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
|
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
|
||||||
|
|
||||||
ctx.close();
|
ctx.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,11 +17,9 @@ import org.springframework.integration.dsl.IntegrationFlow;
|
||||||
@IntegrationComponentScan
|
@IntegrationComponentScan
|
||||||
public class RouterExample {
|
public class RouterExample {
|
||||||
@MessagingGateway
|
@MessagingGateway
|
||||||
public interface I {
|
public interface NumbersClassifier {
|
||||||
|
|
||||||
@Gateway(requestChannel = "flow.input")
|
@Gateway(requestChannel = "flow.input")
|
||||||
void flow(Collection<Integer> is);
|
void flow(Collection<Integer> numbers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -43,28 +41,21 @@ public class RouterExample {
|
||||||
public IntegrationFlow flow() {
|
public IntegrationFlow flow() {
|
||||||
return f -> f.split()
|
return f -> f.split()
|
||||||
.<Integer, Integer> route(p -> p % 3, m -> m.channelMapping(0, "multipleof3Channel")
|
.<Integer, Integer> route(p -> p % 3, m -> m.channelMapping(0, "multipleof3Channel")
|
||||||
.subFlowMapping(1, sf -> sf .channel("remainderIs1Channel"))
|
.subFlowMapping(1, sf -> sf.channel("remainderIs1Channel"))
|
||||||
.subFlowMapping(2, sf -> sf.<Integer> handle((p,h)->p)))
|
.subFlowMapping(2, sf -> sf.<Integer> handle((p, h) -> p)))
|
||||||
.channel("remainderIs2Channel");
|
.channel("remainderIs2Channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(RouterExample.class);
|
final ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(RouterExample.class);
|
||||||
|
|
||||||
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
DirectChannel multipleof3Channel = ctx.getBean("multipleof3Channel", DirectChannel.class);
|
||||||
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
multipleof3Channel.subscribe(x -> System.out.println("multipleof3Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
DirectChannel remainderIs1Channel = ctx.getBean("remainderIs1Channel", DirectChannel.class);
|
||||||
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
remainderIs1Channel.subscribe(x -> System.out.println("remainderIs1Channel: " + x));
|
||||||
|
|
||||||
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
DirectChannel remainderIs2Channel = ctx.getBean("remainderIs2Channel", DirectChannel.class);
|
||||||
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
remainderIs2Channel.subscribe(x -> System.out.println("remainderIs2Channel: " + x));
|
||||||
|
ctx.getBean(NumbersClassifier.class)
|
||||||
ctx.getBean(I.class)
|
|
||||||
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
|
.flow(Arrays.asList(1, 2, 3, 4, 5, 6));
|
||||||
|
|
||||||
ctx.close();
|
ctx.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
Loading…
Reference in New Issue