你好,游客 登录 注册 搜索
背景:
阅读新闻

Spring Integration 4.1 Milestone 1 发布下载

[日期:2014-09-06] 来源:oschina.net  作者:Linux [字体:大 中 小]

Spring Integration 4.1 Milestone 1 发布,现已提供在 Milestone Repository,可以使用 Maven 和 Gradle 安装升级,也可以直接下载。

Spring Integration 4.1 Milestone 1 包括一些新特性,系统改进和 bug 修复,GA 版本将会在十月底发布。

改进列表:

  • migration of additional Spring Integration APIs to the Core Spring Messaging module and the Spring Integration equivalents are deprecated
    or removed to avoid confusion in the target applications;

  • a number of Messaging performance improvements have been included in Spring Framework 4.1.

  • Spring Framework 4.1 introduced the SpEL Compiler. It is very useful for Spring Integration, which extensively uses SpEL at runtime. You can enable the SpEL Compiler using thespring.expression.compiler.mode System Property with a value of IMMEDIATE or MIXED.

WebSocket Adapters

引入了 WebSocket Inbound 和 Outbound Channel Adapters。

服务器端:

@Configuration@EnableIntegrationpublic class ServerConfig {
 
    @Bean
    public ServerWebSocketContainer serverWebSocketContainer() {
        return new ServerWebSocketContainer("/ws").withSockJs();
    }
 
    @Bean
    public MessageProducer webSocketInboundChannelAdapter() {
        WebSocketInboundChannelAdapter webSocketInboundChannelAdapter = 
                    new WebSocketInboundChannelAdapter(serverWebSocketContainer());
        webSocketInboundChannelAdapter.setOutputChannel(webSocketInputChannel());
        return webSocketInboundChannelAdapter;
    }
 
    @Bean
    @Transformer(inputChannel = "webSocketInputChannel", outputChannel = "webSocketOutputChannel")
    public ExpressionEvaluatingTransformer transformer() {
        return new ExpressionEvaluatingTransformer(PARSER.parseExpression("'Hello ' + payload"));
    }
 
    @Bean
    @ServiceActivator(inputChannel = "webSocketOutputChannel")
    public MessageHandler webSocketOutboundMessageHandler() {
        return new WebSocketOutboundMessageHandler(serverWebSocketContainer());
    }}

客户端

@Configuration@EnableIntegrationpublic class ClientConfig {
    @Bean
    public WebSocketClient webSocketClient() {
        return new SockJsClient(Collections.<Transport>singletonList(
                        new WebSocketTransport(new JettyWebSocketClient())));
    }
 
    @Bean
    public IntegrationWebSocketContainer clientWebSocketContainer() {
        return new ClientWebSocketContainer(webSocketClient(), "ws://host:port/ws");
    }
 
    @Bean
    public MessageProducer webSocketInboundChannelAdapter() {
        WebSocketInboundChannelAdapter webSocketInboundChannelAdapter =
                new WebSocketInboundChannelAdapter(clientWebSocketContainer());
        webSocketInboundChannelAdapter.setOutputChannel(webSocketInputChannel());
        return webSocketInboundChannelAdapter;
    }
 
    @Bean
    @ServiceActivator(inputChannel = "webSocketOutputChannel")
    public MessageHandler webSocketOutboundMessageHandler() {
        return new WebSocketOutboundMessageHandler(clientWebSocketContainer());
    }}

另一个简单集成 Spring WebSockets 和 STOMP 子协议的方法,但���使用集成流来处理请求和发送响应,这是基于 @MessageMapping 注释的,但是在 @MessagingGateway 接口:

@MessagingGateway@Controllerpublic interface WebSocketGateway {
 
    @MessageMapping("/greeting")
    @SendToUser("/queue/answer")
    @Gateway(requestChannel = "greetingChannel")
    String greeting(String payload);}

支持 Reactor

Promise<?> Gateway 支持 Project Reactor,现在 Spring Integration 信息流可以用作 Reactive Streams 的一部分:

@MessagingGateway(reactorEnvironment = "reactorEnv")public interface PromiseGateway {
 
    @Gateway(requestChannel = "promiseChannel")
    Promise<Integer> multiply(Integer value);}
 
        ...@ServiceActivator(inputChannel = "promiseChannel")public Integer multiply(Integer value) {
    return value * 2;}
 
        ...Streams.defer(Arrays.asList("1", "2", "3", "4", "5"))
    .env(this.environment)
    .get()
    .map(Integer::parseInt)
    .mapMany(integer -> promiseGateway.multiply(integer))
    .collect()
    .consume(integers -> ...)
    .flush();

另外,还支持 Spring Framework ListenableFuture<?> gateway 方法返回类型。

Boon JSON mapper

 JSON 转换器添加了 Boon JsonObjectMapper 实现。

Splitter Iterator

<splitter>s 可以返回 Iterator<?> 和 Iterable<?> 作为一个 payload 来达到 streaming 行为。

这里包含两个维护版本:3.0.5 和 4.0.4。强烈建议各位用户升级到最新版本!

注意

完整的更新列表请看这里,What's New 和 Java Docs。

升级请看迁移指导。

SpringOne 2GX 2014

一些新特性下周将会出现在 SpringOne,请继续关注 Gary Russell's Session。

Spring Integration能在基于Spring的应用中进行简单的消息通信,并通过简单的适配器与外部系统集成。这些适配器提供了一个更高级别的抽象,超越 了Spring对远程调用、消息和调度的支持。其主要目标是在保持关注点分离的同时,为构建企业集成解决方案提供一个简单的模型,该模型对产出可维护、可 测试的代码来说是必不可少的。

文档地址

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-09/106244.htm

linux
相关资讯       Spring Integration 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款