Author |
Message
|
shavo25 |
Posted: Mon Feb 16, 2009 5:06 pm Post subject: Publish/Subscribe questions |
|
|
 Apprentice
Joined: 16 Feb 2009 Posts: 29
|
I am pretty new to Websphere MQ and just have a question on subscribing to a topic.
In my back end java application that will be running on WAS 6.1, i have a durable subsriber that needs to listen to a topic and perform certain business logic on the messages before publishing them to a new topic.
A few questions:
When creating a durable subscriber the name as in:
createDurableSubscriber(Topic topic,
java.lang.String name) just uniquely identifies the subscriber, so i can call it anything?
If i create a session and i set this subscriber as a message listener to the associated topic, anytime a message is published i act on it automatically? As in onMessage will be invoked? If i am processing messages asynchronously, when i manipulate the message and want to publish to a new topic, i have to create a new session for the publisher?
For exception handling if i tried to publish the message with my new session and there was an MQ exception, if i inserted my message into the DB and logged it, if i called rollback on the topic session after, would this work be lost or is it in a seperate transaction? And would the message return to the topic to be pulled off again or would it be lost?
Hope yous can help.
Regards,
Shane. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 16, 2009 10:35 pm Post subject: Re: Publish/Subscribe questions |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
_________________ MQ & Broker admin |
|
Back to top |
|
 |
shavo25 |
Posted: Tue Feb 17, 2009 3:41 pm Post subject: Publish/Subscribe questions |
|
|
 Apprentice
Joined: 16 Feb 2009 Posts: 29
|
Quote: |
Like you can use the anonymous sender in p2p you should be able to use an anonymous producer in pub/sub. Just create the producer with a null topic. Be sure to set the topic in the publish method.
|
No what i mean is for aysnchronous delivery that when i create a durable subscriber that acts as a message listener and previous to that create a publisher and send a message to the topic, this is all done with the same session
this will give me an error as im using asynchronuos delivery, so i am just wondering is it better to create seperate sessions?
Exception handling
If in my development environment i deployed a pub/sub example on JBoss as a jar, jdk version is 1.5 and i listenened to a topic on MQ V6. When i manipulate the message i subscribed to and tried to publish the updated message to a new topic and there was an MQException, if i rolled back on the session, would the message be put back on the topic and processed again or what would happen. I was going to insert the message into my oracle DB if an exception occurred, but would the session rollback clear this also? |
|
Back to top |
|
 |
shavo25 |
Posted: Tue Feb 17, 2009 4:18 pm Post subject: Publish/Subscribe questions |
|
|
 Apprentice
Joined: 16 Feb 2009 Posts: 29
|
MDB would be the way i would like to listen to a topic, and perform my business logic in a stateless session bean, but the way mQ is setup there is no administered objects and i am not the Websphere administrator so im afraid i have to work with what ive got and not use JNDI lookups im afraid. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Feb 17, 2009 8:09 pm Post subject: Re: Publish/Subscribe questions |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
shavo25 wrote: |
No what i mean is for aysnchronous delivery that when i create a durable subscriber that acts as a message listener and previous to that create a publisher and send a message to the topic, this is all done with the same session
this will give me an error as im using asynchronuos delivery, so i am just wondering is it better to create seperate sessions? |
Why would you use the same session. The standard would be to use completely different sessions. On top of this the topic used to subscribe may substantially differ from the topic being published on. On of the extra attributes being the delivery queue for the subscription...
shavo25 wrote: |
Exception handling
If in my development environment i deployed a pub/sub example on JBoss as a jar, jdk version is 1.5 and i listenened to a topic on MQ V6. When i manipulate the message i subscribed to and tried to publish the updated message to a new topic and there was an MQException, if i rolled back on the session, would the message be put back on the topic and processed again or what would happen. I was going to insert the message into my oracle DB if an exception occurred, but would the session rollback clear this also? |
Like I said it depends on the transactionality you set on your MDB. Make sure you are able to handle poison messages.
At the same time the message you publish has been altered so it really should be a new message. You should also add a reply to Destination (queue) when you publish. You can then read the pscr message coming back and determine if the publish was successful.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Feb 17, 2009 8:17 pm Post subject: Re: Publish/Subscribe questions |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
shavo25 wrote: |
MDB would be the way i would like to listen to a topic, and perform my business logic in a stateless session bean, but the way mQ is setup there is no administered objects and i am not the Websphere administrator so im afraid i have to work with what ive got and not use JNDI lookups im afraid. |
This is not sound practice and makes the code a lot less portable.
Before deploying your application you need to request the JNDI setup.
This is an activity for the appserver Admin. You can help with it.
You need change management to handle and control the sequences of the deployment... Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
shavo25 |
Posted: Tue Feb 17, 2009 8:38 pm Post subject: Publish/Subscribe questions |
|
|
 Apprentice
Joined: 16 Feb 2009 Posts: 29
|
Thanks alot for the replies.
Quote: |
This is not sound practice and makes the code a lot less portable.
|
I understand this but in a perfect world i would have an administrator on site to help me with this, but im working for the state now so im the only technical guy here and MQ was setup like this before i came here!
If i subscribe to a topic on MQ, and messages are delivered asynchronously, as in the durable subscriber is a message listener, every time a message is published to this topic, my java application running on the server [JBOSS for example] will trigger and onMessage method will be invoked?
As the other scenario was having a while loop, calling receive and waiting for a certain length of time but i dont want to have an application working around a loop!
I read about poision messages been backed out by the app server calling session.rollback() . You need a backoutthreshold and backoutrequestQName but again this is activity that should be done at the websphere administration level i guess somethign that i cannot decide.
But if if did rollback on the subscriber session due to a fatal system error would the message go back on the topic to be received again?
Thanks,
Shane. |
|
Back to top |
|
 |
shavo25 |
Posted: Tue Feb 17, 2009 8:41 pm Post subject: Publish/Subscribe questions |
|
|
 Apprentice
Joined: 16 Feb 2009 Posts: 29
|
Quote: |
You should also add a reply to Destination (queue) when you publish. You can then read the pscr message coming back and determine if the publish was successful. |
If i create a new queue and publish the message how do i add a reply to destination queue to check if it published correctly using websphere MQ JMS?
Thanks again,
Shane. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Feb 18, 2009 1:05 am Post subject: Re: Publish/Subscribe questions |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
shavo25 wrote: |
im working for the state now so im the only technical guy here and MQ was setup like this before i came here! |
Either someone is supporting it, or your ability to implement anything will be seriously impeded. Particually if new objects are needed.
shavo25 wrote: |
If i subscribe to a topic on MQ, and messages are delivered asynchronously, as in the durable subscriber is a message listener, every time a message is published to this topic, my java application running on the server [JBOSS for example] will trigger and onMessage method will be invoked? |
If the subscriber is set that way.
shavo25 wrote: |
But if if did rollback on the subscriber session due to a fatal system error would the message go back on the topic to be received again? |
Yes. That's why they're called poison messages. Likewise if the subscriber abends. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Feb 18, 2009 1:07 am Post subject: Re: Publish/Subscribe questions |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
shavo25 wrote: |
[If i create a new queue and publish the message how do i add a reply to destination queue to check if it published correctly using websphere MQ JMS? |
If you've got no administrative support, how are you creating the new queue? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
shavo25 |
Posted: Wed Feb 18, 2009 2:38 pm Post subject: Publish/Subscribe questions |
|
|
 Apprentice
Joined: 16 Feb 2009 Posts: 29
|
Haha, lets just say there is alot of red tape where im working and the powers that be are not that keen on helping me, so ill have to either at some stage hope my PM can get an administrator to help me or try and work it out myself! |
|
Back to top |
|
 |
shavo25 |
Posted: Wed Feb 18, 2009 3:31 pm Post subject: Publish/Subscribe questions |
|
|
 Apprentice
Joined: 16 Feb 2009 Posts: 29
|
I understand the concept of poision messages, but i dont mean that the message is badly formatted, i mean that there may occur a system fatal error as in MQ server is down and i cannot publish the new formatted message to a new queue/topic so i will rollback on my session which will back out the message, but i guess then its up to the BackoutThreshold to decide how many times to process the message? Or if threshold is zero and poison message handling is disabled, i just keep on trying? |
|
Back to top |
|
 |
|