| Author |
JMS queue problem
|
shankha bhattacharya
Greenhorn
Joined: Apr 20, 2007
Posts: 12
|
|
I have a JMS Queue in My jboss. Now from my standalone Java class I send message (in the XML format )to the queue. as queue is used for P2P communication.So there should be a dedicated listener to that queue to get the message. If I have more than 2 listeners to that Queue, Can It be possible to send the message to a particular Listener Based on the Message Content?
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
|
I'm promoting this topic to the intermediate forum.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Medha Jhunjhunwala
Greenhorn
Joined: Sep 06, 2007
Posts: 9
|
|
Have you tried message selectors? -Medha
|
 |
shankha bhattacharya
Greenhorn
Joined: Apr 20, 2007
Posts: 12
|
|
yes I tried it and able to solve it. Code sample : message to queue. -------------------------------- try { Context ctx = new InitialContext(env); /* ctx = new InitialContext(); */ cf = (QueueConnectionFactory) ctx.lookup("/ConnectionFactory"); destination = (Queue) ctx.lookup("queue/testQueue"); connection = cf.createQueueConnection(); session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); sender = session.createSender(destination); message = session.createTextMessage(); String name ="shankha1"; message.setText("Hello World --- --- --- "+name); //message.setJMSType("COMMUNICATOT"); message.setStringProperty("COMMUNICATOR",name); System.out.println("Sending Message."); sender.send(message); connection.close(); System.out.println("Done."); } catch (NamingException e) { e.printStackTrace(); } catch (JMSException e) { e.printStackTrace(); } Code sample : Queue to message ------------------------------- Context ctx = new InitialContext(env); cf = (QueueConnectionFactory) ctx.lookup("/ConnectionFactory"); destination = (Queue) ctx.lookup("queue/testQueue"); connection = cf.createQueueConnection(); session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); //String selector = "to = '" + System.getProperty("user.name") + "'"; String selector="COMMUNICATOR='shankha1'"; receiver = session.createReceiver(destination,selector); System.out.println("Waiting For A Message. QueueToMessage "); //connection.start(); message = (TextMessage) receiver.receive();
|
 |
 |
|
|
subject: JMS queue problem
|
|
|