Solved

EJB MDB project on jboss server issues

Posted on 2013-05-18
6
996 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Three Considerations for Containers

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read our article on Experts Exchange.

Question has a verified solution.

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

There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

632 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