mirror of https://github.com/apache/activemq.git
Improve how trace logging is handled in the AMQP transport.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1495057 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
661801ebcd
commit
e8eb58ada3
|
@ -102,7 +102,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
class AmqpProtocolConverter {
|
class AmqpProtocolConverter {
|
||||||
|
static final Logger TRACE_FRAMES = AmqpTransportFilter.TRACE_FRAMES;
|
||||||
public static final EnumSet<EndpointState> UNINITIALIZED_SET = EnumSet.of(EndpointState.UNINITIALIZED);
|
public static final EnumSet<EndpointState> UNINITIALIZED_SET = EnumSet.of(EndpointState.UNINITIALIZED);
|
||||||
public static final EnumSet<EndpointState> INITIALIZED_SET = EnumSet.complementOf(UNINITIALIZED_SET);
|
public static final EnumSet<EndpointState> INITIALIZED_SET = EnumSet.complementOf(UNINITIALIZED_SET);
|
||||||
public static final EnumSet<EndpointState> ACTIVE_STATE = EnumSet.of(EndpointState.ACTIVE);
|
public static final EnumSet<EndpointState> ACTIVE_STATE = EnumSet.of(EndpointState.ACTIVE);
|
||||||
|
@ -126,27 +126,32 @@ class AmqpProtocolConverter {
|
||||||
public AmqpProtocolConverter(AmqpTransport transport, BrokerContext brokerContext) {
|
public AmqpProtocolConverter(AmqpTransport transport, BrokerContext brokerContext) {
|
||||||
this.amqpTransport = transport;
|
this.amqpTransport = transport;
|
||||||
this.protonTransport.bind(this.protonConnection);
|
this.protonTransport.bind(this.protonConnection);
|
||||||
if (transport.isTrace()) {
|
updateTracer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateTracer() {
|
||||||
|
if (amqpTransport.isTrace()) {
|
||||||
this.protonTransport.setProtocolTracer(new ProtocolTracer() {
|
this.protonTransport.setProtocolTracer(new ProtocolTracer() {
|
||||||
@Override
|
@Override
|
||||||
public void receivedFrame(TransportFrame transportFrame) {
|
public void receivedFrame(TransportFrame transportFrame) {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (TRACE_FRAMES.isTraceEnabled()) {
|
||||||
LOG.debug(String.format("%s | RECV: %s",
|
TRACE_FRAMES.trace(String.format("%s | RECV: %s",
|
||||||
amqpTransport.getRemoteAddress(), transportFrame.getBody()));
|
AmqpProtocolConverter.this.amqpTransport.getRemoteAddress(), transportFrame.getBody()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sentFrame(TransportFrame transportFrame) {
|
public void sentFrame(TransportFrame transportFrame) {
|
||||||
if (LOG.isDebugEnabled()) {
|
if (TRACE_FRAMES.isTraceEnabled()) {
|
||||||
LOG.debug(String.format("%s | SENT: %s",
|
TRACE_FRAMES.trace(String.format("%s | SENT: %s",
|
||||||
amqpTransport.getRemoteAddress(), transportFrame.getBody()));
|
AmqpProtocolConverter.this.amqpTransport.getRemoteAddress(), transportFrame.getBody()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pumpProtonToSocket() {
|
void pumpProtonToSocket() {
|
||||||
try {
|
try {
|
||||||
int size = 1024 * 64;
|
int size = 1024 * 64;
|
||||||
|
|
|
@ -39,7 +39,8 @@ import java.security.cert.X509Certificate;
|
||||||
*/
|
*/
|
||||||
public class AmqpTransportFilter extends TransportFilter implements AmqpTransport {
|
public class AmqpTransportFilter extends TransportFilter implements AmqpTransport {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AmqpTransportFilter.class);
|
private static final Logger LOG = LoggerFactory.getLogger(AmqpTransportFilter.class);
|
||||||
private static final Logger TRACE = LoggerFactory.getLogger(AmqpTransportFilter.class.getPackage().getName() + ".AMQPIO");
|
static final Logger TRACE_BYTES = LoggerFactory.getLogger(AmqpTransportFilter.class.getPackage().getName() + ".BYTES");
|
||||||
|
static final Logger TRACE_FRAMES = LoggerFactory.getLogger(AmqpTransportFilter.class.getPackage().getName() + ".FRAMES");
|
||||||
private final AmqpProtocolConverter protocolConverter;
|
private final AmqpProtocolConverter protocolConverter;
|
||||||
// private AmqpInactivityMonitor monitor;
|
// private AmqpInactivityMonitor monitor;
|
||||||
private AmqpWireFormat wireFormat;
|
private AmqpWireFormat wireFormat;
|
||||||
|
@ -86,8 +87,8 @@ public class AmqpTransportFilter extends TransportFilter implements AmqpTranspor
|
||||||
|
|
||||||
public void onCommand(Object command) {
|
public void onCommand(Object command) {
|
||||||
try {
|
try {
|
||||||
if (trace) {
|
if (trace && TRACE_BYTES.isTraceEnabled()) {
|
||||||
TRACE.trace("Received: \n" + command);
|
TRACE_BYTES.trace("Received: \n" + command);
|
||||||
}
|
}
|
||||||
protocolConverter.lock.lock();
|
protocolConverter.lock.lock();
|
||||||
try {
|
try {
|
||||||
|
@ -112,8 +113,8 @@ public class AmqpTransportFilter extends TransportFilter implements AmqpTranspor
|
||||||
|
|
||||||
public void sendToAmqp(Object command) throws IOException {
|
public void sendToAmqp(Object command) throws IOException {
|
||||||
assert protocolConverter.lock.isHeldByCurrentThread();
|
assert protocolConverter.lock.isHeldByCurrentThread();
|
||||||
if (trace) {
|
if (trace && TRACE_BYTES.isTraceEnabled()) {
|
||||||
TRACE.trace("Sending: \n" + command);
|
TRACE_BYTES.trace("Sending: \n" + command);
|
||||||
}
|
}
|
||||||
Transport n = next;
|
Transport n = next;
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
|
@ -138,6 +139,7 @@ public class AmqpTransportFilter extends TransportFilter implements AmqpTranspor
|
||||||
|
|
||||||
public void setTrace(boolean trace) {
|
public void setTrace(boolean trace) {
|
||||||
this.trace = trace;
|
this.trace = trace;
|
||||||
|
this.protocolConverter.updateTracer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
|
|
@ -56,9 +56,10 @@ public class ActiveMQAdmin implements Admin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void enableJMSFrameTracing() throws FileNotFoundException {
|
static public void enableJMSFrameTracing() {
|
||||||
|
try {
|
||||||
final SimpleFormatter formatter = new SimpleFormatter();
|
final SimpleFormatter formatter = new SimpleFormatter();
|
||||||
String outputStreamName = System.getProperty("java.io.tmpdir") + "/amqp-trace.txt";
|
String outputStreamName = "amqp-trace.txt";
|
||||||
final PrintStream out = new PrintStream(new FileOutputStream(new File(outputStreamName)));
|
final PrintStream out = new PrintStream(new FileOutputStream(new File(outputStreamName)));
|
||||||
Handler handler = new Handler() {
|
Handler handler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,6 +80,9 @@ public class ActiveMQAdmin implements Admin {
|
||||||
Logger log = Logger.getLogger("FRM");
|
Logger log = Logger.getLogger("FRM");
|
||||||
log.addHandler(handler);
|
log.addHandler(handler);
|
||||||
log.setLevel(Level.FINEST);
|
log.setLevel(Level.FINEST);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BrokerService createBroker() throws Exception {
|
protected BrokerService createBroker() throws Exception {
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
#
|
#
|
||||||
log4j.rootLogger=WARN, console, file
|
log4j.rootLogger=WARN, console, file
|
||||||
log4j.logger.org.apache.activemq=INFO
|
log4j.logger.org.apache.activemq=INFO
|
||||||
log4j.logger.org.apache.activemq.transport.amqp=TRACE
|
log4j.logger.org.apache.activemq.transport.amqp=INFO
|
||||||
|
log4j.logger.org.apache.activemq.transport.amqp.FRAMES=TRACE
|
||||||
log4j.logger.org.fusesource=INFO
|
log4j.logger.org.fusesource=INFO
|
||||||
|
|
||||||
# Console will only display warnnings
|
# Console will only display warnnings
|
||||||
|
|
Loading…
Reference in New Issue