I'm developing a web app using JBoss 6.1 as backend.
I created a message driven bean with the "destination" property: "queue/searchtabQueue" and "destination type" property "javax.jms.Queue".

As described under https://community.jboss.org/wiki/HowToCreateJMSQueuetopicInAS6 I managed to create my queue "queue/searchtabQueue" ("searchtab-hornetq-jms.xml"):

<configuration xmlns="urn:hornetq"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
     <queue name="searchtabQueue">
     <entry name="/queue/searchtabQueue"/>
   </queue>
</configuration>

After the deployment, in the admin console, I see my queue under "JMS Queues" with status "up".

In a stateless bean I'm doing the look up for the queue, which works correct, and also the sending throws no exception:

Context ctx = new InitialContext(p); // Create the initial context
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
Queue queue = (Queue) ctx.lookup("queue/searchtabQueue");
Connection connect = factory.createConnection();
javax.jms.Session session = connect.createSession(false, 0);
MessageProducer sender = session.createProducer(queue);
TextMessage msg = session.createTextMessage();
msg.setText("abc");
sender.send(msg);
connect.close();

But the onMessage method of the message driven bean is not called.

What am I missing?

Thanks alot in advance

Wolfgang

Update: My MDB-Code:

My message driven bean has the following code:

@MessageDriven(activationConfig =  {
        @ActivationConfigProperty(propertyName = "destinationType",
                                  propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination",
                                  propertyValue = "queue/searchtabQueue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode",
                                  propertyValue = "Auto-acknowledge")
    })
public class SearchTableBean implements MessageListener {

   public void onMessage (Message message) {
  }
}
有帮助吗?

解决方案

Now it is working, I changed a view things.

Lookup code:

Context ctx = new InitialContext(p); // Create the initial context
Queue queue = (Queue) ctx.lookup("java:jboss/exported/jms/queue/searchtab");
QueueConnectionFactory factory = (QueueConnectionFactory)
  ctx.lookup("ConnectionFactory");
QueueConnection connect = factory.createQueueConnection();
javax.jms.QueueSession session = connect.createQueueSession(false,
  QueueSession.AUTO_ACKNOWLEDGE);
TextMessage msg = session.createTextMessage("Hello World");
QueueSender sender = session.createSender(queue);
sender.send(msg);  
connect.close();

Queue creation xml file:

<configuration xmlns="urn:hornetq"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
   <queue name="searchtabQueue">
      <entry name="queue/searchtab"/>   
      <entry name="java:jboss/exported/jms/queue/searchtab"/>
   </queue>
</configuration>      

MDB code:

@MessageDriven(activationConfig =  {
        @ActivationConfigProperty(propertyName = "destinationType",
                                  propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination",
                                  propertyValue = "queue/searchtab"),       
        @ActivationConfigProperty(propertyName = "acknowledgeMode",
                                  propertyValue = "Auto-acknowledge")
    })
public class SearchTableBean implements MessageListener {
  public void onMessage (Message message) {
    System.out.println("abc");
 }  

其他提示

According to the specs, you must call

connect.start(); 

to activate the message delivery process.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top