JMS is not very familiar with, after a few days finally have a point of thought. Here are two programs, add a queue-example-service.xml configuration file is very simple, complex point in the future said.
A destination is the "object on" JBOSSMQ server that clients
Use to send and receive messages. There are two types of
Destination objects, queues and topics.
public class Examplemdb implements MessageListener
{
public void OnMessage (message recvmsg)
{
System.out.println ("----------------");
SYSTEM.OUT.PRINTLN ("Received message");
System.out.println ("----------------");
}
}
The English comment is the one I found in the JBoss 4 Application Server Guide to know that destination is responsible for sending and receiving messages (message) in the JBoss server. Destination is divided into two different ways according to how the message is published: Queues and topics.
The topic release allows One-to-many, or many-to-many, communication channels, the message creator is called publisher, and the message recipient is called subscriber, so it is called a publish/subscribe (publish/subscribe).
Queue is another way to allow only one message to be sent to a customer. A sender places a message in a message queue, the recipient extracts from the queue and gets the message, and the message disappears in the queue. After the first recipient extracts and gets the message, the other person cannot get it. Also known as the point-to-point point.
About Activateconfig with Queue-example-service.xml, here as long as you know the destination on the line. From the program can see its interface for MessageListener can guess this program is responsible for listening to messages, after receiving the message to print. That's it:
Client.java
Package org.jboss.tutorial.mdb.client;
Import Javax.jms.Queue;
Import javax.jms.QueueConnection;
Import Javax.jms.QueueConnectionFactory;
Import Javax.jms.QueueSender;
Import javax.jms.QueueSession;
Import Javax.jms.TextMessage;
Import Javax.naming.InitialContext;
public class Client
{
public static void Main (string[] args) throws Exception
The first thing I feel is that this XML is related to JMX, and the Mbean represents the Manage bean, which is not a big problem.
The role of this XML is to instance a queue, the name is tutorial (can be changed), and then by jmx-console this console unified management, run this program can be http://localhost:8080/ Jmx-console/htmladaptor?action=inspectmbean&name=jboss.mq.destination%3aservice%3dqueue%2cname%3dtutorial (I hope you haven't come and changed the configuration above, I can't find a way to get you to the address of this queue faster, too much.) To see the queue on this profile, JBoss already has a couple of queue.
Then you define a Jndi,client.java and you can have a lookup.
Here attached log4j.properties in Jboss-ejb-3.0_preview_5.zip without this always shows a lack of appender. With this, a record.log log file will be generated in this directory.
Although it's two programs, it took some time since I didn't know much about JMS before. Finding relevant information is important for understanding the above issues.
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.