Log4j JMS appender向STOMP客户端发送空消息

时间:2015-04-27 09:22:06

标签: node.js log4j jms activemq stomp

使用log4j JMS appender转发日志消息。我正在使用STOMP-CLIENT运行Node JS,以监听activemq,以接收转发的日志消息

现在的问题是,无论何时转发日志,都会收到消息为空

这是我的stomp客户端代码

var Stomp = require('stomp-client');
var destination = '/topic/logTopic';
var client = new Stomp('127.0.0.1', 61613, '', '');
client.connect(function(sessionId) {
    client.subscribe(destination, function(body, headers) {     
        console.log('Mesage');
      console.log(body); //This is empty
    });       

});

这是我的Log4.j属性

log4j.rootLogger=INFO, stdout, jms

## Be sure that ActiveMQ messages are not logged to 'jms' appender
log4j.logger.org.apache.activemq=INFO, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c - %m%n

## Configure 'jms' appender. You'll also need jndi.properties file in order to make it work
log4j.appender.jms=org.apache.log4j.net.JMSAppender
log4j.appender.jms.InitialContextFactoryName=org.apache.activemq.jndi.ActiveMQInitialContextFactory
log4j.appender.jms.ProviderURL=tcp://localhost:61616
log4j.appender.jms.TopicBindingName=logTopic
log4j.appender.jms.TopicConnectionFactoryBindingName=ConnectionFactory

1 个答案:

答案 0 :(得分:0)

尝试设置:

<bean class="org.apache.activemq.util.XStreamFactoryBean" name="xstream">
     <property name="annotatedClass"> 
            <value>org.apache.activemq.transport.stomp.SamplePojo</value>
     </property>
</bean>

http://activemq.2283324.n4.nabble.com/Active-MQ-sends-empty-message-bodies-via-Stomp-td2364203.html