Apache Geronimo Jndi Naming and Java source Connection pool, part 2nd

Source: Internet
Author: User
Tags resource

Using the Java Message Service

Creating and accessing a JMS resource group using the Geronimo console

Brief introduction

JMS is an API that allows software components to create, send, receive, and read messages. These messages do not require human consumption. Of course, they are a way of communicating between software applications. Applications that interact through messages have the advantage of being loosely coupled because changes in one system do not have an impact on another system as long as both sides use the same message format. The JMS API is implemented through a third party and provides the benefits of asynchronous communication and reliable message delivery. Communication is asynchronous, because a component or client can send or receive messages without waiting for the recipient's approval. Communication is still reliable, because the system guarantees that messages are delivered once and only once, using JMS. To receive a message, the application requires a JMS listener that is used to listen for messages at the specified destination.

Session beans and entity beans can send JMS messages, but only those JMS messages can be received synchronously. It is possible to bind server-side resources because the component must wait for the message to be received. In Java 2 Platform, Enterprise Edition (EE) 1.3, a new Enterprise JavaBean (EJB)--mdb was introduced. This EJB is like a JMS listener, allowing the Java application to receive messages asynchronously.

The customer Service utility that is described in this article is a simple WEB application that allows users to save basic customer information to a database. We'll build the utility using the Apache Ant 1.6.5 and Java 1.4.2_10 and deploy it to Geronimo 1.1 with Tomcat. You will also use both the Apache Derby database and the ActiveMQ JMS provider, as they are included with Geronimo.

This section, part 2nd of this series of tutorials, continues with the Customer Service utility, which is discussed in part 1th. This time, the content that all customers are interested in is parsed and compared against a list of known topics. These topics will be divided into special interest groups. If the interest of a given customer matches a known topic, the group and the customer's e-mail address are saved to the database for better service in the future. To implement this functionality using JMS, the system sends a message after the group is found. The MDB is used to receive these messages, which in turn invokes the entity bean to store the content in the database. The next section describes how to use the Geronimo console to create a JMS resource group.

Set Apache Geronimo

The Geronimo console can manage Java components in a user-friendly manner. When Geronimo is started, you can access the Geronimo console located in Http://localhost:8080/console. The default user name and password are system and manager respectively.

You need to create a new database table that is required to store special interest groups that your customers may be interested in:

Click the DB Manager link at the bottom of the left Console navigation panel to display the Derby database Manager.

Select Customerservicedatabase in the Use DB drop-down menu to create the database table.

Then cut and paste the contents of Listing 1 into the SQL command/s text box, and then click the Run SQL button.

Listing 1. SQL Script Customerservice-part2.sql

create table interestgroup (
   clientid integer primary key,
   groupname varchar(20),
   emailaddress varchar(30)
);

The customer service database should now have two tables: Customers and Interestgroup.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.