Questions - JMS Durable Topics and Subscriptions

J

Jazil

I understand that JMS allows you to publish messages to durable topics
for durable destinations (i.e. topics) for duable subscriptions. I am
trying to make the connection between the topic string and the topic
destinations.

First, let's assume I have 2 durable subscribers who are not currently
active - Joe and Fred.
Joe wants to receive msgs for hierarchical topic: "Stock Market /
NYSE / Energy / * "
Fred wants to receive msgs for hierarchical topic: "Stock Market /
NYSE / Energy / Oil / XOM"

Question #1: How many durable destinatations does Joe have?
One? Three?
Question #2: How many durable destinatations does Fred have?
One? Five?
Question #3: I assume Joe and Fred cannot share durable
destinations - correct?

Now, let's assume I have 1 persistent message that I want to publish
to this topic string: "StockMarket / NYSE / Energy / Oil / XOM"

Question #4: Does JMS publish the message to 1 duable
destination called
"StockMarket / NYSE / Energy / Oil / XOM"?
Question #5: Does JMS publish the message to 5 duable
destinations called
"StockMarket"
"NYSE"
"Energy"
"Oil"
"XOM"?
Question #6: Does JMS publish the message to EACH durable
destination for the providers?

Perhaps JMS doesn't not have builtin support a hierarchical topic
string. If so, is that something an application using JMS needs to
handle itself? And would you handle it in any particular JMS objects
method or your own class method?

If the application has to keep track of it - I guess before using JMS,
I'd have to have stored the subscriber's topic string in a database
intially...and then for each message to be published, I'd have to
write code to compare the message's topic string to the each
subscription's topic string and only if it matches, would I publish to
that subscriber's "queue". I was hoping JMS would handle all this.

I appreciate any help you can give this newbie to JMS! :)

Thanks!
Jaz
 
E

EricF

I understand that JMS allows you to publish messages to durable topics
for durable destinations (i.e. topics) for duable subscriptions. I am
trying to make the connection between the topic string and the topic
destinations.

First, let's assume I have 2 durable subscribers who are not currently
active - Joe and Fred.
Joe wants to receive msgs for hierarchical topic: "Stock Market /
NYSE / Energy / * "
Fred wants to receive msgs for hierarchical topic: "Stock Market /
NYSE / Energy / Oil / XOM"

Question #1: How many durable destinatations does Joe have?
One? Three?
Question #2: How many durable destinatations does Fred have?
One? Five?
Question #3: I assume Joe and Fred cannot share durable
destinations - correct?

Now, let's assume I have 1 persistent message that I want to publish
to this topic string: "StockMarket / NYSE / Energy / Oil / XOM"

Question #4: Does JMS publish the message to 1 duable
destination called
"StockMarket / NYSE / Energy / Oil / XOM"?
Question #5: Does JMS publish the message to 5 duable
destinations called
"StockMarket"
"NYSE"
"Energy"
"Oil"
"XOM"?
Question #6: Does JMS publish the message to EACH durable
destination for the providers?

Perhaps JMS doesn't not have builtin support a hierarchical topic
string. If so, is that something an application using JMS needs to
handle itself? And would you handle it in any particular JMS objects
method or your own class method?

If the application has to keep track of it - I guess before using JMS,
I'd have to have stored the subscriber's topic string in a database
intially...and then for each message to be published, I'd have to
write code to compare the message's topic string to the each
subscription's topic string and only if it matches, would I publish to
that subscriber's "queue". I was hoping JMS would handle all this.

I appreciate any help you can give this newbie to JMS! :)

Thanks!
Jaz

You need to get an understanding of what a topic is. It's an administered
object. It is not like a hierarchical file system. Wild cards don't make
sense. You do a JNDI lookup to locate topics.

HTH

Eric
 
O

Owen Jacobson

I understand that JMS allows you to publish messages to durable topics
for durable destinations (i.e. topics) for duable subscriptions.  I am
trying to make the connection between the topic string and the topic
destinations.

The JMS specification makes no mention of a "topic string" -- only of
the JNDI name of a managed destination. Such names identify *at most
one* destination: either they map to a topic, or they don't. There is
no hierarchy of destinations implied by JNDI names with slashes in
them[0].

For durable subscriptions to topics there are two other identifiers
(the client ID and the subscription ID), but they do not identify the
topic -- they identify the subscriber.

Your description also contains an "extra" noun that doesn't exist.
Within JMS, there are destinations - a topic *is* a destination, and a
queue *is* a destination. Topics are associated with subscriptions,
some of which may be durable; a message sent to a topic is delivered
to each subscription.
First, let's assume I have 2 durable subscribers who are not currently
active - Joe and Fred.
Joe wants to receive msgs for hierarchical topic: "Stock Market /
NYSE / Energy / * "
Fred wants to receive msgs for hierarchical topic: "Stock Market /
NYSE / Energy / Oil / XOM"

     Question #1: How many durable destinatations does Joe have?
One?  Three?

None. Subscribers do not own destinations.

Joe has one subscription, to a destination whose JNDI name is
"Stock Market / NYSE / Energy / * "
     Question #2: How many durable destinatations does Fred have?
One?  Five?

Fred has one subscription, to a destination whose JNDI name is
"Stock Market / NYSE / Energy / Oil / XOM"
     Question #3: I assume Joe and Fred cannot share durable
destinations - correct?

The JMS specification defines no behaviour for multiple physical
clients sharing a single durable subscription. However, it does
guarantee that any durable subscription to a topic will recieve each
message exactly once, in order[1].

In practice, if multiple JMS clients use the same subscription ID and
client ID, each message will be delivered to *one* of them; which one
is somewhat unpredictable and depends on the implementation.
Now, let's assume I have 1 persistent message that I want to publish
to this topic string:  "StockMarket / NYSE / Energy / Oil / XOM"

     Question #4:  Does JMS publish the message to 1 duable
destination called
                          "StockMarket / NYSE / Energy / Oil / XOM"?
Yes.

     Question #5:  Does JMS publish the message to 5 duable
destinations called
                          "StockMarket"
                          "NYSE"
                          "Energy"
                          "Oil"
                          "XOM"?
No.

     Question #6:  Does JMS publish the message to EACH durable
destination for the providers?

JMS will ensure that, barring administrative interference or
catastrophic failure, a message sent to a topic will be delivered to
each active subscription *on that topic* exactly once.
Perhaps JMS doesn't not have builtin support a hierarchical topic
string.  If so, is that something an application using JMS needs to
handle itself?  And would you handle it in any particular JMS objects
method or your own class method?

Most JMS providers have some way to bridge messages from N input
destinations to M output destinations. You could set up bridging from
one destination to its logical "parent" destinations to emulate
hierarchal destinations, if you really want them. Within the code for
any particular JMS client (either producer or consumer) nothing
special needs to happen.

If your JMS provider doesn't offer bridging, it's not terribly hard to
write your own bridging MessageListener that republishes all messages
it receives on another destination.

Architecturally I've found it worthwhile to give each producer or
consumer a dedicated queue and to use bridging to control how messages
are routed from producers to consumers. This pattern is formalized in
tools like Mule, which are, at heart, overgrown message brokers.
If the application has to keep track of it - I guess before using JMS,
I'd have to have stored the subscriber's topic string in a database
intially...and then for each message to be published, I'd have to
write code to compare the message's topic string to the each
subscription's topic string and only if it matches, would I publish to
that subscriber's "queue".  I was hoping JMS would handle all this.

Producers should never need to concern themselves with who the
consumers are, or even if there are any consumers. They produce
messages. Having a message producer aware of the consumer(s) re-
introduces the dependencies message-oriented designs are supposed to
eliminate. :)

-o

[0] There is a hierarchy of JNDI namespaces, but that's an
administrative issue and has nothing to do with JMS as such.
[1] Well, sort of in order. It's more complex than that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top