users@glassfish.java.net

Re: Glassfish jms usage with richfaces 4.2 a4j push

From: <forums_at_java.net>
Date: Mon, 15 Oct 2012 19:56:35 -0500 (CDT)

Hi Timo, You can refer to JMS Message Selectors [1] for the concept of
filter. Example: At the publisher side: ... ObjectMessage objMessage =
session.createObjectMessage(messageInfo); objMessage.setStringProperty("uid",
this.uid); //uid gotten from db publisher.publish(objMessage); Then at the
subscriber side: TopicConnectionFactory tcf = (TopicConnectionFactory)
ctx.lookup("jndi name of TopicConnectionFactory"); Topic topic = (Topic)
ctx.lookup("jndi name of Topic"); TopicConnection tc =
tcf.createTopicConnection(); TopicSession session =
tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); String
messageSelector = "uid = '" + this.uid + "'"; //uid gotten from db
TopicSubscriber subscriber = session.createSubscriber(topic, messageSelector,
false); Message msg = subscriber.receive(); This can filter only the messages
with desired uid being received by the subscriber. --- David

[1] http://docs.oracle.com/javaee/5/tutorial/doc/bnceh.html

--
[Message sent by forum member 'liang.x.zhao']
View Post: http://forums.java.net/node/891195