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 » Publish and SubScribe

Post new topic  Reply to topic Goto page Previous  1, 2, 3
 Publish and SubScribe « View previous topic :: View next topic » 
Author Message
fjb_saper
PostPosted: Fri Nov 07, 2008 2:51 am    Post subject: Reply with quote

Grand High Poobah

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

masteringmq wrote:
Quote:
Also in the topic uri when you subscribe you need to specify the subscription queue being QM2/something....


ok. You mean,
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/uj40080_.htm

Please advice.


Yes in part. Use the file based JNDI to define your topic connection factory. It will allow you to set the connection parms for QM2. In the broker qmgr info set QM1.

When defining the topic you can define 2 topics
A) publish topic with topic://mytopic
B) subscribe topic with topic://mytopic?xxxx
See in the script to define the subscribe topic you can specify a subscription queue in the form SYSTEM.JMS.ND..... as per the link above and specify the subscription qmgr.

On your qmgr you can then ALIAS some queue with that subscription name (so that the real queue name will not be in the SYSTEM range).

This should give you the ?xxxx information in the topic destination that you retrieve from JNDI.

Now if you ALIAS the SYSTEM.BROKER.CONTROL.QUEUE on QM2 and pretend QM2 is the broker qmgr you can inspect your subscription message using rfhutil or any other tool. You can also create a subscription message using rfhutil and inspect it using any other tool...(MO71)...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
masteringmq
PostPosted: Fri Nov 07, 2008 4:28 am    Post subject: Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

please note that im only using websphere mq 7.
Back to top
View user's profile Send private message
masteringmq
PostPosted: Fri Nov 07, 2008 5:55 am    Post subject: Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

I successfully route the publishing message to QM2. But when I attempt to subscribe I get a null value. I imagine that I need to browse the content of the message and read the value. This is what I think. Please advice.

/**
* @(#)PubSub.java
*
* PubSub application
*
* @author
* @version 1.00 2008/11/6
*/

import javax.jms.*;
import javax.naming.*;
import com.ibm.mq.jms.*;
import com.ibm.jms.JMSTextMessage;
import com.ibm.jms.JMSMessage;

public class PubSub
{
public static void main(String[] args) throws Exception
{
MQTopicConnectionFactory factory = new MQTopicConnectionFactory();
factory.setQueueManager("QM2");
MQTopicConnection connection = (MQTopicConnection)factory.createTopicConnection();
MQTopicSession session = (MQTopicSession)connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
MQTopic topic = (MQTopic)session.createTopic("Price/Fruit/Apple");

MQTopicSubscriber subscriber = (MQTopicSubscriber)session.createSubscriber(topic);
connection.start();
JMSMessage receivedMessage = (JMSMessage)subscriber.receive(1000);
System.out.println(receivedMessage);
session.close();
connection.close();
}
}
Back to top
View user's profile Send private message
masteringmq
PostPosted: Fri Nov 07, 2008 7:40 am    Post subject: Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

My imagination:

QM1

DEFINE TOPIC(FRUIT) TOPICSTR('Price/Fruit') DURSUB(YES)
DISPLAY TPSTATUS('Price/Fruit')

DEFINE TOPIC(ORANGES) TOPICSTR('Price/Fruit/Orange')
DEFINE QALIAS(PRICES) TARGTYPE(TOPIC) TARGET(ORANGES)

DEFINE SUB(FruitPrices) TOPICSTR('Price/Fruit/+') DEST(QM1.RQST)

Explanation:
QM1.RQSTIN is a remote queue to QM2. In QM2 I have a local queue with the name QM1.RQST. So the receiving application will retrieve the subscribe message from the local queue QM1.RQST, process the message and store it in a database. Is this the process?. Auto subscribe and routing of messages. So from a publishing application point of view, the application user will use the existing topic and publish. The topics will be created by the administrator. So it becomes a service to anyone who intends to publish. Please advice.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 07, 2008 12:41 pm    Post subject: Reply with quote

Grand High Poobah

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

Doing pub/sub with MQ V7 makes it so much easier because you can do pub/usb outside of JMS. Now if you want to use JMS check out again the link in my previous note and conform to the JMS standards.

Use a file based JNDI to create your topic, especially the subscription topic.
Retrieve it from JNDI. The way you are creating the topic will work for publication but is not feasible for subscription as you do not have access to QM1 to retrieve the subscription message. You could use the uri form for creating the topic but then you need to know what it is. Following my suggestion in the previous post is a little bit more work but it would show you the uri form for the subscription topic...

Of course in V7 you could have the admin do all this for you...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
masteringmq
PostPosted: Sat Nov 08, 2008 9:53 am    Post subject: Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

The other imagination is to form a cluster so that I can establish a distributed pub and sub model. App1 -> QM1 <-QM2 <- App2. QM1 and QM2 will function as a full repository in the cluster. So App2 can subscribe to the topic publish in QM1 via QM2. But if QM1 sits in USA and QM2 sits in Japan, is it advisable?. Please advice. I can imagine QM1 is a full repos sitting on it's own cluster in USA and QM2 is a full repos sitting on it's own cluster in Japan. Both can have a sender and receiver channel to each other and update each other.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Nov 08, 2008 6:53 pm    Post subject: Reply with quote

Grand High Poobah

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

Well I am not yet used to thinking cluster in pub/sub. I look at it more as a collective.
What you have in mind is feasible but keep in mind where people/apps are publishing and where people/apps are consuming...

To get a real pub/sub load balanced cluster going is a little bit more complex than that... Durable subscriptions ease the burden somewhat...

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
masteringmq
PostPosted: Sat Nov 08, 2008 7:02 pm    Post subject: Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

The publishing can be done in Japan and USA. So USA can subscribe to Japan and Japan can subscribe to USA. USA can subscribe to USA and Japan can subscribe to Japan. So USA can serve app in the western region and Japan can serve app in asian region.
Back to top
View user's profile Send private message
masteringmq
PostPosted: Sat Nov 08, 2008 9:28 pm    Post subject: Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

This is an example:


PS1

ALTER QMGR REPOS(CLUS2)

DEFINE QLOCAL(SHARED.RQSTIN)

DEFINE CHANNEL(PS1.PS2.DF) CHLTYPE(CLUSSDR) TRPTYPE(TCP) CONNAME('localhost(1415)') CLUSTER(CLUS2)

DEFINE CHANNEL(PS2.PS1.DF) CHLTYPE(CLUSRCVR) TRPTYPE(TCP) CONNAME('localhost(1416)') CLUSTER(CLUS2)

DEFINE TOPIC(FRUIT) TOPICSTR('Price/Fruit') DURSUB(YES) CLUSTER(CLUS2)

DEFINE TOPIC(ORANGES) TOPICSTR('Price/Fruit/Orange') CLUSTER(CLUS2)

DEFINE QALIAS(PRICES) TARGTYPE(TOPIC) TARGET(ORANGES) CLUSTER(CLUS2)

runmqlsr -m PS1 -t TCP -p 1416


PS2

ALTER QMGR REPOS(CLUS3)

DEFINE QLOCAL(SHARED.RQSTIN)

DEFINE CHANNEL(PS1.PS2.DF) CHLTYPE(CLUSRCVR) TRPTYPE(TCP) CONNAME('localhost(1415)') CLUSTER(CLUS3)

DEFINE CHANNEL(PS2.PS1.DF) CHLTYPE(CLUSSDR) TRPTYPE(TCP) CONNAME('localhost(1416)') CLUSTER(CLUS3)

DEFINE SUB(FruitPrices) TOPICSTR('Price/Fruit/+') DEST(SHARED.RQSTIN)

runmqlsr -m PS2 -t TCP -p 1415
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2, 3 Page 3 of 3

MQSeries.net Forum Index » IBM MQ Java / JMS » Publish and SubScribe
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.