|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Issue with Pub Sub service with selector using WMQ API |
« View previous topic :: View next topic » |
Author |
Message
|
poosarla |
Posted: Thu Apr 28, 2016 5:51 am Post subject: Issue with Pub Sub service with selector using WMQ API |
|
|
Newbie
Joined: 28 Apr 2016 Posts: 4
|
Hi all,
I am working on pubsub service using wmq API to publish a topic message to queue.In that I have created a subscription filter condition based on that condition it will publish a topic message to queue.
ex:Root.MQRFH2.usr.color='blue'; but it is not publishing when we adding filter.
MQQueueManager queueManager = new MQQueueManager("IB9QMGR");
MQMessage msg=new MQMessage();
msg.writeString("<emp><id>487</id></emp>");
msg.setStringProperty("CountryCode", "US");
MQTopic publisher=queueManager.accessTopic("selector","",CMQC.MQTOPIC_OPEN_AS_PUBLICATION, CMQC.MQOO_OUTPUT);
publisher.put(msg);
when I am working in IIB the same code.I have enabled content based filtering and it publishing fine.
Please update me why it is not publishing using WMQ API.
ASAP |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Apr 28, 2016 5:57 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Does the MQ API support content based filtering? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
poosarla |
Posted: Thu Apr 28, 2016 6:10 am Post subject: |
|
|
Newbie
Joined: 28 Apr 2016 Posts: 4
|
I am not aware of content based filtering supports WMQ API.
I have achieved content based filtering in IIB.
but I have done in normal java Class it is publishing a topic without filter.when I added filter to subscription it is not publishing |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Apr 28, 2016 6:22 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
poosarla wrote: |
I am not aware of content based filtering supports WMQ API.
I have achieved content based filtering in IIB.
but I have done in normal java Class it is publishing a topic without filter.when I added filter to subscription it is not publishing |
If the publish command doesn't return an error, then the message is published.
If the subscriber doesn't receive any messages, it's because the subscription doesn't match any topics that messages were published to.
Review the MQ documentation on pub/sub. Determine if your needs can be met using those functions. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
hughson |
Posted: Thu Apr 28, 2016 7:30 pm Post subject: Re: Issue with Pub Sub service with selector using WMQ API |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Your terminology confuses me a little, but I think I understand your question. I'm going to repeat your question before I answer it so you can tell whether I understood it correctly.
Q: You are writing a Pub/Sub application using the MQ API to publish a message to a topic that contains some message property indicating the color of the message. You have created a subscription on the topic in order to have these messages that are published be sent to the subscriber's nominated queue; and this subscription contains a filter that wishes only to see those messages that have a color of blue. When you run the same subscriber and publisher through IIB it works but when you just use MQ and no IIB adding the filter to the subscriber means that the publish fails.
A: I believe the problem to be with the syntax of your subscriber's selector. You indicate that you are using the following selector:-
poosarla wrote: |
ex:Root.MQRFH2.usr.color='blue'; |
which works in IIB.
To understand why this works in IIB you need to understand two things.
- Message properties can be flattened into an MQRFH2 header, 'usr' folder and thus become part of the message body.
- IIB can filter published messages based on message content, MQ alone cannot.
MQ alone, i.e. without the help of IIB, CAN select publications based on message properties, but you have to use syntax that doesn't look like you are trying to read the message body. For a message property called "color" you should try the following syntax.
You can test this out with administrative subscriptions thus:-
Code: |
DEFINE QLOCAL(TEST.Q1) DESCR('Queue for testing out selectors with Pub Sub')
DEFINE SUB(TEST.SUB1) TOPICSTR('selector') DEST(TEST.Q1) SELECTOR('color=''blue''') |
Then publish your message with the property color set to blue. You'll find that TEST.Q1 gets the message.
Note: yes there are two and then three single quotes in that DEFINE SUB command - see another MQSeries.net question for the reasoning.
FYI: you can also use sample amqsstm to put messages with properties - useful for anyone else reading this who hasn't got an application already using properties.
If you then add the following administrative subscription:-
Code: |
DEFINE QLOCAL(TEST.Q2) DESCR('Queue for testing out selectors with Pub Sub')
DEFINE SUB(TEST.SUB2) TOPICSTR('selector') DEST(TEST.Q2) SELECTOR('Root.MQRFH2.usr.color=''blue''') |
and publish again, you'll find that your publisher is returned a MQRC_SELECTION_NOT_AVAILABLE (2551) reason code which tells you that you are trying to use a content based selector without IIB in the picture (or that you've messed up your quotes!).
So, to use only the MQ API, make sure your selector is:-
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|