You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Oleksandr Rudyy <or...@gmail.com> on 2021/04/02 09:22:48 UTC

Re: Configuring an in-memory QPID Broker-J 8.0.4 with behaviourOnUnknownDeclareArgument: ignore

Hi Simon,
You set context variable "queue.behaviourOnUnknownDeclareArgument" as
an attribute in your virtual host initial configuration.
You need to set it as an entry in "context" attribute, for example,
{
...
"context": {
   "queue.behaviourOnUnknownDeclareArgument": "IGNORE"
 }
...
}

Thus, your virtual host initial configuration should be like the one below

{
  "type": "Memory",
  "nodeAutoCreationPolicies": [
    {
      "pattern": ".*",
      "createdOnPublish": "true",
      "createdOnConsume": "true",
      "nodeType": "queue",
      "attributes": {
        "context": {
          "queue.behaviourOnUnknownDeclareArgument": "IGNORE"
        }
      }
    }
  ]
}
or in strigified form


"{\"type\":\"Memory\",\"nodeAutoCreationPolicies\":[{\"pattern\":\".*\",\"createdOnPublish\":\"true\",\"createdOnConsume\":\"true\",\"nodeType\":\"queue\",\"attributes\":
{\"context\": {\"queue.behaviourOnUnknownDeclareArgument\":\"IGNORE\"
}}}]}"

It seems that instructions [1], you followed, are based on Qpid
instructions [2] but I could be wrong.

Kind Regards,
Alex

[1] https://novotnyr.github.io/scrolls/qpid-as-mocking-amqp-broker-for-integration-tests/
[2] https://cwiki.apache.org/confluence/display/qpid/How+to+embed+Qpid+Broker-J

On Tue, 30 Mar 2021 at 15:27, Simon Baptista <si...@hotmail.com> wrote:
>
> Hi,
>
> I'm trying to use QPID in-memory for the purpose of an integration test against a RabbitMQ consumer.
>
> My application uses a RabbitMQ specific queue declaration argument (x-expires). I've seen through googling that "queue.behaviourOnUnknownDeclareArgument: Ignore" Will do what I want to do.
>
> This is what my config looks like at the moment (I'm making guesses about the nodeAutoCreationPolicies being the default template for how elements are created...):
> =======================
> {
>   "name": "Embedded Broker",
>   "modelVersion": "7.0",
>   "authenticationproviders": [
>     {
>       "name": "hardcoded",
>       "type": "Plain",
>       "secureOnlyMechanisms": [],
>       "users": [
>         {
>           "name": "guest",
>           "password": "guest",
>           "type": "managed"
>         }
>       ]
>     }
>   ],
>   "ports": [
>     {
>       "name": "AMQP",
>       "port": "${qpid.amqp_port}",
>       "bindingAddress": "127.0.0.1",
>       "protocols": [
>         "AMQP_0_9_1"
>       ],
>       "authenticationProvider": "hardcoded",
>       "virtualhostaliases": [
>         {
>           "name": "defaultAlias",
>           "type": "defaultAlias"
>         }
>       ]
>     }
>   ],
>   "virtualhostnodes": [
>     {
>       "name": "default",
>       "type": "Memory",
>       "defaultVirtualHostNode": "true",
>       "virtualHostInitialConfiguration": "{\"type\": \"Memory\", \"nodeAutoCreationPolicies\": [{\"pattern\":\".*\",\"createdOnPublish\":\"true\",\"createdOnConsume\":\"true\",\"nodeType\":\"queue\", \"attributes\": {\"queue.behaviourOnUnknownDeclareArgument\":\"IGNORE\"}}]}"
>     }
>   ]
> }
> =========================
>
> And it's doesn't appear to be doing anything as my application is throwing:
> ===============
> java.io.IOException: null
> at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:129)
> at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:125)
> at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:147)
> at com.rabbitmq.client.impl.ChannelN.queueDeclare(ChannelN.java:968)
> at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.queueDeclare(AutorecoveringChannel.java:342)
> ...
> Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=542, reply-text=Error creating queue 'myqueue_dtmanager_task': Unsupported queue declare argument(s) : x-expires, class-id=50, method-id=10) at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)
> ===============
>
>
> This is how I am initialising my broker:
> ===================
>
> public class BrokerManager {
>
>     private static final String DEFAULT_INITIAL_CONFIGURATION_LOCATION = "qpid-it.json";
>
>     private SystemLauncher systemLauncher;
>
>     public BrokerManager() {
>         this.systemLauncher = new SystemLauncher();
>     }
>
>     public void start() throws Exception {
>         this.systemLauncher.startup(createSystemConfig());
>     }
>
>     public void shutdown() {
>         this.systemLauncher.shutdown();
>     }
>
>     private Map<String, Object> createSystemConfig() throws IllegalConfigurationException {
>         Map<String, Object> attributes = new HashMap<>();
>         URL initialConfigUrl = BrokerManager.class.getClassLoader().getResource(DEFAULT_INITIAL_CONFIGURATION_LOCATION);
>         if (initialConfigUrl == null) {
>         throw new IllegalConfigurationException("Configuration location '" + DEFAULT_INITIAL_CONFIGURATION_LOCATION + "' not found");
>     }
>         attributes.put(SystemConfig.TYPE, "Memory");
>         attributes.put(SystemConfig.INITIAL_CONFIGURATION_LOCATION, initialConfigUrl.toExternalForm());
>         attributes.put(SystemConfig.STARTUP_LOGGED_TO_SYSTEM_OUT, true);
>         return attributes;
>     }
> }
>
> ==================
>
> Any help you can offer or documentation you can point me to as to where/how to set the configuration properties on a queue for an in-memory QPID broker would be great as I've been failing spectacularly.
>
> For completeness. I've mostly been following this page https://novotnyr.github.io/scrolls/qpid-as-mocking-amqp-broker-for-integration-tests/ and using trial + error
>
> And I am encouraged that this is possible because of the discussion here: https://issues.apache.org/jira/browse/QPID-8388
>
> Thanks in advance,
> Simon.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Configuring an in-memory QPID Broker-J 8.0.4 with behaviourOnUnknownDeclareArgument: ignore

Posted by Oleksandr Rudyy <or...@gmail.com>.
Hi Siman,

I missed the fact that connection context is checked for the variable.
The context variables are inherited from the parent objects in the
object hierarchy. Thus, you can declare the corresponding variable on
the connection parent (Port) or parent of a parent (Broker).

{
  "name": "Embedded Broker",
  "modelVersion": "8.0",
  "context": {"queue.behaviourOnUnknownDeclareArgument":"IGNORE"},
 ...

Kind Regards,
Alex

On Fri, 21 May 2021 at 17:08, Simon Baptista <si...@hotmail.com> wrote:
>
> So I'm digging around the source, I think the issue might be related to the
> nodeType of the nodeAutoCreationPolicies
>
> ===== AMQChannel.java. lines 3040-3042 =====
>
> Queue.BehaviourOnUnknownDeclareArgument unknownArgumentBehaviour =
>
> getConnection().getContextValue(Queue.BehaviourOnUnknownDeclareArgument.class,
>
> Queue.UNKNOWN_QUEUE_DECLARE_ARGUMENT_BEHAVIOUR_NAME);
>
> =================================
>
> would suggest to me that the context value is on the connection rather than
> on the queue itself.
>
> However attempting to configure a nodeType "connection" throws an error too:
>
> "The node type of a NodeAutoCreationPolicy must be a valid child type of a
> VirtualHost, 'connection' is not."
>
> even though both Queue and Connection are interfaces which extend
> ConfiguredObject.
>
>
> And as you can tell, I'm thoroughly lost.
>
> I'm only mentioning this in the hope that this triggers an idea for someone.
>
> Here's what my virtualhostnodes config looks like right now:
>
> ============
>
>   "virtualhostnodes": [
>     {
>       "name": "default",
>       "type": "Memory",
>       "defaultVirtualHostNode": "true",
>       "virtualHostInitialConfiguration" : "{\"type\": \"Memory\",
> \"nodeAutoCreationPolicies\":
> [{\"pattern\":\".*\",\"createdOnPublish\":\"true\",\"createdOnConsume\":\"true\",\"nodeType\":\"queue\",\"attributes\":{}},
> {\"pattern\":\".*\",\"createdOnPublish\":\"true\",\"createdOnConsume\":\"true\",\"nodeType\":\"connection\",\"attributes\":{\"context\":
> {\"queue.behaviourOnUnknownDeclareArgument\":\"IGNORE\"}}}] }"
>     }
>   ]
> ===========
>
>
>
>
> --
> Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Configuring an in-memory QPID Broker-J 8.0.4 with behaviourOnUnknownDeclareArgument: ignore

Posted by Simon Baptista <si...@hotmail.com>.
So I'm digging around the source, I think the issue might be related to the
nodeType of the nodeAutoCreationPolicies 

===== AMQChannel.java. lines 3040-3042 =====

Queue.BehaviourOnUnknownDeclareArgument unknownArgumentBehaviour =
                       
getConnection().getContextValue(Queue.BehaviourOnUnknownDeclareArgument.class,
                                                       
Queue.UNKNOWN_QUEUE_DECLARE_ARGUMENT_BEHAVIOUR_NAME);

=================================

would suggest to me that the context value is on the connection rather than
on the queue itself.

However attempting to configure a nodeType "connection" throws an error too:

"The node type of a NodeAutoCreationPolicy must be a valid child type of a
VirtualHost, 'connection' is not."

even though both Queue and Connection are interfaces which extend
ConfiguredObject.


And as you can tell, I'm thoroughly lost.

I'm only mentioning this in the hope that this triggers an idea for someone.

Here's what my virtualhostnodes config looks like right now:

============

  "virtualhostnodes": [
    {
      "name": "default",
      "type": "Memory",
      "defaultVirtualHostNode": "true",
      "virtualHostInitialConfiguration" : "{\"type\": \"Memory\",
\"nodeAutoCreationPolicies\":
[{\"pattern\":\".*\",\"createdOnPublish\":\"true\",\"createdOnConsume\":\"true\",\"nodeType\":\"queue\",\"attributes\":{}},
{\"pattern\":\".*\",\"createdOnPublish\":\"true\",\"createdOnConsume\":\"true\",\"nodeType\":\"connection\",\"attributes\":{\"context\":
{\"queue.behaviourOnUnknownDeclareArgument\":\"IGNORE\"}}}] }"
    }
  ]
===========




--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: Configuring an in-memory QPID Broker-J 8.0.4 with behaviourOnUnknownDeclareArgument: ignore

Posted by Simon Baptista <si...@hotmail.com>.
Hi Alex,

Sorry, I tried to reply to this earlier and failed.

Unfortunately this configuration still doesn't work and I don't know how to
fix it.

The error hasn't changed. I'm still getting "Unsupported queue declare
argument(s) : x-expires"

If you (or anyone else for that matter) has any ideas I'd appreciate it.

Also, if I remove the flag from the creation of the queue, the integration
test passes, so this is the last piece of the puzzle. Otherwise I'm going to
have to remove the flag which would be a shame.

Thanks!
Simon.



--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org