EJB MDB project on jboss server issues

Hi,

I am trying to create simple EJB MDB project.

I created EJB project and then one more separate dynamic web project. I am using JBoss 5 server.

I was looking for JMS folder under

C:\softwares\jboss-5.0.0.CR2\jboss-5.0.0.CR2\server\default\deploy

I could not see jms folder there.

I want to open
jbossmq-destinations-services.xml
under the jms folder to edit it.

I could not see that file as well .

In jboss4.2 there used to be jms folder and under that there used to be
jbossmq-destinations-services.xml

Not sure where can I find
jbossmq-destinations-services.xml


Alternately i found destinations-services.xml under below folder

C:\softwares\jboss-5.0.0.CR2\jboss-5.0.0.CR2\server\default\deploy\messaging

I modified that as below by adding mbean at the end

<?xml version="1.0" encoding="UTF-8"?>

<!--
     Messaging Destinations deployment descriptor.

     $Id: destinations-service.xml 72251 2008-04-16 00:38:50Z clebert.suconic@jboss.com $
 -->

<server>

   <!--
      The Default Dead Letter Queue. This destination is a dependency of an EJB MDB container.
   -->

   <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=DLQ"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>      
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>
   
   <!--
      The Default Expiry Queue.
   -->

   <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=ExpiryQueue"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>      
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>   

 <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=ExpiryQueue2"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>      
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>
    <mbean code="org.jboss.jms.server.destination.TopicService"
      name="jboss.messaging.destination:service=Topic,name=GpTopicc"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>      
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>
</server>

Open in new window


I created 3 mdb's in ejb project and one servlet in web project.

mdb1 looks like below
<?xml version="1.0" encoding="UTF-8"?>

<!--
     Messaging Destinations deployment descriptor.

     $Id: destinations-service.xml 72251 2008-04-16 00:38:50Z clebert.suconic@jboss.com $
 -->

<server>

   <!--
      The Default Dead Letter Queue. This destination is a dependency of an EJB MDB container.
   -->

   <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=DLQ"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>      
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>
   
   <!--
      The Default Expiry Queue.
   -->

   <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=ExpiryQueue"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>      
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>   

 <mbean code="org.jboss.jms.server.destination.QueueService"
      name="jboss.messaging.destination:service=Queue,name=ExpiryQueue2"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>      
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>
    <mbean code="org.jboss.jms.server.destination.TopicService"
      name="jboss.messaging.destination:service=Topic,name=GpTopicc"
      xmbean-dd="xmdesc/Queue-xmbean.xml">
      <annotation>@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)</annotation>      
      <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
      <depends>jboss.messaging:service=PostOffice</depends>
   </mbean>
</server>


mdb2 looks like below
package com.demo;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Message-Driven Bean implementation class for: GpMDB02
 *
 */
@MessageDriven(
&#9;&#9;activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
                @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.GpTopicc")}, 
mappedName = "GpTopicc")
public class GpMDB02 implements MessageListener {

    /**
     * Default constructor. 
     */
    public GpMDB02() {
        // TODO Auto-generated constructor stub
    }
&#9;
&#9;/**
     * @see MessageListener#onMessage(Message)
     */
    public void onMessage(Message message) {
        // TODO Auto-generated method stub
    &#9;String textMessage;
&#9;&#9;try {
&#9;&#9;&#9;textMessage = ((TextMessage)message).getText();
&#9;&#9;&#9;System.out.println("GpMDB02 onMessage method received msg"+textMessage);
&#9;&#9;} catch (JMSException e) {
&#9;&#9;&#9;// TODO Auto-generated catch block
&#9;&#9;&#9;e.printStackTrace();
&#9;&#9;}
    &#9;
        
    }

}



mdb3 looks like below

package com.demo;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * Message-Driven Bean implementation class for: GpMDB02
 *
 */
@MessageDriven(
&#9;&#9;activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
                @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.GpTopicc")}, 
mappedName = "GpTopicc")
public class GpMDB02 implements MessageListener {

    /**
     * Default constructor. 
     */
    public GpMDB02() {
        // TODO Auto-generated constructor stub
    }
&#9;
&#9;/**
     * @see MessageListener#onMessage(Message)
     */
    public void onMessage(Message message) {
        // TODO Auto-generated method stub
    &#9;String textMessage;
&#9;&#9;try {
&#9;&#9;&#9;textMessage = ((TextMessage)message).getText();
&#9;&#9;&#9;System.out.println("GpMDB02 onMessage method received msg"+textMessage);
&#9;&#9;} catch (JMSException e) {
&#9;&#9;&#9;// TODO Auto-generated catch block
&#9;&#9;&#9;e.printStackTrace();
&#9;&#9;}
    &#9;
        
    }

}


servlet looks like beloe


package com.gp;

import java.io.IOException;

import javax.jms.JMSException;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.jms.TopicConnection;
import javax.jms.TopicConnectionFactory;
import javax.jms.TopicPublisher;
import javax.jms.TopicSession;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class GPServlet
 */
public class GPServlet extends HttpServlet {
&#9;private static final long serialVersionUID = 1L;

&#9;/**
&#9; * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
&#9; *      response)
&#9; */
&#9;protected void doGet(HttpServletRequest request,
&#9;&#9;&#9;HttpServletResponse response) throws ServletException, IOException {
&#9;&#9;// TODO Auto-generated method stub
&#9;&#9;System.out.println("entering GpServlet do get method--------");

&#9;&#9;try {
&#9;&#9;&#9;Context context = new InitialContext();
&#9;&#9;&#9;Topic topic = (Topic) context.lookup("topic/GpTopicc");
&#9;&#9;&#9;TopicConnectionFactory factory = (TopicConnectionFactory) context
&#9;&#9;&#9;&#9;&#9;.lookup("ConnectionFactory");
&#9;&#9;&#9;TopicConnection topicConnection = factory.createTopicConnection();
&#9;&#9;&#9;TopicSession topicSession = topicConnection.createTopicSession(
&#9;&#9;&#9;&#9;&#9;false, TopicSession.AUTO_ACKNOWLEDGE);
&#9;&#9;&#9;TextMessage textMessage = topicSession
&#9;&#9;&#9;&#9;&#9;.createTextMessage("msg from GpServlet");
&#9;&#9;&#9;TopicPublisher topicSender = topicSession.createPublisher(topic);
&#9;&#9;&#9;topicSender.send(textMessage);

&#9;&#9;} catch (NamingException | JMSException e) {
&#9;&#9;&#9;// TODO Auto-generated catch block
&#9;&#9;&#9;e.printStackTrace();
&#9;&#9;}
&#9;&#9;System.out.println("exiting GpServlet do get method--------");
&#9;}

}

Open in new window


I deployed both ejb project and web project.

My servlet sending text messages to topic on which 3 message driven beans(mdb) are listening.
When i go to servlet url
http://localhost:8080/GpWebProj/GPServlet

My console is not roling with the text messages instead i see some errors there as below

16:49:09,679 INFO  [STDOUT] entering GpServlet do get method--------
16:49:09,745 INFO  [ServerSessionEndpoint] Received send for ID:JBM-5099599c-6b94-408b-a5a5-b9c669f4cbb7 reliable: true
16:49:09,745 INFO  [ServerSessionEndpoint] Done send
16:49:09,745 INFO  [STDOUT] exiting GpServlet do get method--------



Instead I would like to see something like below


16:49:09,679 INFO  [STDOUT] entering GpServlet do get method--------
GpMDB01 onMessage method received msg msg from GpServlet
GpMDB02 onMessage method received msg msg from GpServlet
GpMDB03 onMessage method received msg msg from GpServlet
16:49:09,745 INFO  [STDOUT] exiting GpServlet do get method--------

I am not sure where is the issue. How can i fix this issue

Please advise. Any links, sample code, resources, ideas highly appreciated. thanks in advance
MDBProjStr.jpg
LVL 7
gudii9Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
gudii9Connect With a Mentor Author Commented:
I found the solution

I have to go deep into


C:\softwares\jboss-5.0.0.CR2\jboss-5.0.0.CR2\server

To see JMS folder and also XML file. I also tweaked the code to get the required output. thank you
0
 
gudii9Author Commented:
is jbossmq is also MoM(message oriented middleware) system similar to ActiveMQ from Apache(opensource), MQSeries from IBM(commercial). Please advise. What other open source/commercial MoMs are available out there. Please advise
0
 
gudii9Author Commented:
any response
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.