本文整理汇总了Java中com.rabbitmq.client.MessageProperties.BASIC属性的典型用法代码示例。如果您正苦于以下问题:Java MessageProperties.BASIC属性的具体用法?Java MessageProperties.BASIC怎么用?Java MessageProperties.BASIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.rabbitmq.client.MessageProperties
的用法示例。
在下文中一共展示了MessageProperties.BASIC属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
/****
* This method is used to publish the message to RabbitMQ
* @param routingKey
* @param msg is Eiffel Event
* @throws IOException
*/
public void send(String routingKey, String msg) throws IOException {
Channel channel = giveMeRandomChannel();
channel.addShutdownListener(new ShutdownListener() {
public void shutdownCompleted(ShutdownSignalException cause) {
// Beware that proper synchronization is needed here
if (cause.isInitiatedByApplication()) {
log.debug("Shutdown is initiated by application. Ignoring it.");
} else {
log.error("Shutdown is NOT initiated by application.");
log.error(cause.getMessage());
boolean cliMode = Boolean.getBoolean(PropertiesConfig.CLI_MODE);
if (cliMode) {
System.exit(-3);
}
}
}
});
BasicProperties msgProps = MessageProperties.BASIC;
if (usePersitance)
msgProps = MessageProperties.PERSISTENT_BASIC;
channel.basicPublish(exchangeName, routingKey, msgProps, msg.getBytes());
log.info("Published message with size {} bytes on exchange '{}' with routing key '{}'", msg.getBytes().length,
exchangeName, routingKey);
}
示例2: convert
private static AMQP.BasicProperties convert(String name) throws RuleException {
switch (name) {
case "BASIC":
return MessageProperties.BASIC;
case "TEXT_PLAIN":
return MessageProperties.TEXT_PLAIN;
case "MINIMAL_BASIC":
return MessageProperties.MINIMAL_BASIC;
case "MINIMAL_PERSISTENT_BASIC":
return MessageProperties.MINIMAL_PERSISTENT_BASIC;
case "PERSISTENT_BASIC":
return MessageProperties.PERSISTENT_BASIC;
case "PERSISTENT_TEXT_PLAIN":
return MessageProperties.PERSISTENT_TEXT_PLAIN;
default:
throw new RuleException("Message Properties: '" + name + "' is undefined!");
}
}
示例3: createProps
private AMQP.BasicProperties createProps(InternalMessage message) {
if(message.getTimeout() < 0) {
return message.isDurable() ? MessageProperties.PERSISTENT_BASIC : MessageProperties.BASIC;
} else {
if(message.isDurable()) {
return new AMQP.BasicProperties.Builder().contentType("application/octet-stream").deliveryMode(2)
.priority(0).expiration(String.valueOf(message.getTimeout())).build();
} else {
return new AMQP.BasicProperties.Builder().contentType("application/octet-stream").deliveryMode(1)
.priority(0).expiration(String.valueOf(message.getTimeout())).build();
}
}
}