The Spring Blog

Engineering
Releases
News and Events

Spring Integration Java DSL: Line by line tutorial

Dear Spring Community!

Just after the Spring Integration Java DSL 1.0 GA release announcement I want to introduce the Spring Integration Java DSL to you as a line by line tutorial based on the classic Cafe Demo integration sample. We describe here Spring Boot support, Spring Framework Java and Annotation configuration, the IntegrationFlow feature and pay tribute to Java 8 Lambda support which was an inspiration for the DSL style. Of course, it is all backed by the Spring Integration Core project.

Read more...

Spring Cloud 1.0.0.M3 Available Now

Spring Cloud 1.0.0.M3 is available now in the repo.spring.io repository. The following projects all had a 1.0.0.M3 release:

  • Spring Cloud Config: centralized key-value (or YAML) configuration management. Now supports the config server being fully embedded in another application.

  • Spring Cloud Netflix. Also has better support for embeddability of the server components. Now also properly records load balancer statistics in Ribbon-enabled Spring RestTemplate.

  • Spring Cloud for Amazon Web Services. Has new Spring Boot integration points, externalizing configuration for AWS metadata.

  • Spring Cloud Security: super simple OAuth2 in a declarative style.

  • Spring Cloud Bus: broadcasts framework-level events to Spring Cloud components. Big news here is that we now have a RabbitMQ-based aggregator for Hystrix metrics (based on Turbine 2), so you don't have to rely on having direct HTTP access to all service instances.

  • Spring Cloud CLI: Groovy CLI for writing microservices in self-contained scripts.

  • Spring Cloud for Cloud Foundry: now bridges between Spring Cloud Security and Cloud Foundry service bindings, making it super easy to do Single Sign On and OAutth2 protected resources in Cloud Foundry.

Read more...

This Week in Spring - November 25th, 2014

Egads! Can you believe it's already almost the end of the year? Time has been screaming fast! It's the week of Thanksgiving for those of us in the United States. This is a wonderful time of year to sit back, find a nice Spring IO guide or blog to read, and then build something awesome.. oh, and it's an ideal time to spend in the company of friends and family and to reflect on those and that for which we're grateful. I'm sure I speak for the Spring team and Pivotal at large when I say that we're grateful for you, our inspiring community, users and customers.

Read more...

Webinar Replay: Spring Boot and JRebel 6.0

Speakers: Josh Long, Pivotal + Adam Koblentz - ZeroTurnaround

Slides: https://speakerdeck.com/joshlong/bootiful-jrebel

Spring Boot, the new convention-over-configuration centric framework from the Spring team at Pivotal, marries Spring's flexibility with conventional, common sense defaults to make application development not just fly, but pleasant! Spring Boot gives you a huge leg up over normal starter projects, now let's give you another boost by adding JRebel. With JRebel, the average Java developer saves over 1 work-month per year by using JRebel to skip rebuild, restart, and redeploys of their application. JRebel 6 launches on November 4, 2014 and includes complete Spring Boot integration. Join Spring's Josh Long and ZeroTurnaround's Adam Koblentz and learn how to combine Boot with JRebel and get more done, in less time with less configuration.

Read more...

SpringOne2GX 2014 Replay: Creating REST-ful, Hypermedia-based Micro-services with Spring Boot

Recorded at SpringOne2GX 2014.

Speaker: Ben Hale @nebhale

Slides: http://www.slideshare.net/SpringCentral/creating-restful-hypermediabased-microservices-with-spring-boot

As data-driven applications become ubiquitous, the services that provide the data are proliferating. As teams become responsible for more and more of these services, it becomes critical that they be designed and implemented in a way that is as lightweight as possible. This session will cover how to design micro-services as RESTful APIs and implement them with minimal code using Spring Boot. It will focus on API design using REST and HATEOAS, with live coding progressing from a tweet-length implementation all the way to a full-fledged app running in the cloud.

Read more...

SpringOne2GX 2014 Replay: Developing Microservices for PaaS with Spring and Cloud Foundry

Recorded at SpringOne2GX 2014.

Speaker: Matt Stine

Slides: http://www.slideshare.net/SpringCentral/developing-microservices-for-paas-with-spring-and-cloud-foundry

Marc Andressen has famously said "Software is eating the world." What does that mean? We take it to mean that multiple industries with historically entrenched leaders are being disrupted by businesses built around a software core. These software factories are characterized by: tight feedback loops rapid iteration horizontal scaling mobile-first UX continuous delivery These factors have contributed to drive a change in how we approach infrastructure, which has taken the lead in adapting to meet these needs with the move to the cloud, and Platform as a Service (PaaS) offerings like Cloud Foundry have raised the level of abstraction to a focus on an ecosystem of applications and services. However, most applications are still developed as if we're living in the previous generation of both business and infrastructure: the monolithic application. Microservices - small, loosely coupled applications that follow the Unix philosophy of ""doing one thing well"" - represent the application development side of enabling rapid, iterative development, horizontal scale, polyglot clients, and continuous delivery. They also enable us to scale application development and eliminate long term commitments to a single technology stack. While microservices are simple, they are certainly not easy. It's recently been said that "microservices are not a free lunch." Interestingly enough, if you look at the concerns typically expressed about microservices, you'll find that they are exactly the challenges that a PaaS is intended to address. So while microservices do not necessarily imply cloud (and vice versa), there is in fact a symbiotic relationship between the two, with each approach somehow compensating for the limitations of the other, much like the practices of eXtreme Programming do the same. This session will describe architectural patterns for developing microservices:

Read more...

SpringOne2GX 2014 Replay: Running Your Spring Apps in the Cloud

Recorded at SpringOne2GX 2014.

Speaker: Cornelia Davis

Slides: http://www.slideshare.net/SpringCentral/running-your-spring-apps-in-the-cloud

The Spring Trader application was debuted at SpringOne 2GX in 2012 and presented an application that demonstrates a multitude of Pivotal Application Fabric components working together – tcServer, RabbitMQ, SQLFire and Gemfire. In this session we will take that application and make (a few) modifications (mostly to config) to get it running on the same components in the cloud, specifically on the Cloud Foundry PaaS. We’ll show you how to use the Spring Cloud project to configure the deployment, how to leverage a cloud services catalog, how to implement a cross-site scripting solution (and why), how to do session state caching and we’ll discuss (the dangers of) auto reconfiguration. If you bring a laptop you can have your own instance of the app running by the end of the session.

Read more...

Spring Integration Java DSL 1.0 GA Released

Dear Spring community,

As we promised in the Release Candidate blog post, we are pleased to announce that the Spring Integration Java DSL 1.0 GA is now available. As usual, use the Release Repository with Maven or Gradle, or download a distribution archive, to give it a spin.

See the project home page for more information.

First of all, we are glad to share with you that on Nov 12, 2014, DZone research recognized Spring Integration as the leader in the ESB / Integration framework space, leading with 42% marketshare, in a publication of their recent survey results. And the report is the most popular DZone Guide in November, with more than 12 000 downloads already! Don't miss it: very exciting. We hope the release of the Spring Integration Java DSL adds more excitement!.

Read more...

"Bootiful" Java EE Support in Spring Boot 1.2

In this blog, I want to look at - and demonstrate - some of the many new features in Spring Boot 1.2 that make the lives of those coming from, or otherwise building on, Java EE easier.

It's worth mentioning that a lot of this support has been possible with Spring before, of course, but now with Spring Boot 1.2, it's just so darned easy!

First, here's an example program with notes after.

package demo;

import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsTemplate;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import javax.jms.JMSException;
import javax.persistence.*;
import javax.transaction.Transactional;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.io.Serializable;
import java.util.Collection;
import java.util.logging.Logger;

@SpringBootApplication
public class Application {

    @Named
    public static class JerseyConfig extends ResourceConfig {

        public JerseyConfig() {
            this.register(GreetingEndpoint.class);
            this.register(JacksonFeature.class);
        }
    }

    @Named
    @Transactional
    public static class GreetingService {

        @Inject
        private JmsTemplate jmsTemplate;

        @PersistenceContext
        private EntityManager entityManager;

        public void createGreeting(String name, boolean fail) {
            Greeting greeting = new Greeting(name);
            this.entityManager.persist(greeting);
            this.jmsTemplate.convertAndSend("greetings", greeting);
            if (fail) {
                throw new RuntimeException("simulated error");
            }
        }

        public void createGreeting(String name) {
            this.createGreeting(name, false);
        }

        public Collection<Greeting> findAll() {
            return this.entityManager
                    .createQuery("select g from " + Greeting.class.getName() + " g", Greeting.class)
                    .getResultList();
        }

        public Greeting find(Long id) {
            return this.entityManager.find(Greeting.class, id);
        }
    }

    @Named
    @Path("/hello")
    @Produces({MediaType.APPLICATION_JSON})
    public static class GreetingEndpoint {

        @Inject
        private GreetingService greetingService;

        @POST
        public void post(@QueryParam("name") String name) {
            this.greetingService.createGreeting(name);
        }

        @GET
        @Path("/{id}")
        public Greeting get(@PathParam("id") Long id) {
            return this.greetingService.find(id);
        }
    }

    @Entity
    public static class Greeting implements Serializable {

        @Id
        @GeneratedValue
        private Long id;

        @Override
        public String toString() {
            return "Greeting{" +
                    "id=" + id +
                    ", message='" + message + '\'' +
                    '}';
        }

        private String message;

        public String getMessage() {
            return message;
        }

        public Greeting(String name) {
            this.message = "Hi, " + name + "!";
        }

        Greeting() {
        }
    }

    @Named
    public static class GreetingServiceClient {

        @Inject
        private GreetingService greetingService;

        @PostConstruct
        public void afterPropertiesSet() throws Exception {
            greetingService.createGreeting("Phil");
            greetingService.createGreeting("Dave");
            try {
                greetingService.createGreeting("Josh", true);
            } catch (RuntimeException re) {
                Logger.getLogger(Application.class.getName()).info("caught exception...");
            }
            greetingService.findAll().forEach(System.out::println);
        }
    }

    @Named
    public static class GreetingMessageProcessor {

        @JmsListener(destination = "greetings")
        public void processGreeting(Greeting greeting) throws JMSException {
            System.out.println("received message: " + greeting);
        }
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
Read more...

Spring Boot 1.2.0.RC2 Available Now

I am pleased to announce that the second release candidate for Spring Boot 1.2.0 is available now in the Spring milestone repository. This is mainly a bug fix release, although we did manage to sneak in a fantastic community contribution which adds support for Undertow as an embedded Servlet container.

For a complete list of changes, and for upgrade instructions, see the Spring Boot 1.2 Release Notes on the WIKI. The reference documentation has also been updated to cover new features.

As usual, please report any problems using the project Issue tracker.

Read more...