當前位置: 首頁>>代碼示例>>Java>>正文


Java Envelope.getDeliveryTag方法代碼示例

本文整理匯總了Java中com.rabbitmq.client.Envelope.getDeliveryTag方法的典型用法代碼示例。如果您正苦於以下問題:Java Envelope.getDeliveryTag方法的具體用法?Java Envelope.getDeliveryTag怎麽用?Java Envelope.getDeliveryTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.rabbitmq.client.Envelope的用法示例。


在下文中一共展示了Envelope.getDeliveryTag方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleDelivery

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
@Override
public void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties, byte[] body) throws IOException {
	if(body != null) {
		try {
			// resolve the returned message
			long deliveryTag = envelope.getDeliveryTag();
			String message = new String(body, "UTF-8");
			LOG.info("Task received: consumerTag=" + consumerTag + ", deliveryTag=" + deliveryTag + ", message=" + message);
			
			JSONObject taskReq = JSONObject.parseObject(message);
			if(!taskReq.isEmpty()) {
				long id = messageIdGenerator.incrementAndGet();
				WaitingTask task = new WaitingTask(id, taskReq, getChannel(), deliveryTag);
				waitingTasks.putLast(task);
				LOG.info("Add task to waiting queue: " + task);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
開發者ID:shirdrn,項目名稱:runp,代碼行數:22,代碼來源:Master.java

示例2: handleDelivery

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
@Override
public void handleDelivery(String consumer_Tag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException
{
  long tag = envelope.getDeliveryTag();
  if (envelope.isRedeliver() && (recoveredTags.contains(tag) || pendingAck.contains(tag))) {
    if (recoveredTags.contains(tag)) {
      pendingAck.add(tag);
    }
    return;
  }

  // Acknowledgements are sent at the end of the window after adding to idempotency manager
  pendingAck.add(tag);
  holdingBuffer.add(new KeyValPair<Long, byte[]>(tag, body));
  logger.debug("Received Async message: {}  buffersize: {} ", new String(body), holdingBuffer.size());
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:17,代碼來源:AbstractRabbitMQInputOperator.java

示例3: 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

示例4: beginSubscriptionThread

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
@Override
public void beginSubscriptionThread() throws InterruptedException, IOException {
    DefaultConsumer consumer = new DefaultConsumer(channel) {
        @Override
        public void handleDelivery(String consumerTag,
                                                Envelope envelope,
                                                AMQP.BasicProperties properties,
                                                byte[] body)
            throws IOException {
            long deliveryTag = envelope.getDeliveryTag();

            LOG.info("[RabbitMQEventConsumer {}] Received Message: {}",
                Thread.currentThread().getId(), new String(body));

            Gson gson = new Gson();
            @SuppressWarnings("unchecked")
            final CoordinationEntryEvent<K> event = gson.fromJson(new String(body), CoordinationEntryEvent.class);
            routeEventToListeners(event);

            channel.basicAck(deliveryTag, false);
        }
    };
    consumerTag = channel.basicConsume(queueName, false, consumer);
}
 
開發者ID:Excelian,項目名稱:Mache,代碼行數:25,代碼來源:RabbitMQEventConsumer.java

示例5: publishToPoisonQueue

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
/**
 * Send all unacknowledged messages to poison queue, up-to and including this one
 * @throws IOException
 */
private void publishToPoisonQueue(Envelope envelope
                                , AMQP.BasicProperties properties
                                , String reason
                                , byte[] body
                                , boolean multiple) throws IOException {
    if (!multiple) {
        super.publishToPoisonQueue(envelope, properties, reason, body);
        return;
    }

    Iterator<AMQPMessageBundle> messages = unacknowledgedMessages.values().iterator();
    long deliveryTag = envelope.getDeliveryTag();

    while (messages.hasNext()) {
        AMQPMessageBundle next = messages.next();

        if (next.getEnvelope().getDeliveryTag() > deliveryTag) {
            break;
        }

        super.publishToPoisonQueue(next.getEnvelope(), next.getBasicProperties(), reason, next.getBody());
    }
}
 
開發者ID:RentTheRunway,項目名稱:conduit,代碼行數:28,代碼來源:AMQPAsyncQueueConsumer.java

示例6: createConsumer

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
private Consumer createConsumer(final Channel channel)
{
    return new DefaultConsumer(channel) {
        @Override
        public void handleDelivery(String consumerTag,
                                   Envelope envelope,
                                   AMQP.BasicProperties properties,
                                   byte[] body)
                throws IOException
        {
            long deliveryTag = envelope.getDeliveryTag();

            String row[] = ExportOnServerVerifier.RoughCSVTokenizer.tokenize(new String(body, Charsets.UTF_8));
            if (row.length != 29) {
                return;
            }
            ExportOnServerVerifier.ValidationErr err = null;
            try {
                err = ExportOnServerVerifier.verifyRow(row);
            } catch (ExportOnServerVerifier.ValidationErr validationErr) {
                validationErr.printStackTrace();
            }
            if (err != null) {
                System.out.println("ERROR in validation: " + err.toString());
            }

            if (++m_verifiedRows % VALIDATION_REPORT_INTERVAL == 0) {
                System.out.println("Verified " + m_verifiedRows + " rows.");
            }

            channel.basicAck(deliveryTag, false);
        }
    };
}
 
開發者ID:anhnv-3991,項目名稱:VoltDB,代碼行數:35,代碼來源:ExportRabbitMQVerifier.java

示例7: handleDelivery

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
                           byte[] body) throws IOException {

	if (bindAckToRequest) {
		this.deliveryTag = envelope.getDeliveryTag();
	}

	doOnNext.accept(QueueSignal.from(body, consumerTag, envelope, properties));
}
 
開發者ID:smaldini,項目名稱:reactor-incubator,代碼行數:11,代碼來源:LapinQueueSubscription.java

示例8: handleDelivery

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
@Override public void handleDelivery(String consumerTag,
                           Envelope envelope,
                           AMQP.BasicProperties basicProperties,
                           byte[] body) throws IOException {

    Message message = new Message();

    try {
        ThriftUtils.createThriftFromBytes(body, message);
        TBase event = null;
        String gatewayId = null;
        long deliveryTag = envelope.getDeliveryTag();
        if (message.getMessageType().equals(MessageType.LAUNCHPROCESS)) {
            ProcessSubmitEvent processSubmitEvent = new ProcessSubmitEvent();
            ThriftUtils.createThriftFromBytes(message.getEvent(), processSubmitEvent);
            log.info(" Message Received with message id '" + message.getMessageId()
                    + " and with message type:" + message.getMessageType() + ", for processId:" +
                    processSubmitEvent.getProcessId() + ", expId:" + processSubmitEvent.getExperimentId());
            event = processSubmitEvent;
            gatewayId = processSubmitEvent.getGatewayId();
            MessageContext messageContext = new MessageContext(event, message.getMessageType(),
                    message.getMessageId(), gatewayId, deliveryTag);
            messageContext.setUpdatedTime(AiravataUtils.getTime(message.getUpdatedTime()));
            messageContext.setIsRedeliver(envelope.isRedeliver());
            handler.onMessage(messageContext);
        } else {
            log.error("{} message type is not handle in ProcessLaunch Subscriber. Sending ack for " +
                    "delivery tag {} ", message.getMessageType().name(), deliveryTag);
            sendAck(deliveryTag);
        }
    } catch (TException e) {
        String msg = "Failed to de-serialize the thrift message, from routing keys:" + envelope.getRoutingKey();
        log.warn(msg, e);
    }

}
 
開發者ID:apache,項目名稱:airavata,代碼行數:37,代碼來源:ProcessConsumer.java

示例9: handleDelivery

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
@Override
public void handleDelivery(String consumerTag,
                           Envelope envelope,
                           AMQP.BasicProperties properties,
                           byte[] body) throws IOException {

    Message message = new Message();

    try {
        ThriftUtils.createThriftFromBytes(body, message);
        long deliveryTag = envelope.getDeliveryTag();
        if (message.getMessageType() == MessageType.EXPERIMENT || message.getMessageType() == MessageType.EXPERIMENT_CANCEL) {
            TBase event = null;
            String gatewayId = null;
            ExperimentSubmitEvent experimentEvent = new ExperimentSubmitEvent();
            ThriftUtils.createThriftFromBytes(message.getEvent(), experimentEvent);
            log.info(" Message Received with message id '" + message.getMessageId()
                    + "' and with message type '" + message.getMessageType() + "'  for experimentId:" +
                    " " +
                    experimentEvent.getExperimentId());
            event = experimentEvent;
            gatewayId = experimentEvent.getGatewayId();
            MessageContext messageContext = new MessageContext(event, message.getMessageType(),
                    message.getMessageId(), gatewayId, deliveryTag);
            messageContext.setUpdatedTime(AiravataUtils.getTime(message.getUpdatedTime()));
            messageContext.setIsRedeliver(envelope.isRedeliver());
            handler.onMessage(messageContext);
        } else {
            log.error("{} message type is not handle in ProcessLaunch Subscriber. Sending ack for " +
                    "delivery tag {} ", message.getMessageType().name(), deliveryTag);
            sendAck(deliveryTag);
        }
    } catch (TException e) {
        String msg = "Failed to de-serialize the thrift message, from routing keys:" + envelope.getRoutingKey();
        log.warn(msg, e);
    }

}
 
開發者ID:apache,項目名稱:airavata,代碼行數:39,代碼來源:ExperimentConsumer.java

示例10: respond

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
private void respond(AMQPMessageBundle messageBundle, ActionResponse actionResponse) {
    //! We can't issue any blocking amqp calls in the context of this method, otherwise
    //  channel's internal thread(s) will deadlock. Both, basicAck and basicReject are
    //  asynchronous.
    Envelope envelope = messageBundle.getEnvelope();
    Long deliveryTag = envelope.getDeliveryTag();
    byte[] body = messageBundle.getBody();
    AMQP.BasicProperties properties = messageBundle.getBasicProperties();

    try {
        switch (actionResponse.getAction()) {
            case Acknowledge:
                ack(deliveryTag);
                break;

            case RejectAndDiscard:
                log.warn("Discarding message, body = " + new String(body));
                //! Let the broker know we rejected this message. Then publish this bad boy onto
                //  the poison queue. Don't bother confirming for two reasons; we don't care, and
                //  we can't issue blocking calls here.
                publishToPoisonQueue(envelope, properties, actionResponse.getReason(), body);
                reject(deliveryTag);
                break;

            case RejectAndRequeue:
                log.warn("Received an unknown message, body = " + new String(body));
                log.warn("\tAdjusting headers for retry.");

                if (!retry(envelope, properties, body)) {
                    publishToPoisonQueue(envelope, properties, actionResponse.getReason(), body);
                }
                reject(deliveryTag);
                break;
        }
    } catch (Exception e) {
        callback.notifyOfActionFailure(e);
    }
}
 
開發者ID:RentTheRunway,項目名稱:conduit,代碼行數:39,代碼來源:AMQPQueueConsumer.java

示例11: respond

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
protected void respond(AMQPMessageBundle messageBundle, ActionResponse actionResponse, boolean multiple) {
    //! We can't issue any blocking amqp calls in the context of this method, otherwise
    //  channel's internal thread(s) will deadlock. Both, basicAck and basicReject are
    //  asynchronous.
    Envelope envelope = messageBundle.getEnvelope();
    Long deliveryTag = envelope.getDeliveryTag();
    byte[] body = messageBundle.getBody();
    AMQP.BasicProperties properties = messageBundle.getBasicProperties();

    try {
        switch (actionResponse.getAction()) {
            case Acknowledge:
                ack(deliveryTag, multiple);
                break;

            case RejectAndDiscard:
                log.warn("Discarding message, body = " + new String(body));
                //! Let the broker know we rejected this message. Then publish this bad boy onto
                //  the poison queue. Don't bother confirming for two reasons; we don't care, and
                //  we can't issue blocking calls here.
                publishToPoisonQueue(envelope, properties, actionResponse.getReason(), body, multiple);
                reject(deliveryTag, multiple);
                break;

            case RejectAndRequeue:
                log.warn("Received an unknown message, body = " + new String(body));
                log.warn("\tAdjusting headers for retry.");

                if (!retry(envelope, properties, body, multiple)) {
                    publishToPoisonQueue(envelope, properties, actionResponse.getReason(), body, multiple);
                }
                reject(deliveryTag, multiple);
                break;
        }
    } catch (Exception e) {
        callback.notifyOfActionFailure(e);
    }
}
 
開發者ID:RentTheRunway,項目名稱:conduit,代碼行數:39,代碼來源:AMQPAsyncQueueConsumer.java

示例12: handleDelivery

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
    long deliveryTag = envelope.getDeliveryTag();

    Stopwatch stopwatch = Stopwatch.createStarted();
    try {
        T message = MAPPER.readValue(body, type);

        if (log.isTraceEnabled()) {
            log.trace("Received message '{}' with data '{}'.", deliveryTag, new String(body));
        }

        processor.apply(message);
        getChannel().basicAck(deliveryTag, false);

        stopwatch.stop();
        successCount.mark();
        successDuration.update(stopwatch.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS);
        log.info("Processed {} message '{}' succesfully in {} ms.", type.getSimpleName(), deliveryTag, stopwatch.elapsed(TimeUnit.MILLISECONDS));
    } catch (Exception e) {
        getChannel().basicNack(deliveryTag, false, true);

        stopwatch.stop();
        failureCount.mark();
        failureDuration.update(stopwatch.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS);
        log.error("Processing {} message '{}' failed with exception:", type.getSimpleName(), deliveryTag, e);
    }
}
 
開發者ID:Lugribossk,項目名稱:dropwizard-experiment,代碼行數:29,代碼來源:FunctionConsumer.java

示例13: handleDelivery

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
@Override
public void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties,
    byte[] body) throws IOException {
  if (closed)
    return;
  long deliveryTag = envelope.getDeliveryTag();
  channelHandler.maxDeliveryTag = deliveryTag = deliveryTag
      + channelHandler.previousMaxDeliveryTag;
  delegate.handleDelivery(
      consumerTag,
      new Envelope(deliveryTag, envelope.isRedeliver(), envelope.getExchange(),
          envelope.getRoutingKey()), properties, body);
}
 
開發者ID:jhalterman,項目名稱:lyra,代碼行數:14,代碼來源:ConsumerDelegate.java

示例14: HaEnvelope

import com.rabbitmq.client.Envelope; //導入方法依賴的package包/類
public HaEnvelope(long internalChannelId, Envelope internalEnvelope) {
	this.deliveryTag = new DeliveryTag(internalChannelId, internalEnvelope.getDeliveryTag());
	this.internalEnvelope = internalEnvelope;
}
 
開發者ID:jclawson,項目名稱:rabbitmq-ha-client,代碼行數:5,代碼來源:HaEnvelope.java


注:本文中的com.rabbitmq.client.Envelope.getDeliveryTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。