Author |
Message
|
RogerLacroix |
Posted: Fri May 13, 2016 2:05 pm Post subject: Sample MQPubSubApiSample throws RC 2085 |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
All,
I decided to play around with Topics and Subscriptions this afternoon.
I found MQPubSubApiSample.java in the MQ samples directory but the subscriber throws RC of 2085 (unknown object).
I checked the MQ Knowledge Center for MQPubSubApiSample and there is nothing about configuring topics/subscriptions. It just says to update the connection information (if necessary) then run it. (Note: I'm on Win 7 with MQ v8.0.0.4)
So what am I doing wrong?
Does anyone have any working Pub/Sub Java applications that they want to share?
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
hughson |
Posted: Fri May 13, 2016 3:21 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Feels rather odd to be answering a Java question as I'm not known for my Java skills!
I can't run this sample because I haven't got working Java on the machine I'm on right now, but I looked in the java file at the code and saw this:-
Code: |
/**
* Demonstrates using the publish/subscribe API introduced into WebSphere MQ v7 Use system
* properties to define the parameters :-
* <ul>
* <li>com.ibm.mq.pubSubSample.queueManagerName
* <li>com.ibm.mq.pubSubSample.topicObject (default is "myTopicObject")
* <li>com.ibm.mq.pubSubSample.subscriberCount (default is 3)
* <ul>
*/ |
So do you have a topic object called "myTopicObject"?
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
RogerLacroix |
Posted: Fri May 13, 2016 7:25 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi Morag,
Yeah, setting those JVM environment variables allows the user to specify different values. I tried a different topic (i.e. roger) but it still failed with RC of 2085.
I've never played around with topics before, I guess I need to find a "How To" book somewhere because the simple stuff has stumped me.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
hughson |
Posted: Fri May 13, 2016 8:27 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Did you try it with the myTopicObject? Did that work?
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
tczielke |
Posted: Sat May 14, 2016 4:20 am Post subject: |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
It looks like the MQPubSubApiSample program uses code that requires the topic to be defined in the queue manager:
Code: |
MQDestination destinationForGet = queueManager.accessTopic(topicString, topicObject,
CMQC.MQTOPIC_OPEN_AS_SUBSCRIPTION, openOptionsForGet);
|
The topicString is null and the topicObject is set here:
Code: |
topicObject = System.getProperty("com.ibm.mq.pubSubSample.topicObject", "myTopicObject");
|
_________________ Working with MQ since 2010. |
|
Back to top |
|
 |
hughson |
Posted: Sat May 14, 2016 4:27 am Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Agreed it needs a topic OBJECT defined with the name 'myTopicObject' (by default) and remember the case - i.e. use quotes when you define it.
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun May 15, 2016 6:29 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
tczielke wrote: |
It looks like the MQPubSubApiSample program uses code that requires the topic to be defined in the queue manager:
Code: |
MQDestination destinationForGet = queueManager.accessTopic(topicString, topicObject,
CMQC.MQTOPIC_OPEN_AS_SUBSCRIPTION, openOptionsForGet);
|
The topicString is null and the topicObject is set here:
Code: |
topicObject = System.getProperty("com.ibm.mq.pubSubSample.topicObject", "myTopicObject");
|
|
I did not verify it, but would it be possible to pass a topicString and null as topicObject?
Obviously if you do pass a topic object it has to be defined first (just like a queue)...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
hughson |
Posted: Sun May 15, 2016 12:09 pm Post subject: |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
fjb_saper wrote: |
I did not verify it, but would it be possible to pass a topicString and null as topicObject?
Obviously if you do pass a topic object it has to be defined first (just like a queue)...  |
The API allows this yes. You'd have to make changes to this sample to allow it though.
We haven't heard from Roger for a while. Are you all fixed now Roger?
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
tczielke |
Posted: Sun May 15, 2016 4:03 pm Post subject: Re: Sample MQPubSubApiSample throws RC 2085 |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 Location: Illinois, USA
|
RogerLacroix wrote: |
Does anyone have any working Pub/Sub Java applications that they want to share? |
I have been working through a JMS book (Java Message Service), and it has a chapter 2 example in the vendor agnostic source code at this link:
http://examples.oreilly.com/9780596000684/
called Chat.java. It uses pub/sub to create a simple chat program between users. Of course, the nice thing about JMS is you can compile the Chat.java program, and then run the same class file against IBM MQ or ActiveMQ with just some jndi.properties changes and the required administrative work (you do need to define a topic on the qmgr or ActiveMQ server thingy). Pretty slick on how portable Java/JMS makes this between JMS service providers. _________________ Working with MQ since 2010. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon May 16, 2016 12:24 am Post subject: Re: Sample MQPubSubApiSample throws RC 2085 |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
tczielke wrote: |
RogerLacroix wrote: |
Does anyone have any working Pub/Sub Java applications that they want to share? |
I have been working through a JMS book (Java Message Service), and it has a chapter 2 example in the vendor agnostic source code at this link:
http://examples.oreilly.com/9780596000684/
called Chat.java. It uses pub/sub to create a simple chat program between users. Of course, the nice thing about JMS is you can compile the Chat.java program, and then run the same class file against IBM MQ or ActiveMQ with just some jndi.properties changes and the required administrative work (you do need to define a topic on the qmgr or ActiveMQ server thingy). Pretty slick on how portable Java/JMS makes this between JMS service providers. |
This would largely depend on the authorizations. As I work mostly with a privileged user, I never have to define the topic object in JMS. I just give it the topic string. Now you will have to define the subscription queue, if you wish to use one in your subscription...
The definition of a Topic object is mostly an authorization thing when looking at JMS. I thought the base API would allow you the same latitude when using the topic string vs the Topic Object. If you wish to use a topic object or an alias to a Topic, the corresponding topic object needs indeed to be defined on the server first.
If you wish to give specific authorizations at a topic (string) level, you will have to define the corresponding Topic Object and run the authorizations against that Topic Object.
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Mon May 16, 2016 5:07 am Post subject: Re: Sample MQPubSubApiSample throws RC 2085 |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
The definition of a Topic object is mostly an authorization thing when looking at JMS. I thought the base API would allow you the same latitude when using the topic string vs the Topic Object. If you wish to use a topic object or an alias to a Topic, the corresponding topic object needs indeed to be defined on the server first. |
A Topic Object is both a point of authorization and also a point of administrative control.
It allows for applications to be ignorant of the entire topic tree structure and gives them room to specify shorter topic strings. So an administrator can define a topic object with a topic string of "Company/Region/Store/BusinessCategory/Application/", and then an application only has to know the name of the Topic Object and "Service/Register#/UserId". As an example. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed May 18, 2016 7:32 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
hughson wrote: |
We haven't heard from Roger for a while. Are you all fixed now Roger? |
Ah, life got in the way, so I'm now back to this and no, I still confused. Dave Ware sent me some links to postings: blog and a video but it left me still scratching my head.
I can't figure out how to define a topic object.
i.e.
Code: |
DEFINE TOPIC(WC.TEAMS) TOPICSTR('/WorldCup/Teams') DEFPSIST(YES) |
So 'WC.TEAMS' is the topic and '/WorldCup/Teams' is the topic string but I cannot find anywhere in the MQ KnowLedge Center where you define topic object.
Obviously, I'm missing something obvious but I have no idea what it is.
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
mqjeff |
Posted: Wed May 18, 2016 7:37 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
WC.TEAMS is the name of the Topic Object.
Like "DEFINE QLOCAL(THIS.IS.A.QUEUE)" creates a queue named 'THIS.IS.A.QUEUE'.
The app would then open topic 'WC.TEAMS' and then publish to topic '/ManU/Must/Die', or whatever...
This would cause messages to be published to '/WorldCup/Teams/ManU/Must/Die'
Make more sense?
You might also look at Chris Frank's presentations from some MQ conference... what was that called again?  _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed May 18, 2016 7:49 am Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Hi,
Really!?!
The manual for MQSC Define Topic says:
Quote: |
(topic-name)
Name of the IBM MQ topic definition (see Rules for naming IBM MQ objects ). The maximum length is 48 characters.
The name must not be the same as any other topic definition currently defined on this queue manager (unless REPLACE is specified). |
It doesn't say anything about the 'topic-name' being the 'topic object'.
I've never created any Pub/Sub stuff, so are you saying that if I issue the following MQSC then the sample will work?
Code: |
DEFINE TOPIC('myTopicObject') TOPICSTR('/Test/Roger') |
Or do I need to do something to create the topic string of '/Test/Roger' ??
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
mqjeff |
Posted: Wed May 18, 2016 8:05 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Easy enough to run the MQSC and find out what it does..
But yes, the "(topic-name) " is the name of the Topic Object. Not any part of the topic string used in the publish/subscribe.
The app would issue an MQOPEN to the (topic-name), or put it in the TCF or etc... _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
|