[jboss-user] [JBoss Messaging] - Re: JOBSS Messaging POC
ssjboss
do-not-reply at jboss.com
Thu Apr 24 08:54:15 EDT 2008
i changed jndi props as
| ### JBossNS properties
| java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
| java.naming.provider.url=jnp://10.12.170.180:1099
| java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
>From another end(system) how can i see the messages in another system ?
my q listener code is
| import java.io.*;
| import java.util.*;
| import java.util.Date;
| import javax.transaction.*;
| import javax.naming.*;
| import javax.jms.*;
|
| import java.util.Properties;
| 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.jms.Queue;
|
|
| public class QBrowser
| {
| QueueConnectionFactory qconFact;
| QueueConnection qcon;
| QueueSession qsession;
| /* in place of receiver we are using qbrowser here.*/
| private QueueBrowser qbrowser;
| private Queue queue;
|
| public void init(Context ctx, String queueName) throws NamingException, JMSException
| {
| /* get the connection and create the connection object*/
| qconFact=(QueueConnectionFactory) ctx.lookup("MyExampleConnectionFactory");
| qcon=qconFact.createQueueConnection();
| /* using connection create a non transactional session */
| qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
| /* look up for the destination ie queue */
| queue = (Queue) ctx.lookup(queueName);
| // we are using qbrowser here
| qbrowser = qsession.createBrowser(queue);
|
|
|
| qcon.start();
| }
|
| public void displayQueue()
| throws JMSException
| {
| Enumeration e = qbrowser.getEnumeration(); // gets list of messages.
| Message m = null;
|
| if (! e.hasMoreElements()) {
| System.out.println("There are no messages on this queue.");
| } else {
|
| int ii =0;
| while (e.hasMoreElements()) {
| ii++;
| m = (Message) e.nextElement();// display header
|
| System.out.println("Message ID " + m.getJMSMessageID() +
| " delivered " + new Date(m.getJMSTimestamp()) +
| " to " + m.getJMSDestination());
| System.out.println("\tMessage type " + m.getJMSType() + "Number >>>>" +ii);
|
| if (m instanceof TextMessage) {
| System.out.println("\t TextMessage \"" + ((TextMessage)m).getText() + "\"");
| }
| }ii=0;
| }
| }
|
| public void close()
| throws JMSException
| {
| qbrowser.close();
| qsession.close();
| qcon.close();
| }
|
|
| public static void main(String[] args)
| throws Exception
| {
| //InitialContext ic = getInitialContext();
| Properties props = new Properties();
| props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
| props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
| props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
|
| Context ic = new InitialContext(props);
|
| QBrowser qb = new QBrowser();
| System.out.println(" Trying to initialize the QBrowser");
| qb.init(ic, "queue/testQueue");
| qb.displayQueue();
| qb.close();
| }
|
| }
i given all jars acc to user guide.( i did't not found any trove.jar in this path $JBOSS_HOME/server/<SERVER_NAME>/lib/trove.jar)
Please tell me what i am missing.
------
SS
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4146493#4146493
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4146493
More information about the jboss-user
mailing list