Last active
March 25, 2016 23:01
-
-
Save knalli/e81a4bff19d1fb5f20d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MessagingGateway | |
public interface ApiGateway { | |
@Gateway(requestChannel = "requestChannel", replyChannel = "resultChannel") | |
Response handle(Request request); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MessagingGateway | |
public interface ApiGateway { | |
@Gateway(requestChannel = "requestChannel", replyChannel = "resultChannel") | |
CompletableFuture<Response> handle(Request request); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class ConfigClient { | |
@Bean public IntegrationFlow flow() { | |
return IntegrationFlows.from(MessageChannels.publishSubscribe("requestChannel")) | |
.transform(Transformers.toJson(mapper())) | |
.handle(Amqp.outboundGateway(amqpTemplate).routingKey("queue")) | |
.transform(Transformers.fromJson(Response.class, mapper())) | |
.channel(MessageChannels.direct("responseChannel")) | |
.get(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class ConfigServer { | |
@Autowired ConnectionFactory connectionFactory; | |
@Autowired ApiImpl api; | |
@Bean public JsonObjectMapper<?, ?> mapper() { | |
return new Jackson2JsonObjectMapper(); | |
} | |
@Bean public IntegrationFlow flow() { | |
return IntegrationFlows.from( | |
Amqp.inboundGateway(connectionFactory, "queue") | |
.errorChannel("errorChannel")) | |
.transform(Transformers.fromJson(Request.class, mapper())) | |
.handle(Request.class, (request, headers) -> api.handle(request)) | |
.transform(Transformers.toJson(mapper())) | |
.get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment