# Creating Message-driven Beans

You can use a wizard to create a message-driven bean and add it to your project.

The message-driven bean wizard helps you create an Enterprise message-driven bean by walking you through the creation process and by providing you with output files that you can use or that you can modify for use with your application.

To create a message-driven bean, complete the following steps:

1. From the Java™ EE perspective, expand your EJB project in the Project Explorer view.
2. Right click on the Message-Driven Bean icon, and select New > Message-Driven Bean from the pop-up menu. The Create Message-Driven Bean wizard appears.
3. Follow the project wizard prompts.

General Information

Destination name
  This field provides the attribute mappedName to the @MessageDriven annotation. This attribute specifies the product-specific name to which the message-driven bean should be mapped. You can also use this attribute to specify the JNDI name of the destination from which the bean will consume messages.

Destination type
  To send a JMS message, we need a connection to the JMS provider and a destination address for the message. A JMS connection factory makes the connection to the provider possible. In JMS, messages are not sent directly to applications; they are sent to topics or queues:
  Queue:
    Queue is used as a destination for pointtopoint messaging. The point-to-point messaging model allows JMS clients to send and receive messages both synchronously and asynchronously via virtual channels known as queues. The p2p messaging model has traditionally been a pull- or polling-based model, where messages are requested from the queue instead of being pushed to the client automatically. A queue may have multiple receivers, but only one receiver may receive each message. Messages holding this queue are of MapMessages type, which stores the information about the email as name/value pair.
  Topic:
    Topic is used as a destination for publish/subscribe messaging. In publish-and-subscribe messaging, one producer can send a message to many consumers through a virtual channel called a topic. Consumers can choose to subscribe to a topic. Any messages addressed to a topic are delivered to all the topic's consumers. Every consumer receives a copy of each message. The pub/sub messaging model is a push-based model, where messages are automatically broadcast to consumers without them having to request or poll the topic for new messages. In the pub/sub messaging model, the producer sending the message is not dependent on the consumers receiving the message. Optionally, JMS clients that use pub/sub can establish durable subscriptions that allow consumers to disconnect and later reconnect and collect messages that were published while they were disconnected.

Transaction type
  The Transaction type field is used to specify whether the transaction is handled by the Container or the Bean.

Interfaces
  Message-driven beans usually implement the javax.jms.MessageListener interface. A MessageListener object is used to receive asynchronously delivered messages. This interface defines the onMessage() method. This method processes the JMS messages received by a bean.

- Message-driven Beans

Parent topic: EJB 2.x application development