Before we can start writing code to take advantage of the JMS API, we need to configure some GlassFish resources. Specifically, we need to set up a JMS Connection Factory, a message queue, and a message topic.
Java EE 7 and Java EE 8 require all compliant application servers to provide a default JMS connection factory. GlassFish, being a fully compliant Java EE 8 application server (and the Java EE 8 reference implementation), complies with this requirement, so, strictly speaking, we don't really need to set up a connection factory. In many cases we may need to set one up, therefore in the following section, we illustrate how it can be done.