Solved

EJB MDB project on jboss server issues

Posted on 2013-05-18
6
925 Views
Last Modified: 2013-12-02
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
0
Comment
Question by:gudii9
  • 3
6 Comments
 
LVL 7

Author Comment

by:gudii9
ID: 39199853
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
 
LVL 7

Author Comment

by:gudii9
ID: 39213432
any response
0
 
LVL 7

Accepted Solution

by:
gudii9 earned 0 total points
ID: 39261004
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now