当前位置: 首页>>代码示例>>Java>>正文


Java Envelope.getExchange方法代码示例

本文整理汇总了Java中com.rabbitmq.client.Envelope.getExchange方法的典型用法代码示例。如果您正苦于以下问题:Java Envelope.getExchange方法的具体用法?Java Envelope.getExchange怎么用?Java Envelope.getExchange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.rabbitmq.client.Envelope的用法示例。


在下文中一共展示了Envelope.getExchange方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: consume

import com.rabbitmq.client.Envelope; //导入方法依赖的package包/类
private void consume(final String consumerTag, final Envelope envelope, final BasicProperties properties,
        final byte[] body) {
    final Message rawMessage = Message.builder()
            .body(body)
            .contentType(properties.getContentType())
            .encoding(properties.getContentEncoding())
            .type(properties.getType())
            .build();
    final T message = deserialize(rawMessage);
    final Consumer<Void> onAck = ackAction(envelope.getDeliveryTag());
    final MessageContext<T> messageContext = new RabbitMessageContext<>(
            message, consumerTag, envelope.getExchange(), envelope.getRoutingKey(),
            properties, onAck);
    logDelivery(messageContext);
    consumer.accept(messageContext);
}
 
开发者ID:FinderSystems,项目名称:Elmer,代码行数:17,代码来源:InternalConsumer.java

示例2: handleDelivery

import com.rabbitmq.client.Envelope; //导入方法依赖的package包/类
/**
 * Handles a message delivery from the broker.
 */
@Override
public void handleDelivery(String consumerTag, Envelope envelope,
	BasicProperties properties, byte[] body) throws IOException {

	LOG.debug("Consumer: {} Received handle delivery", consumerTag);

	Message message = new Message(properties, body, envelope.getExchange(),
		envelope.getRoutingKey(), envelope.getDeliveryTag());

	LOG.info("Consumer: {} Received message: {}", consumerTag,
		envelope.getDeliveryTag());

	handleMessage(message);
	_channel.basicAck(envelope.getDeliveryTag(), true);
}
 
开发者ID:Peerlez,项目名称:RabbitMq,代码行数:19,代码来源:RabbitMqConsumer.java

示例3: doInBeforeTrace

import com.rabbitmq.client.Envelope; //导入方法依赖的package包/类
@Override
protected void doInBeforeTrace(SpanRecorder recorder, Object target, Object[] args) {
    AMQP.BasicProperties properties = (AMQP.BasicProperties) args[2];
    Map<String, Object> headers = properties.getHeaders();
    Envelope envelope = (Envelope) args[1];

    String exchange=envelope.getExchange();
    if (exchange == null || exchange.equals(""))
        exchange = "unknown";

    recorder.recordServiceType(RabbitMQConstants.RABBITMQ_SERVICE_TYPE);
    recorder.recordEndPoint("exchange:"+exchange);

    if (headers != null) {
        Object parentApplicationName = headers.get(RabbitMQConstants.META_PARENT_APPLICATION_NAME);
        Object parentApplicationType = headers.get(RabbitMQConstants.META_PARENT_APPLICATION_TYPE);
        if (parentApplicationName != null) {
            recorder.recordParentApplication(parentApplicationName.toString(), NumberUtils.parseShort(parentApplicationType.toString(), ServiceType.UNDEFINED.getCode()));
        }
    }
    recorder.recordRpcName("rabbitmq://exchange="+exchange);
    recorder.recordAcceptorHost("exchange-" + exchange);
    if (isDebug)
        logger.debug("endPoint=" + envelope.getExchange() + ",=" + exchange);
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:26,代码来源:RabbitMQConsumeInterceptor.java

示例4: doInAfterTrace

import com.rabbitmq.client.Envelope; //导入方法依赖的package包/类
@Override
protected void doInAfterTrace(SpanRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    DefaultConsumer consumer = (DefaultConsumer) target;
    Connection connection = consumer.getChannel().getConnection();
    Envelope envelope = (Envelope) args[1];
    AMQP.BasicProperties properties = (AMQP.BasicProperties) args[2];
    byte[] body = (byte[]) args[3];

    String exchange=envelope.getExchange();
    if (exchange == null || exchange.equals(""))
        exchange = "unknown";

    recorder.recordApi(methodDescriptor);
    recorder.recordAttribute(RabbitMQConstants.RABBITMQ_ROUTINGKEY_ANNOTATION_KEY, envelope.getRoutingKey());
    recorder.recordRemoteAddress(connection.getAddress().getHostAddress() + ":" + connection.getPort());

    if (throwable != null) {
        recorder.recordException(throwable);
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:21,代码来源:RabbitMQConsumeInterceptor.java

示例5: createTrace

import com.rabbitmq.client.Envelope; //导入方法依赖的package包/类
@Override
protected Trace createTrace(Object target, Object[] args) {
    Envelope envelope = (Envelope) args[1];
    String exchange = envelope.getExchange();

    if (RabbitMQClientPluginConfig.isExchangeExcluded(exchange, excludeExchangeFilter)) {
        if (isDebug)
            logger.debug("exchange {} is excluded", exchange);
        return null;
    }

    AMQP.BasicProperties properties = (AMQP.BasicProperties) args[2];
    Map<String, Object> headers = properties.getHeaders();

    // If this transaction is not traceable, mark as disabled.
    if (headers.get(RabbitMQConstants.META_DO_NOT_TRACE) != null) {
        return traceContext.disableSampling();
    }

    Object transactionId = headers.get(RabbitMQConstants.META_TRANSACTION_ID);
    // If there's no trasanction id, a new trasaction begins here.
    if (transactionId == null) {
        return traceContext.newTraceObject();
    }

    // otherwise, continue tracing with given data.
    long parentSpanID = NumberUtils.parseLong(headers.get(RabbitMQConstants.META_PARENT_SPAN_ID).toString(), SpanId.NULL);
    long spanID = NumberUtils.parseLong(headers.get(RabbitMQConstants.META_SPAN_ID).toString(), SpanId.NULL);
    short flags = NumberUtils.parseShort(headers.get(RabbitMQConstants.META_FLAGS).toString(), (short) 0);
    TraceId traceId = traceContext.createTraceId(transactionId.toString(), parentSpanID, spanID, flags);

    return traceContext.continueTraceObject(traceId);
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:34,代码来源:RabbitMQConsumeInterceptor.java

示例6: handleDelivery

import com.rabbitmq.client.Envelope; //导入方法依赖的package包/类
@Override
public void handleDelivery(java.lang.String consumerTag, Envelope envelope, BasicProperties properties, byte[] body) {
		String originServer = null;
		final Object originServerObj = properties.getHeaders().get("ORIGIN_SERVER");
		if (originServerObj != null) {
			originServer = originServerObj.toString();
			if (originServer.equals(handler_.serverName())) {
				// Don't deliver a message to oneself
				if (MercuryConfigManager.getDebug()) {
					MercuryAPI.info("Received message from self %s, dropping message", originServer);
				}
				return;
			}
		}
		String channelName = envelope.getExchange();
		if (channelMap_.containsKey(channelName)) {
			channelName = channelMap_.get(channelName);
		} else {
			if (!channelName.startsWith("mc.")) {
				MercuryAPI.info("Bad chan name %s on %s, dropping message", originServer, channelName);
				return;
			}
			final boolean global = channelName.endsWith(".global");
			String newName;
			if (global) {
				newName = channelName.substring(3, channelName.length() - 7);
			} else {
				newName = channelName.substring(3);
			}
			channelMap_.put(channelName, newName);
			channelName = newName;
		}
		String message;
		try {
			message = new String(body, "UTF-8");
		} catch (java.io.UnsupportedEncodingException e) {
			e.printStackTrace();
			MercuryAPI.info("Exception while UTF-8 decoding message from %s on %s, dropping message", originServer, channelName);
			return;
		}
		if (MercuryConfigManager.getDebug()) {
			MercuryAPI.info("Received from %s on %s: %s", originServer, channelName, message);
		}
		EventManager.fireMessage(originServer, channelName, message);
}
 
开发者ID:Civcraft,项目名称:Mercury,代码行数:46,代码来源:RabbitConsumer.java


注:本文中的com.rabbitmq.client.Envelope.getExchange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。