You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by queimadus <qu...@gmail.com> on 2020/02/05 19:08:05 UTC

[Broker-J] Use log4j2 instead of logback

Hi, I'm trying to use qpid-broker as an embedded broker for tests.

Our project uses `log4j2` for logging and `log4j-slf4j-impl` for `slf4j`
compatibility, which clashes with the provided logback-classic. 
I've tried to use `qpid-broker-core` and not use the
`qpid-broker-plugins-logging-logback` plugin in a effort to drop the
`logback-classic` dependency. 
Unfortunately, doing that results in a exception:
`org.apache.qpid.server.model.NoFactoryForCategoryException: Unknown
category: BrokerLogger`.

My question is: even if I don't defined any logger in the config, do I still
need `BrokerLogger` implementations? A `qpid-broker-plugins-logging-log4j2` 
of sorts? Ideally, I'd like to consume the logs directly via the `slf4j`
interface or drop the logs altogether if the solution is easier.

Thanks,
Bruno



--
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: [Broker-J] Use log4j2 instead of logback

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

The reported NPE can only occur when there is no AMQP protocol plugin
available in the broker classpath. Thus, the broker cannot support any AMQP
connectivity. Though, instead of NPE, the more correct behaviour would be
to report that no AMQP protocol plugin is available. However, it is a bit
unexpected use case. The broker is supposed to run with a support for at
least one AMQP protocol.

As per AMQP specifications (for both legacy ones and new AMQP 1.0), the
Broker is obligated to reply with the latest supported AMQP protocol
version in response to unsupported version request. In this particular
case, the broker supported protocol was "null" which cased an NPE :(

Adding a dependency for
"qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store" only adds a support
for AMQP 1.0, as module
"qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store" depends on
"qpid-broker-plugins-amqp-1-0-protocol".

For AMQP 0-9, you need to add a broker pluging implementing support for
AMQP 0-8,0-9 and 0-91:

<dependency>
    <groupId>org.apache.qpid</groupId>
    <artifactId>qpid-broker-plugins-amqp-0-8-protocol</artifactId>
    <version>${qpid-broker-version}</version>
</dependency>

That should resolve the NPE exception.

Kind Regards,
Alex



On Mon, 10 Feb 2020 at 11:48, queimadus <qu...@gmail.com> wrote:

> Hi Alex,
>
> My client (com.rabbitmq.amqp-client) is using the 0.9.1 protocol and I'm
> including the `qpid-broker-core`,
> `qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store` and
> `qpid-broker-plugins-memory-store` at version `7.1.5` (We have another
> dependency which relies on a inferior version of `com.fasterxml.jackson` so
> we couldn't use `7.1.7`).
>
> This is my current config is:
> ```
> {
>   "name": "TestBroker",
>   "modelVersion": "7.1",
>   "defaultVirtualHost": "default",
>
>   "authenticationproviders" : [{
>     "secureOnlyMechanisms": [],
>     "name": "plain",
>     "type": "Plain",
>     "users": [
>       {
>         "id": "03eb68b8-8e9c-42e0-a7d0-70d436ba22af",
>         "type": "managed",
>         "name": "${qpid.user.name}",
>         "password": "${qpid.user.password}"
>       }
>     ]
>   }],
>
>   "ports" : [  {
>     "name" : "AMQP",
>     "port" : "${qpid.amqp_port}",
>     "authenticationProvider" : "plain",
>     "virtualhostaliases" : [ {
>       "name" : "nameAlias",
>       "type" : "nameAlias"
>     }, {
>       "name" : "defaultAlias",
>       "type" : "defaultAlias"
>     }, {
>       "name" : "hostnameAlias",
>       "type" : "hostnameAlias"
>     } ]
>   }],
>
>   "virtualhostnodes" : [{
>     "name" : "default",
>     "type" : "JSON",
>     "defaultVirtualHostNode" : "true",
>     "virtualHostInitialConfiguration" : "{\"type\": \"Memory\"}",
>     "preferenceStoreAttributes": {"type": "Noop"}
>   }]
>
> }
> ```
>
> And without the `qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store`
> dependency I get exceptions of this type:
> ```
> Exception in thread "IO-/0:0:0:0:0:0:0:1:59163"
> java.lang.NullPointerException
>         at
>
> org.apache.qpid.server.transport.MultiVersionProtocolEngine$SelfDelegateProtocolEngine.received(MultiVersionProtocolEngine.java:467)
>         at
>
> org.apache.qpid.server.transport.MultiVersionProtocolEngine.received(MultiVersionProtocolEngine.java:135)
>         at
>
> org.apache.qpid.server.transport.NonBlockingConnection.processAmqpData(NonBlockingConnection.java:611)
>         at
>
> org.apache.qpid.server.transport.NonBlockingConnectionPlainDelegate.processData(NonBlockingConnectionPlainDelegate.java:58)
>         at
>
> org.apache.qpid.server.transport.NonBlockingConnection.doRead(NonBlockingConnection.java:496)
>         at
>
> org.apache.qpid.server.transport.NonBlockingConnection.doWork(NonBlockingConnection.java:270)
>         at
>
> org.apache.qpid.server.transport.NetworkConnectionScheduler.processConnection(NetworkConnectionScheduler.java:134)
>         at
>
> org.apache.qpid.server.transport.SelectorThread$ConnectionProcessor.processConnection(SelectorThread.java:575)
>         at
>
> org.apache.qpid.server.transport.SelectorThread$SelectionTask.performSelect(SelectorThread.java:366)
>         at
>
> org.apache.qpid.server.transport.SelectorThread$SelectionTask.run(SelectorThread.java:97)
>         at
>
> org.apache.qpid.server.transport.SelectorThread.run(SelectorThread.java:533)
>         at
>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>         at
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>         at
>
> org.apache.qpid.server.bytebuffer.QpidByteBufferFactory.lambda$null$0(QpidByteBufferFactory.java:464)
>         at java.lang.Thread.run(Thread.java:748)
> ```
>
> At first, I tried to see if I was missing a dependency that added support
> for 0.9.1 but as far as I can tell, that seems to be supported natively.
> Since adding that dependency fixed that issue I didn't delve much more into
> that.
>
> Thanks,
> Bruno
>
>
>
> --
> 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: [Broker-J] Use log4j2 instead of logback

Posted by queimadus <qu...@gmail.com>.
Hi Alex,

My client (com.rabbitmq.amqp-client) is using the 0.9.1 protocol and I'm
including the `qpid-broker-core`,
`qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store` and
`qpid-broker-plugins-memory-store` at version `7.1.5` (We have another
dependency which relies on a inferior version of `com.fasterxml.jackson` so
we couldn't use `7.1.7`).

This is my current config is:
```
{
  "name": "TestBroker",
  "modelVersion": "7.1",
  "defaultVirtualHost": "default",

  "authenticationproviders" : [{
    "secureOnlyMechanisms": [],
    "name": "plain",
    "type": "Plain",
    "users": [
      {
        "id": "03eb68b8-8e9c-42e0-a7d0-70d436ba22af",
        "type": "managed",
        "name": "${qpid.user.name}",
        "password": "${qpid.user.password}"
      }
    ]
  }],

  "ports" : [  {
    "name" : "AMQP",
    "port" : "${qpid.amqp_port}",
    "authenticationProvider" : "plain",
    "virtualhostaliases" : [ {
      "name" : "nameAlias",
      "type" : "nameAlias"
    }, {
      "name" : "defaultAlias",
      "type" : "defaultAlias"
    }, {
      "name" : "hostnameAlias",
      "type" : "hostnameAlias"
    } ]
  }],

  "virtualhostnodes" : [{
    "name" : "default",
    "type" : "JSON",
    "defaultVirtualHostNode" : "true",
    "virtualHostInitialConfiguration" : "{\"type\": \"Memory\"}",
    "preferenceStoreAttributes": {"type": "Noop"}
  }]

}
```

And without the `qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store`
dependency I get exceptions of this type:
```
Exception in thread "IO-/0:0:0:0:0:0:0:1:59163"
java.lang.NullPointerException
	at
org.apache.qpid.server.transport.MultiVersionProtocolEngine$SelfDelegateProtocolEngine.received(MultiVersionProtocolEngine.java:467)
	at
org.apache.qpid.server.transport.MultiVersionProtocolEngine.received(MultiVersionProtocolEngine.java:135)
	at
org.apache.qpid.server.transport.NonBlockingConnection.processAmqpData(NonBlockingConnection.java:611)
	at
org.apache.qpid.server.transport.NonBlockingConnectionPlainDelegate.processData(NonBlockingConnectionPlainDelegate.java:58)
	at
org.apache.qpid.server.transport.NonBlockingConnection.doRead(NonBlockingConnection.java:496)
	at
org.apache.qpid.server.transport.NonBlockingConnection.doWork(NonBlockingConnection.java:270)
	at
org.apache.qpid.server.transport.NetworkConnectionScheduler.processConnection(NetworkConnectionScheduler.java:134)
	at
org.apache.qpid.server.transport.SelectorThread$ConnectionProcessor.processConnection(SelectorThread.java:575)
	at
org.apache.qpid.server.transport.SelectorThread$SelectionTask.performSelect(SelectorThread.java:366)
	at
org.apache.qpid.server.transport.SelectorThread$SelectionTask.run(SelectorThread.java:97)
	at
org.apache.qpid.server.transport.SelectorThread.run(SelectorThread.java:533)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at
org.apache.qpid.server.bytebuffer.QpidByteBufferFactory.lambda$null$0(QpidByteBufferFactory.java:464)
	at java.lang.Thread.run(Thread.java:748)
``` 

At first, I tried to see if I was missing a dependency that added support
for 0.9.1 but as far as I can tell, that seems to be supported natively.
Since adding that dependency fixed that issue I didn't delve much more into
that.

Thanks,
Bruno



--
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: [Broker-J] Use log4j2 instead of logback

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

Thanks for reporting an issue with upgrade from "modelVersion: 2.0".
The upgrade functionality unconditionally adds logback loggers into the
broker configuration on model upgrade. It is a defect. The upgrader should
actually check whether logback loggers are available before making any
assumptions.

As for `qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store` dependency, I
am surprised to hear that you had to add it for a Memory virtual host.
You should be able to embed the broker without this  module. It only make
sense to use BDB link store with a bdb message store or bdb-ha virtual host
node. It cannot be used with Memory store.
I suspect that something wrong with your configuration.

If you could provide the details of the errors you are getting without
bdb-link-store dependency, I might be able to help you to resolve the issue.

Kind Regards,
Alex



On Fri, 7 Feb 2020 at 11:54, queimadus <qu...@gmail.com> wrote:

> Thanks Alex, I managed to work it out with your example.
>
> For the record, my initial config was using `modelVersion: 2.0` and that
> seems to be what was causing the unknown category BrokerLogger.
>
> One peculiar thing is that even though I ended up using the `Memory` for
> the
> `virtualHostInitialConfiguration` I still have to include the
> `qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store` dependency to have
> it
> all work. At first I thought it may be because of some transitive
> dependency
> but that didn't seem to be the case.
>
> Thanks again for the fast reply and standalone example,
> Bruno
>
>
>
>
>
> --
> 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: [Broker-J] Use log4j2 instead of logback

Posted by queimadus <qu...@gmail.com>.
Thanks Alex, I managed to work it out with your example.

For the record, my initial config was using `modelVersion: 2.0` and that
seems to be what was causing the unknown category BrokerLogger. 

One peculiar thing is that even though I ended up using the `Memory` for the
`virtualHostInitialConfiguration` I still have to include the
`qpid-broker-plugins-amqp-1-0-protocol-bdb-link-store` dependency to have it
all work. At first I thought it may be because of some transitive dependency
but that didn't seem to be the case.

Thanks again for the fast reply and standalone example,
Bruno





--
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: [Broker-J] Use log4j2 instead of logback

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

I put together an example [1] how to embed Qpid broker-j without logback
dependencies (It depends on log4j2).
Logback broker loggers are completely optional. In order to avoid any Qpid
logback dependency, you just need to add into your project a dependency to
qpid-broker-core and any other required modules.
Please check [2] for more details.

Kind Regards,
Alex

[1] https://github.com/alex-rufous/embedded-qpid-broker-j
[2]
https://cwiki.apache.org/confluence/display/qpid/How+to+embed+Qpid+Broker-J


On Wed, 5 Feb 2020 at 19:40, queimadus <qu...@gmail.com> wrote:

> Hi, I'm trying to use qpid-broker as an embedded broker for tests.
>
> Our project uses `log4j2` for logging and `log4j-slf4j-impl` for `slf4j`
> compatibility, which clashes with the provided logback-classic.
> I've tried to use `qpid-broker-core` and not use the
> `qpid-broker-plugins-logging-logback` plugin in a effort to drop the
> `logback-classic` dependency.
> Unfortunately, doing that results in a exception:
> `org.apache.qpid.server.model.NoFactoryForCategoryException: Unknown
> category: BrokerLogger`.
>
> My question is: even if I don't defined any logger in the config, do I
> still
> need `BrokerLogger` implementations? A
> `qpid-broker-plugins-logging-log4j2`
> of sorts? Ideally, I'd like to consume the logs directly via the `slf4j`
> interface or drop the logs altogether if the solution is easier.
>
> Thanks,
> Bruno
>
>
>
> --
> 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
>
>