Book Image

Java EE 7 Development with NetBeans 8

By : David R Heffelfinger
5 (1)
Book Image

Java EE 7 Development with NetBeans 8

5 (1)
By: David R Heffelfinger

Overview of this book

Table of Contents (18 chapters)
Java EE 7 Development with NetBeans 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing a JMS message producer


In this section, we will develop a simple JSF application. One of the CDI managed beans in our application will produce a JMS message and send it to the queue we configured in the previous section.

Let's create a new Java class named JmsMessageModel. This class will store the message text that will be sent to the queue.

We should then annotate the class with the @Named annotation to make the class a CDI named bean. We should also annotate the class with the @RequestScoped annotation to give it a scope of request.

We should add a private variable named msgText of type String, along with its corresponding getter and setter methods.

Tip

Generating getter and setter methods

Getter and setter methods can be automatically generated by pressing Alt + Insert, and then selecting Getter and Setter

When finished, our class should look like this:

package com.ensode.jmsintro;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named
@RequestScoped...