简体   繁体   中英

How to specify topic or queue when sending/subscribing to a JMS object, ActiveMQ Artemis and STOMP

I'm using ActiveMQ Artemis messaging system, and I'm testing my setup with STOMP (stomp.py).

I created an "address" on Artemis called Site.SOF.Order.Fulfillment.Submission.ActiveOmni.Topic , and attached two queues to it:

  • Site.SOF.Order.Fulfillment.Submission.ActiveOmni.queue (multicast)
  • Site.SOF.Order.Fulfillment.Submission.ActiveOmni.log.queue (multicast)

Here are the exported bindings:

<bindings>
   <address-binding routing-types="ANYCAST" name="DLQ" id="2"/>
   <address-binding routing-types="ANYCAST" name="ExpiryQueue" id="6"/>
   <address-binding routing-types="MULTICAST" name="activemq.notifications" id="10"/>
   <address-binding routing-types="MULTICAST" name="Site.SOF.Order.Fulfillment.Submission.Topic" id="92"/>
   <queue-binding address="Site.SOF.Order.Fulfillment.Submission.Topic" filter-string="" name="Site.SOF.Order.Fulfillment.Submission.log.Queue" id="97" routing-type="MULTICAST"/>
   <queue-binding address="DLQ" filter-string="" name="DLQ" id="4" routing-type="ANYCAST"/>
   <queue-binding address="ExpiryQueue" filter-string="" name="ExpiryQueue" id="8" routing-type="ANYCAST"/>
   <queue-binding address="Site.SOF.Order.Fulfillment.Submission.Topic" filter-string="" name="Site.SOF.Order.Fulfillment.Submission.ActiveOmni.Queue" id="94" routing-type="MULTICAST"/>
</bindings>

I created a user with access to Site.*

So how do I access the queues? For example, if I use the stomp.py command line tool like so:

> subscribe Site.SOF.Order.Fulfillment.Submission.ActiveOmni.queue

I get the error:

[username] does not have permission='CREATE_ADDRESS' on address Site.SOF.Order.Fulfillment.Submission.ActiveOmni.queue

So I try adding /queue/ to the front, as I've seen in the tutorials

> subscribe /queue/Site.SOF.Order.Fulfillment.Submission.ActiveOmni.queue

But I get the same error:

[username] does not have permission='CREATE_ADDRESS' on address /queue/Site.SOF.Order.Fulfillment.Submission.ActiveOmni.queue

I can send to the topic/address without trouble. The following results in a "hello" message appearing in both queues.

send Site.SOF.Order.Fulfillment.Submission.ActiveOmni.Topic "hello"

Is this a naming convention I'm missing? Or a way to specify topic vs queue? What am I missing here that's too obvious to be clearly documented?

Let me provide some background information first...

The ActiveMQ Artemis address model includes 3 main elements - addresses, queues, and routing types. These are low-level entities which are used to implement all the different semantics for all the different protocols and configurations the broker supports.

STOMP, by contrast, just supports ambiguous "destinations." The STOMP 1.2 specification says this about destinations:

A STOMP server is modelled as a set of destinations to which messages can be sent. The STOMP protocol treats destinations as opaque string and their syntax is server implementation specific. Additionally STOMP does not define what the delivery semantics of destinations should be. The delivery, or “message exchange”, semantics of destinations can vary from server to server and even from destination to destination. This allows servers to be creative with the semantics that they can support with STOMP.

In the core address model messages are sent to addresses and consumed from queues. Addresses and queues are named independently so the names that the core producer and consumer use can be different.

ActiveMQ Artemis supports both point-to-point and pub/sub semantics for STOMP destinations. You can read more about how to configure these semantics in the latest ActiveMQ Artemis STOMP documentation .

In the STOMP point-to-point use-case a message is sent to a destination and consumed from that same destination. The name that both the STOMP producer and consumer use are the same . In order to support these semantics the broker uses a core address and a core anycast queue with the same name .

In the STOMP pub/sub use-case a client creates a subscription on a destination which it can then use to receive messages sent to that destination. The name that both the STOMP subscriber and producer use are the same . In order to support these semantics the broker uses a core address and a core multicast queue with different names . The name of the core queue is generated by the broker automatically. The subscriber can then receive the messages directly from the underlying core subscription queue.

All this stuff is done behind the scenes for STOMP clients, but it's important to understand how STOMP maps to ActiveMQ Artemis' address model so you can configure things appropriately


In your case you've configured an address with 2 multicast queues and you're trying to consume from those queues. This use-case is a mix between point-to-point and pub/sub because you have statically defined queues (ie not queues auto-created by the broker in response to a subscriber) but the queues are multicast. These queues are like statically configured durable subscriptions. To access the queues directly you need to use their fully-qualified queue name (ie FQQN) from your client. The FQQN follows the pattern of <address>::<queue> so in your case you'd use either

Site.SOF.Order.Fulfillment.Submission.ActiveOmni.Topic::Site.SOF.Order.Fulfillment.Submission.ActiveOmni.queue

or

Site.SOF.Order.Fulfillment.Submission.ActiveOmni.Topic::Site.SOF.Order.Fulfillment.Submission.ActiveOmni.log.queue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM