Topic tempTopic = session.createTemporaryTopic();
TopicSubscriber subscriber = session.createSubscriber(tempTopic);
subscriber.setMessageListener(this);
TopicPublisher publisher = session.createPublisher(topic);
TextMessage tm = session.createTextMessage();
tm.setJMSType("log");
tm.setStringProperty("ReplyTo", tempTopic.getTopicName());
In the last line, I can't use JMSReplyTo as property's name, why? The
exception is :
weblogic.jms.common.MessageFormatException: Illegal property name,
'JMSReplyTo'
In my MDB's onMessage() method, I use the following code:
Topic topic = session.createTopic(tm.getStringProperty("ReplyTo"));
TopicPublisher publisher = session.createPublisher(topic);
and I got the following exception :
weblogic.jms.common.JMSException: Invalid destination name:
WSStoreForwardInternalJMSServermyserver.TemporaryTopic92
at weblogic.jms.frontend.FEManager.destinationCreate(FEManager.java:214)
at weblogic.jms.frontend.FEManager.invoke(FEManager.java:539)
at
weblogic.jms.dispatcher.Request.wrappedFiniteStateMachine(Request.java:609)
at
weblogic.jms.dispatcher.DispatcherImpl.dispatchSyncNoTran(DispatcherImpl.jav
a:212)
at weblogic.jms.client.JMSSession.createDestination(JMSSession.java:1961)
at weblogic.jms.client.JMSSession.createTopic(JMSSession.java:1353)
at com.yinbo.test.LogBean.sendToken(LogBean.java:67)
at com.yinbo.test.LogBean.onMessage(LogBean.java:44)
at weblogic.ejb20.internal.MDListener.execute(MDListener.java:382)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
What should I do? Thanks!
(1) Any message property name that begins with "JMS_", "JMSX", or
that matches a message header field name is reserved. Thus
the "Invalid" exception.
(2) The createTopic() call takes a vendor specific format (each
vendor is different). This is the first time I've heard of someone
trying it with temp destinations given that there is a standard
approach to passing destination references directly
in the message header JMSReplyTo field (see (3) below).
It might work to use
"your-JMS-server-name/" + tempdestination.getName()
or even
"./" + tempdestination.getName().
which are the BEA documented formats for createTopic().
(The latter requires that the destination
is running on the same server as the client's
JMS connection host.)
(3) To pass a reference to a temporary topic, pass it as a "Destination"
object in the "JMSReplyTo" header field of the message of the message,
and then get it directly on the receiving end via "msg.getJMSReplyTo()".
This will work with any JMS vendor.
Tom
Want your help.Thanks!
"Tom Barnes"
<pleasereplyinnewsgroup.webl...@newsgroups.bea.com>
???? news:40571A83...@newsgroups.bea.com...
"jmsReplyTo.toString()" returns the JMX mbean name of
the temporary topic - not a JNDI name. This is similar to
the issue in the previous post of this thread. The returned
name simply will not work in a context lookup, (nor will
the returned name work directly in a call to "createTopic()"
-- although it might work in createTopic() if you prepend it with
jmservername + "/".)
Anyhow, There is no need to toString() the reply-to Topic,
or to call "getTopicName()" on it, or to use the String
name at all. You already have a direct reference to the
reply topic right where you need it.
Edit your code as below:
Tom
Wisen wrote:
> Tom,
> Thank you for your reply.
> This time, I follow your advice,using the tm.setJMSReplyTo(tempTopic) method
> in my client.
> And in my MDB, I use tm.getJMSReplyTo(), codes as following :
> Context ctx = new InitialContext(System.getProperties());
> TopicConnectionFactory factory = (TopicConnectionFactory)
> ctx.lookup("javax.jms.TopicConnectionFactory");
> TopicConnection connection = factory.createTopicConnection();
> TopicSession session = connection.createTopicSession(false,
> TopicSession.AUTO_ACKNOWLEDGE);
> System.err.println("Message Reply To : [" + jmsReplyTo.toString() +
> "]");
Remove the following lines:
> String replyTo = jmsReplyTo.toString();
> System.err.println("replyTo = " + replyTo);
> Topic topic = (Topic) ctx.lookup(replyTo);
Change "topic" to "tm.getJMSReplyTo()" in the following line: