本文整理汇总了Java中com.rabbitmq.client.Envelope.getRoutingKey方法的典型用法代码示例。如果您正苦于以下问题:Java Envelope.getRoutingKey方法的具体用法?Java Envelope.getRoutingKey怎么用?Java Envelope.getRoutingKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rabbitmq.client.Envelope
的用法示例。
在下文中一共展示了Envelope.getRoutingKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleDelivery
import com.rabbitmq.client.Envelope; //导入方法依赖的package包/类
private void handleDelivery(final String queueName, final Envelope envelope, final byte[] body) {
final Ternary<String, Channel, EventSubscriber> queueDetails = s_subscribers.get(queueName);
if (queueDetails != null) {
final EventSubscriber subscriber = queueDetails.third();
final String routingKey = envelope.getRoutingKey();
final String eventSource = getEventSourceFromRoutingKey(routingKey);
final String eventCategory = getEventCategoryFromRoutingKey(routingKey);
final String eventType = getEventTypeFromRoutingKey(routingKey);
final String resourceType = getResourceTypeFromRoutingKey(routingKey);
final String resourceUUID = getResourceUUIDFromRoutingKey(routingKey);
final Event event = new Event(eventSource, eventCategory, eventType, resourceType, resourceUUID);
event.setDescription(new String(body));
// deliver the event to call back object provided by subscriber
subscriber.onEvent(event);
}
}
示例2: 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);
}
示例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);
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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);
TBase event = null;
String gatewayId = null;
if (message.getMessageType().equals(MessageType.EXPERIMENT)) {
ExperimentStatusChangeEvent experimentStatusChangeEvent = new ExperimentStatusChangeEvent();
ThriftUtils.createThriftFromBytes(message.getEvent(), experimentStatusChangeEvent);
log.debug(" Message Received with message id '" + message.getMessageId()
+ "' and with message type '" + message.getMessageType() + "' with status " +
experimentStatusChangeEvent.getState());
event = experimentStatusChangeEvent;
gatewayId = experimentStatusChangeEvent.getGatewayId();
} else if (message.getMessageType().equals(MessageType.PROCESS)) {
ProcessStatusChangeEvent processStatusChangeEvent = new ProcessStatusChangeEvent();
ThriftUtils.createThriftFromBytes(message.getEvent(), processStatusChangeEvent);
log.debug("Message Recieved with message id :" + message.getMessageId() + " and with " +
"message type " + message.getMessageType() + " with status " +
processStatusChangeEvent.getState());
event = processStatusChangeEvent;
gatewayId = processStatusChangeEvent.getProcessIdentity().getGatewayId();
} else if (message.getMessageType().equals(MessageType.TASK)) {
TaskStatusChangeEvent taskStatusChangeEvent = new TaskStatusChangeEvent();
ThriftUtils.createThriftFromBytes(message.getEvent(), taskStatusChangeEvent);
log.debug(" Message Received with message id '" + message.getMessageId()
+ "' and with message type '" + message.getMessageType() + "' with status " +
taskStatusChangeEvent.getState());
event = taskStatusChangeEvent;
gatewayId = taskStatusChangeEvent.getTaskIdentity().getGatewayId();
} else if (message.getMessageType() == MessageType.PROCESSOUTPUT) {
TaskOutputChangeEvent taskOutputChangeEvent = new TaskOutputChangeEvent();
ThriftUtils.createThriftFromBytes(message.getEvent(), taskOutputChangeEvent);
log.debug(" Message Received with message id '" + message.getMessageId() + "' and with message type '" + message.getMessageType());
event = taskOutputChangeEvent;
gatewayId = taskOutputChangeEvent.getTaskIdentity().getGatewayId();
} else if (message.getMessageType().equals(MessageType.JOB)) {
JobStatusChangeEvent jobStatusChangeEvent = new JobStatusChangeEvent();
ThriftUtils.createThriftFromBytes(message.getEvent(), jobStatusChangeEvent);
log.debug(" Message Received with message id '" + message.getMessageId()
+ "' and with message type '" + message.getMessageType() + "' with status " +
jobStatusChangeEvent.getState());
event = jobStatusChangeEvent;
gatewayId = jobStatusChangeEvent.getJobIdentity().getGatewayId();
} else if (message.getMessageType().equals(MessageType.LAUNCHPROCESS)) {
TaskSubmitEvent taskSubmitEvent = new TaskSubmitEvent();
ThriftUtils.createThriftFromBytes(message.getEvent(), taskSubmitEvent);
log.debug(" Message Received with message id '" + message.getMessageId()
+ "' and with message type '" + message.getMessageType() + "' for experimentId: " +
taskSubmitEvent.getExperimentId() + "and taskId: " + taskSubmitEvent.getTaskId());
event = taskSubmitEvent;
gatewayId = taskSubmitEvent.getGatewayId();
} else if (message.getMessageType().equals(MessageType.TERMINATEPROCESS)) {
TaskTerminateEvent taskTerminateEvent = new TaskTerminateEvent();
ThriftUtils.createThriftFromBytes(message.getEvent(), taskTerminateEvent);
log.debug(" Message Received with message id '" + message.getMessageId()
+ "' and with message type '" + message.getMessageType() + "' for experimentId: " +
taskTerminateEvent.getExperimentId() + "and taskId: " + taskTerminateEvent.getTaskId());
event = taskTerminateEvent;
gatewayId = null;
}
MessageContext messageContext = new MessageContext(event, message.getMessageType(), message.getMessageId(), gatewayId);
messageContext.setUpdatedTime(AiravataUtils.getTime(message.getUpdatedTime()));
messageContext.setIsRedeliver(envelope.isRedeliver());
handler.onMessage(messageContext);
} catch (TException e) {
String msg = "Failed to de-serialize the thrift message, from routing keys: " + envelope.getRoutingKey();
log.warn(msg, e);
}
}