Author |
Message
|
fjb_saper |
Posted: Fri Nov 07, 2008 2:51 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20763 Location: LI,NY
|
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 |
|
 |
masteringmq |
Posted: Fri Nov 07, 2008 4:28 am Post subject: |
|
|
Master
Joined: 20 Oct 2008 Posts: 200
|
please note that im only using websphere mq 7. |
|
Back to top |
|
 |
masteringmq |
Posted: Fri Nov 07, 2008 5:55 am Post subject: |
|
|
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 |
|
 |
masteringmq |
Posted: Fri Nov 07, 2008 7:40 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Fri Nov 07, 2008 12:41 pm Post subject: |
|
|
 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 |
|
 |
masteringmq |
Posted: Sat Nov 08, 2008 9:53 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Sat Nov 08, 2008 6:53 pm Post subject: |
|
|
 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 |
|
 |
masteringmq |
Posted: Sat Nov 08, 2008 7:02 pm Post subject: |
|
|
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 |
|
 |
masteringmq |
Posted: Sat Nov 08, 2008 9:28 pm Post subject: |
|
|
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 |
|
 |
|