Link to home
Create AccountLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

middleware infrastructure destination configuration

Hi,

I started jboss server from eclipse. I went to destination-service.xml under folder C:\softwares\jboss-5.0.0.CR2\jboss-5.0.0.CR2\server\default\deploy\messaging

I copy pasted last entry and changed the name as below


   <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>




I refreshed the destination page under jmx-console to see the new destination.


My question is configuring the destination is developer job or is it is job of administrator.

What info conncetion-factories.cml file consist of?

I randomly selected one entry
java:/ConnectionFactory
to create the web client and Message Driven Bean MDB.

My web client servlet code is as below



package com.gp;

import java.io.IOException;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.Context;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



/**
 * Servlet implementation class ClientServlet
 */
public class ClientServlet extends HttpServlet {
&#9;private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ClientServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

&#9;/**
&#9; * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
&#9; */
&#9;protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
&#9;&#9;// TODO Auto-generated method stub
&#9;&#9;
&#9;&#9;try {
&#9;&#9;&#9;Context context=new InitialContext();
&#9;&#9;&#9;
&#9;&#9;&#9;QueueConnectionFactory cf=(QueueConnectionFactory) context.lookup("java:/ConnectionFactory");
&#9;&#9;    Queue queue=(Queue) context.lookup("/queue/ExpiryQueue2");
&#9;&#9;    Connection conn=cf.createConnection();
&#9;&#9;    Session session=conn.createSession(false, 0);
&#9;&#9;    
&#9;&#9;    MessageProducer qs=session.createProducer(queue);
&#9;&#9;    
&#9;&#9;    TextMessage msg=session.createTextMessage("gpp");
&#9;&#9;    qs.send(msg);
&#9;&#9;    
&#9;&#9;} catch (NamingException e) {
&#9;&#9;&#9;// TODO Auto-generated catch block
&#9;&#9;&#9;e.printStackTrace();
&#9;&#9;} catch (JMSException e) {
&#9;&#9;&#9;// TODO Auto-generated catch block
&#9;&#9;&#9;e.printStackTrace();
&#9;&#9;}
&#9;}


}



my MDB MessageConsumer looks like below where i have overriden method onMessage
package com.gpp;

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

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

    /**
     * Default constructor. 
     */
    public MsgConsumer() {
        // TODO Auto-generated constructor stub
    }
&#9;
&#9;/**
     * @see MessageListener#onMessage(Message)
     */
    public void onMessage(Message message) {
        // TODO Auto-generated method stub
    &#9;System.out.println("msg came");
        
    }

}

Open in new window




I deployed and run on server both web application(named JMSClientWeb) and MDB project(named JMSClientEJB)


I do not see my message in output console. How do i run and make sure my message comes to the consumer.

Please advise. Any ideas, resources, sample code highly appreciated. thanks in advance
1.jpg
2.jpg
3.jpg
4.jpg
5.jpg
6.jpg
7.jpg
8.jpg
JMSClient5.jpg
JMSClient6.jpg
JMSClient7.jpg
JMSClient8.jpg
JMSClient9.jpg
JMSClient10.jpg
JMSClient11.jpg
Avatar of girionis
girionis
Flag of Greece image

Have a look here: http://blog.coffeebeans.at/?p=182 for a tutorial.
Avatar of gudii9

ASKER

Under C:\softwares\jboss-5.0.0.CR2\jboss-5.0.0.CR2\server\default\deploy\jbossmq-destinations-services.xml

I added last mbean element as below for topic at the end of the file




view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
    <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>    



For configuring queue i added below mbean as last but one element

view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
 <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>    







view plaincopy to clipboardprint?
Note: Text content in the code blocks is automatically word-wrapped
<?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>    





I was looking this link

http://grwebservice.blogspot.in/2009/06/message-driven-bean.html 

do I need to configure prop file as below.

EJBJNDI.prop
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.namingrg.jnp.interfaces
java.naming.provider.url=localhost:1099

I am not configuring property file as above. Is that is issue. Can you please advise.
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of gudii9

ASKER

what is the importance of JNDI int his context of MoM and Queue and Topic. what are administered objects. what is admin tool used to configure them to read through JNDI. Where the Application server comes into picture. Please advise
Well, if you don't use JNDI how can you locate the queues and the topics? You deploy them in the server and then you have a name that points to them (this is the JNDI name). So you use this name to obtain access to your JMS components.