27 Feb 2017

How to add a JMS appender to the Pax Logging Service in JBoss Fuse?

Ever wondered if its possible to publish JBoss Fuse container logging messages to the embedded ActiveMQ broker?

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 in etc/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
    with
    log4j.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 above config: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 called Logging.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:update
Any 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.

2 comments:

Wow Thinking said...

Nice Info, Call at Apple technical Help Canada 1-844-389-4998 for instant help or MAC E-mail Support Canada to solve your Apple Mac related issue.

Nellie Pease said...

Priya Mumbai Escort Agency. We Give You VIP Services At Your Home Or In Star Hotel. We Deal In High Class Mumbai Models And Beautiful Mumbai Call Girls. We Are Available To Serve You 24 X 7. Contact Us For Booking Ph- 09987215552.
Website: http://www.escortagencyinmumbai.com/

mumbai escort service
Mumbai escorts
escort service in Mumbai
mumbai call girls
Andheri escorts
Bandra escorts