List of usage examples for com.rabbitmq.client.impl AMQChannel getConnection
public AMQConnection getConnection()
From source file:com.navercorp.pinpoint.plugin.rabbitmq.client.interceptor.RabbitMQConsumerHandleCompleteInboundCommandInterceptor.java
License:Apache License
private Trace createTrace(AMQChannel amqChannel, AMQCommand amqCommand) { AMQConnection connection = amqChannel.getConnection(); if (connection == null) { logger.debug("connection is null, skipping trace"); }/* ww w . j a v a 2 s . c o m*/ Method method = amqCommand.getMethod(); AMQP.Basic.GetOk getOk = (AMQP.Basic.GetOk) method; String exchange = getOk.getExchange(); if (RabbitMQClientPluginConfig.isExchangeExcluded(exchange, excludeExchangeFilter)) { if (isDebug) { logger.debug("exchange {} is excluded", exchange); } return null; } String routingKey = getOk.getRoutingKey(); Map<String, Object> headers = getHeadersFromContentHeader(amqCommand.getContentHeader()); // If this transaction is not traceable, mark as disabled. if (headers.get(RabbitMQClientConstants.META_SAMPLED) != null) { return traceContext.disableSampling(); } final TraceId traceId = populateTraceIdFromRequest(headers); // If there's no trasanction id, a new trasaction begins here. final Trace trace = traceId == null ? traceContext.newTraceObject() : traceContext.continueTraceObject(traceId); if (trace.canSampled()) { final SpanRecorder recorder = trace.getSpanRecorder(); recordRootSpan(recorder, connection, exchange, routingKey, headers); } return trace; }
From source file:de.htwk_leipzig.bis.connection.handshake.clientRewrite.AMQCommand.java
License:Mozilla Public License
/** * Sends this command down the named channel on the channel's connection, * possibly in multiple frames./* w ww . j a va2 s . c om*/ * * @param channel * the channel on which to transmit the command * @throws IOException * if an error is encountered */ public void transmit(AMQChannel channel) throws IOException { int channelNumber = channel.getChannelNumber(); AMQConnection connection = channel.getConnection(); synchronized (assembler) { Method m = this.assembler.getMethod(); connection.writeFrame(m.toFrame(channelNumber)); if (m.hasContent()) { byte[] body = this.assembler.getContentBody(); connection.writeFrame(this.assembler.getContentHeader().toFrame(channelNumber, body.length)); int frameMax = connection.getFrameMax(); int bodyPayloadMax = (frameMax == 0) ? body.length : frameMax - EMPTY_FRAME_SIZE; for (int offset = 0; offset < body.length; offset += bodyPayloadMax) { int remaining = body.length - offset; int fragmentLength = (remaining < bodyPayloadMax) ? remaining : bodyPayloadMax; Frame frame = Frame.fromBodyFragment(channelNumber, body, offset, fragmentLength); connection.writeFrame(frame); } } } connection.flush(); }