In this scenario you will learn more about developing Spring Boot applications using the Red Hat Runtimes platform. We will be building a simple Spring Boot application which produces messages to and consumes messages from a Red Hat AMQ resource. AMQ provides fast, lightweight, and secure messaging for Internet-scale applications. AMQ components use industry-standard message protocols and support a wide range of programming languages and operating environments. AMQ gives you the strong foundation you need to build modern distributed applications.
In this scenario you learned about Spring Boot and how it can be used to create Message-driven applications using the JMS protocol. We will add additional scenarios that explain more how to build Spring Boot applications on OpenShift shortly, so check back to learn.openshift.com
To summarize: TODO
More background and related information on Red Hat OpenShift Application Runtimes and Eclipse Vert.x can be found here:
- Red Hat OpenShift Application Runtimes for Developers - Here you can get started with a project using different boosters and clone that project to your local computer. This also enables you to deploy your application on your own private OpenShift Container Platform or use OpenShift Online that is provided for free from Red Hat.
- Project Snowdrop homepage - This site has a lot of details of the work that Red Hat is doing to make Spring work great on Kubernetes and OpenShift.
Spring Boot Messaging on OpenShift
Import the code
Let's refresh the code we'll be using. Run the following command to clone the sample project:
cd /root/projects && rm -rf rhoar-getting-started && git clone https://github.com/openshift-katacoda/rhoar-getting-started && cd rhoar-getting-started/spring/spring-messaging
Review the base structure of the application
For your convenience, this scenario has been created with a base project using the Java programming language and the Apache Maven build tool.
As you review the content, you will notice that there are a lot of TODO comments. Do not remove them! These comments are used as markers for later exercises in this scenario.
1. Add JMS Dependencies
To add Spring JMS to our project all we have to do is to add the following line in
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-artemis</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency>
Along with the JMS dependencies this starter also brings in the ActiveMQ Broker. The Broker manages connections to the Queue and acts as the mediator between the application and ActiveMQ. The
jackson-databind dependency is for marshalling and unmarshalling the messages we will send. We will cover this later.
Right now the application will not compile because we are missing our Message object in the provided code. In our next step we'll fill in those required classes.
You have now successfully executed the first step in this scenario. In the next step we will setup the code necessary to send and receive JMS messages.