當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。