Bug 1034166

Summary: Creating divert is not checking whether "divert-address" or "forwarding-address" exists
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Miroslav Novak <mnovak>
Component: HornetQAssignee: Justin Bertram <jbertram>
Status: CLOSED EOL QA Contact: Miroslav Novak <mnovak>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: ataylor, jbertram, jmesnil, mnovak, msvehla, toross
Target Milestone: ---   
Target Release: EAP 6.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-19 12:49:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Miroslav Novak 2013-11-25 11:29:40 UTC
Description of problem:
Creating divert in CLI does not check whether referenced queues exists:

/subsystem=messaging/hornetq-server=default/divert=badDivert:add(divert-address=badQueue,forwarding-address=badDivertQueue)

{"outcome" => "success"}

There should be check whether queues exists and fail they're not present.

Comment 1 Jeff Mesnil 2013-11-25 11:58:40 UTC
Please note that divert deals only with *addresses*, not *queues*.

Afaik, HornetQ does not expose a way to know whether an address _exists_ (meaning that there are queues bound to it).

To be able to have the check you want, HornetQ should have to handle the check when creating the divert.

Comment 2 Justin Bertram 2014-07-22 21:20:24 UTC
Miroslav, can you clarify why creating a divert for an address that has no bindings is a bad thing?  I don't see anything wrong with this.

First off, it is impossible for the "divert-address" to be invalid because HornetQ will create a "divert binding" on the address specified in the configuration.

Second, even if the "forwarding-address" doesn't have any bindings at the time the divert is created, it could have bindings later.  Consider, for example a JMS topic on which non-durable subscribers will come and go (and their corresponding bindings which will be created and removed).

Comment 3 Miroslav Novak 2014-07-23 07:28:52 UTC
I understand. My concern is about user who makes a typo in name of address. Then he'll notice it usually when server is running and already processing messages. We can still create a divert but some kind of warning would be great. What do you think?

Comment 4 Justin Bertram 2014-07-23 16:47:21 UTC
Well, there's not much we can do for typos in the "divert-address".  However, I suppose we could log a warning if there are no bindings on the "forwarding-address".  That said, the warn message would go to the log file.  I don't think it would make sense to have org.hornetq.core.management.impl.HornetQServerControlImpl.createDivert() return a piece of data that represented whether or not the "forwarding-address" had any bindings so the CLI wouldn't be able to display this warning (assuming it could display such a warning).

Let me know if you want to proceed with this solution.

Comment 5 Miroslav Novak 2014-07-24 06:46:56 UTC
If CLI shows this warning then we should proceed with this. Otherwise I don't think it's worth of effort.

Comment 6 Justin Bertram 2014-07-24 20:44:19 UTC
Jeff, actually it looks like you can attempt to get the AddressControl for the "forwarding-address" and respond appropriately if it doesn't exist.  See org.jboss.as.messaging.AddressControlHandler#getAddressControl for an example.  What do you think?

Comment 7 Jeff Mesnil 2014-09-01 11:26:12 UTC
we can add a warning if the forwarding-address but that would not prevent the operation to succeed. The CLI user would not see the warning, it would only be displayed in the server logs

Comment 8 Miroslav Novak 2014-09-01 13:18:52 UTC
So if CLI operation is successful (but there are some problems) then CLI user cannot get any warning?