ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Create a Topic and subscriber to a Topic

Post new topic  Reply to topic
 Create a Topic and subscriber to a Topic « View previous topic :: View next topic » 
Author Message
nilendu
PostPosted: Wed Aug 27, 2008 10:56 am    Post subject: Create a Topic and subscriber to a Topic Reply with quote

Novice

Joined: 14 Sep 2006
Posts: 16

Hi All,

I am using JMS API to create a Topic and Subscribe to the Topic.
My question is how do we specify the queue name where the messages for a particular Topic be sent?

When I use JMS API as follows
-----------------------
TopicSession tSess = tConn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE );
Topic t = (Topic)tSess.createTopic("test");
tSub = tSess.createSubscriber(t);
msg = (TextMessage)tSub.receive();
-----------------------
I cannot specify the QUEUE where the messages for the topic 'test' be sent. I believe they go to the broker default queue.

Please suggest!!!

Thanks,
Nilendu
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed Aug 27, 2008 12:17 pm    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

Look at the Using Java manual. They are "buried" in the definition of the topic connection factory and topic by JMSAdmin.

There is a mqjmssub.java and mqjmspub.java sample at:

http://www-304.ibm.com/jct09002c/isv/tech/sampmq.html

that you might find helpful.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
fjb_saper
PostPosted: Wed Aug 27, 2008 1:00 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Try :
Topic t = session.createTopic("topic://mytopic?brokerDurSubQueue=SYSTEM.JMS.D.MYALIAS&brokerVersion=1")

Where SYSTEM.JMS.D.MYALIAS is an alias queue pointing to the real queue you want to receive your subscription on.
Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
nilendu
PostPosted: Wed Aug 27, 2008 4:19 pm    Post subject: Reply with quote

Novice

Joined: 14 Sep 2006
Posts: 16

Hi fjb_saper,

Nope this didnt work. I created an ALIAS queue and made it part of my
createTopic() call -
topic://test?brokerDurSubQueue=MYALIAS&brokerVersion=1

These messages did arrive at the base Queue for MYALIAS. Where can I find the list of available parameter to topic://topicname URI?


I did make some progess though. When I burried the pubQueue name in the TopicConnectionFactory the message arrived at my pubQueue.

However, this is not what I want. I cannot ceate new connectionFactory object everytime I change my publisher queue.

--------------------
MQTopicConnectionFactory tcf = new MQTopicConnectionFactory();
tcf.setHostName("localhost");
tcf.setPort(1414);
tcf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
tcf.setQueueManager("QM_jxwgti4x9z9d1");
tcf.setChannel("SYSTEM.DEF.SVRCONN");
tcf.setBrokerPubQueue("TEST"); TopicConnection tConn;
tConn = tcf.createTopicConnection();
TopicSession tSess = tConn.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
Topic topic = (Topic)tSess.createTopic("topic://test");
MQTopicPublisher tp = (MQTopicPublisher)tSess.createPublisher(topic);
MessageProducer mprod = tSess.createProducer(d);
JMSTextMessage msg = (JMSTextMessage)tSess.createTextMessage("Hi Nilendu");
tp.publish(msg)
-----------------------

What am I missing in the Topic URI?

Thanks in advance to all,
Nilendu
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Aug 27, 2008 9:10 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

You got it all wrong.
What you want is the subscriber queue. (final destination of the published message).
You set this by creating the Topic as I showed you. You need to subscribe with this topic. Then all your publications for this topic will be sent to the subscription queue. You may be able to do this differently using RFHUtil(c)..., (played around with RFHUtil(c) and alias queues and inspected the message... this is how I found out the specific URI form for the topic...) however if you want to specify the queue dynamically at subscription time you will need to do something like what I showed you.

Remember that to change the destination queue you need to change the subscription. Also for the queue name the start SYSTEM.JMS.D. is mandatory for durable subscription (see pub/sub manual).
I went around it by creating an alias for my true base queue.

Once this is done you can either receive messages to the topic or you can receive messages to the queue. Receiving messages to the queue will give them to you in arrival order (or priority) regardless of topic. If you want them by topic use a topic receiver.

Finally read the documentation for version 7. There are a lot of changes in pub/sub and you can have the admin subscribe you (I think).

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
nilendu
PostPosted: Thu Aug 28, 2008 1:45 pm    Post subject: Reply with quote

Novice

Joined: 14 Sep 2006
Posts: 16

Hi fjb_saper,

Thanks for your help. I used the rfhutil today.

Here are the steps I followed
1) selected reg pub ->

registered a publisher and provided a topic name 'test'
used SYSTEM.BROKER.CONTROL.QUEUE as the queue name
provided my SYSTEM.BROKER.D.MYALIAS.QUEUE as the subscription Queue

2) Selected Publish tab

provided the topic name - 'test'
Queue name as SYSTEM.BROKER.CONTROL.QUEUE

3) Selected Sub tab

provided the topic name 'test'
SubName - SYSTEM.BROKER.D.MYALIAS.QUEUE

And then wrote a message. I can see the message waiting at SYSTEM.BROKER.CONTROL.QUEUE
when I end the broker. As soon as I start the broker the messages move from my borker control
queue but doesnt apprear in my alias/base queue.

Wondering what's going wrong here.
I have checked that my alias/base queue config is correct since when I use p2p mode and puta message
onto alias queue, the message arrives at my base queue.

Please advice....

Thanks,
Nilendu
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 28, 2008 3:14 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

nilendu wrote:
Hi fjb_saper,

Thanks for your help. I used the rfhutil today.

Here are the steps I followed
1) selected reg pub ->

registered a publisher and provided a topic name 'test'
used SYSTEM.BROKER.CONTROL.QUEUE as the queue name
provided my SYSTEM.BROKER.D.MYALIAS.QUEUE as the subscription Queue

2) Selected Publish tab

provided the topic name - 'test'
Queue name as SYSTEM.BROKER.CONTROL.QUEUE

3) Selected Sub tab

provided the topic name 'test'
SubName - SYSTEM.BROKER.D.MYALIAS.QUEUE

And then wrote a message. I can see the message waiting at SYSTEM.BROKER.CONTROL.QUEUE
when I end the broker. As soon as I start the broker the messages move from my borker control
queue but doesnt apprear in my alias/base queue.

Wondering what's going wrong here.
I have checked that my alias/base queue config is correct since when I use p2p mode and puta message
onto alias queue, the message arrives at my base queue.

Please advise....

Thanks,
Nilendu

2) You need to publish a message. The default pub queue is something like SYSTEM.BROKER.DEFAULT.STREAM but I would check the pub/sub manual.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Create a Topic and subscriber to a Topic
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.