Well,.... it is.
This solution has been verified on JBoss Fuse 6.3.0. The Pax Logging Service in JBoss Fuse is configured to use Log4J Logging internally.
Technically it should be possible to configure the Log4J JMSAppender but that may be difficult to configure due to class loading issues.
The Apache ServiceMix project offers a JMS Appender for Pax Logging that is easier to use and that is used in this solution.
As this solution utilizes two bundle provided by Apache ServiceMix which we don't ship, these bundle are not supported by Red Hat (since they are not shipped out of the box and hence are not certified). As a consequence we cannot fully support this solution.
Instructions
-
In your JBoss Fuse installation edit
etc/system.properties
and append these two lines at the end, replacing the values with your admin
username and password defined inetc/users.properties
activemq.jms.user=admin activemq.jms.password=admin
-
Next, edit
etc/org.ops4j.pax.logging.cfg
and replace
log4j.rootLogger = INFO, out, osgi:VmLogAppender
withlog4j.rootLogger = INFO, out, osgi:VmLogAppender, osgi:JMSLogAppender
-
Start JBoss Fuse and use the Karaf shell for the remaining commands
-
The default broker name in JBoss Fuse is called amq, so lets create a
configuration needed by the Apache ServiceMix bundle where we set this
broker name
config:edit org.apache.servicemix.activemq.service config:propset broker-name amq config:update
This configuration will be used by a bundle to be deployed later. If you assign a different broker name in
etc/io.fabric8.mq.fabric.server-broker.cfg
, then you need to assign the same broker name in aboveconfig:propset
Karaf command.
-
Uninstall the JMS 2.0 API and install JMS 1.1 API.
There should be a more elegant way to do this but I have not found one yet.
osgi:list -l -t 0 | grep jms-api/2.0.1
and note the bundle id (199 typically)
osgi:uninstall 199 features:install jms-spec features:uninstall jms-spec features:install jms-spec/1.1 packages:exports | grep javax.jms
The last command should only output the JMS 1.1 API, e.g.
294 javax.jms; version=1.1.0
-
While the previous sequence of Karaf commands correctly installs the JMS 1.1 API, all JMS related bundles are stopped.
You could manually restart them but the quickest way is to simply restart the JBoss Fuse container. This is only needed due to the sequence of Karaf commands in previous step, its not needed any more later.
-
Install the Pax Logging bundles
osgi:install -s mvn:org.apache.servicemix.logging/jms-appender/6.1.3 osgi:install -s mvn:org.apache.servicemix.activemq/org.apache.servicemix.activemq.service/6.1.3
-
check the broker statistics using
activemq:dstat
It should show a topic calledLogging.Events
with a number of messages enqueued. You can attach a topic subscriber to this topic to receive logging events.
If you further want to configure the JMS Topic name used by this Logger, you can run
config:edit org.apache.servicemix.logging.jms config:propset destinationName LogEvents config:updateAny new logging events will be directed to the new topic destination.
There is currently no way to specify a JMS queue as the destination.
This solution is based on SMX4-1205 but it was difficult to chase down all the details as I also ran into SM-2183.
The source code of this appender can be found at
https://github.com/apache/servicemix/tree/master/logging/jms-appender.
No comments:
Post a Comment