本文整理汇总了Java中com.rabbitmq.client.AMQP.Queue.DeclareOk类的典型用法代码示例。如果您正苦于以下问题:Java DeclareOk类的具体用法?Java DeclareOk怎么用?Java DeclareOk使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeclareOk类属于com.rabbitmq.client.AMQP.Queue包,在下文中一共展示了DeclareOk类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createListenerContainer
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Override
protected Connection createListenerContainer() throws Exception {
log.debug("Creating connection");
Connection conn = endpoint.connect(executorService);
log.debug("Creating channel");
Channel channel = conn.createChannel();
// setup the basicQos
if (endpoint.isPrefetchEnabled()) {
channel.basicQos(endpoint.getPrefetchSize(), endpoint.getPrefetchCount(),
endpoint.isPrefetchGlobal());
}
//Let the server pick a random name for us
DeclareOk result = channel.queueDeclare();
log.info("Using temporary queue name: {}", result.getQueue());
setReplyTo(result.getQueue());
//TODO check for the RabbitMQConstants.EXCHANGE_NAME header
channel.queueBind(getReplyTo(), endpoint.getExchangeName(), getReplyTo());
consumer = new RabbitConsumer(this, channel);
consumer.start();
return conn;
}
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:TemporaryQueueReplyManager.java
示例2: receive
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void receive() throws Exception {
String QUEUE_NAME = "TEST_QUEUE";
//
DeclareOk declare = channel.queueDeclare(QUEUE_NAME, false, false,
false, null);
// System.out.println("declare: " + declare);
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(QUEUE_NAME, true, consumer);
//
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
System.out.println(message);
}
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:17,代码来源:RabbitMqTest.java
示例3: receivePersistent
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void receivePersistent() throws Exception {
String QUEUE_NAME = "TEST_PERSISTENT";
//
DeclareOk declare = channel.queueDeclare(QUEUE_NAME, true, false,
false, null);// durable=true
channel.basicQos(1);//
// System.out.println("declare: " + declare);
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(QUEUE_NAME, false, consumer);
//
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
System.out.println(message);
//
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
}
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:20,代码来源:RabbitMqTest.java
示例4: receiveExchange
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void receiveExchange() throws Exception {
String EXCHANGE_NAME = "TEST_EXCHANGE";
//
com.rabbitmq.client.AMQP.Exchange.DeclareOk declare = channel
.exchangeDeclare(EXCHANGE_NAME, "fanout");
// System.out.println("declare: " + declare);
String queueName = channel.queueDeclare().getQueue();
System.out.println("queueName: " + queueName);
channel.queueBind(queueName, EXCHANGE_NAME, "");
//
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, true, consumer);
//
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
System.out.println(message);
}
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:21,代码来源:RabbitMqTest.java
示例5: receiveExchangeDirect
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void receiveExchangeDirect() throws Exception {
String EXCHANGE_NAME = "TEST_EXCHANGE_DIRECT";
//
com.rabbitmq.client.AMQP.Exchange.DeclareOk declare = channel
.exchangeDeclare(EXCHANGE_NAME, "direct");
// System.out.println("declare: " + declare);
String queueName = channel.queueDeclare().getQueue();
System.out.println("queueName: " + queueName);
//
channel.queueBind(queueName, EXCHANGE_NAME, "info");
channel.queueBind(queueName, EXCHANGE_NAME, "error");
//
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, true, consumer);
//
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
String routingKey = delivery.getEnvelope().getRoutingKey();
System.out.println(" [x] Received '" + routingKey + "':'" + message
+ "'");
}
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:26,代码来源:RabbitMqTest.java
示例6: receiveExchangeTopic
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void receiveExchangeTopic() throws Exception {
String EXCHANGE_NAME = "TEST_EXCHANGE_TOPIC";
//
com.rabbitmq.client.AMQP.Exchange.DeclareOk declare = channel
.exchangeDeclare(EXCHANGE_NAME, "topic");
// System.out.println("declare: " + declare);
String queueName = channel.queueDeclare().getQueue();
System.out.println("queueName: " + queueName);
//
channel.queueBind(queueName, EXCHANGE_NAME, "#");
channel.queueBind(queueName, EXCHANGE_NAME, "kern.*");
channel.queueBind(queueName, EXCHANGE_NAME, "*.critical");
//
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, true, consumer);
//
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
String routingKey = delivery.getEnvelope().getRoutingKey();
System.out.println(" [x] Received '" + routingKey + "':'" + message
+ "'");
}
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:27,代码来源:RabbitMqTest.java
示例7: doesReceiverExist
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
/**
* Check if a certain receiver (queue) exists.
*
* @param receiver
* the name of the receiver.
* @return true if it does, false if it doesn't exists.
*/
public boolean doesReceiverExist(final String receiver)
{
if (objTemplate != null)
{
return objTemplate.execute(new ChannelCallback<DeclareOk>()
{
@Override
public DeclareOk doInRabbit(com.rabbitmq.client.Channel channel) throws Exception
{
try
{
Configuration config = objResources.getConfiguration();
String name = config.getQueuePrefix() + receiver + config.getQueueSuffix();
return channel.queueDeclarePassive(name);
}
catch (Exception e)
{
objMonitor.info(SendController.class, "The receiver client seems to be existing. This does not mean that it's connected and receiving message.");
return null;
}
}
}) != null;
}
return false;
}
开发者ID:MaxxtonGroup,项目名称:async-amqp-messaging,代码行数:33,代码来源:SendController.java
示例8: creatQueue
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void creatQueue() throws Exception {
String QUEUE_NAME = "TEST_BENCHMARK";
//
Channel channel = createChannel();
DeclareOk declareOk = channel.queueDeclare(QUEUE_NAME, false, false,
false, null);
System.out.println(declareOk);
assertNotNull(declareOk);
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:11,代码来源:BenchmarkRmMqoSupporterTest.java
示例9: createExchange
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void createExchange() throws Exception {
String EXCHANGE_NAME = "TEST_BENCHMARK";
//
Channel channel = createChannel();
com.rabbitmq.client.AMQP.Exchange.DeclareOk declareOk = channel
.exchangeDeclare(EXCHANGE_NAME, "fanout");
System.out.println(declareOk);
assertNotNull(declareOk);
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:11,代码来源:BenchmarkRmMqoSupporterTest.java
示例10: send
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void send() throws Exception {
String QUEUE_NAME = "TEST_QUEUE";
//
String message = "Hello World";
DeclareOk declare = channel.queueDeclare(QUEUE_NAME, false, false,
false, null);
// System.out.println("declare: " + declare);
channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
System.out.println(" [x] Sent '" + message + "'");
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:12,代码来源:RabbitMqTest.java
示例11: sendPersistent
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void sendPersistent() throws Exception {
String QUEUE_NAME = "TEST_PERSISTENT";
//
String message = "Hello World";
DeclareOk declare = channel.queueDeclare(QUEUE_NAME, true, false,
false, null);// durable=true
// System.out.println("declare: " + declare);
channel.basicPublish("", QUEUE_NAME,
MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes());
System.out.println(" [x] Sent '" + message + "'");
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:13,代码来源:RabbitMqTest.java
示例12: sendExchange
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void sendExchange() throws Exception {
String EXCHANGE_NAME = "TEST_EXCHANGE";
//
String message = "Hello World";
com.rabbitmq.client.AMQP.Exchange.DeclareOk declare = channel
.exchangeDeclare(EXCHANGE_NAME, "fanout");
// System.out.println("declare: " + declare);
channel.basicPublish(EXCHANGE_NAME, "", null, message.getBytes());
System.out.println(" [x] Sent '" + message + "'");
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:12,代码来源:RabbitMqTest.java
示例13: sendExchangeDirect
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void sendExchangeDirect() throws Exception {
String EXCHANGE_NAME = "TEST_EXCHANGE_DIRECT";
//
String message = "Hello World";
com.rabbitmq.client.AMQP.Exchange.DeclareOk declare = channel
.exchangeDeclare(EXCHANGE_NAME, "direct");
// System.out.println("declare: " + declare);
String severity = "info";
channel.basicPublish(EXCHANGE_NAME, severity, null, message.getBytes());
System.out.println(" [x] Sent '" + severity + "':'" + message + "'");
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:13,代码来源:RabbitMqTest.java
示例14: sendExchangeTopic
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void sendExchangeTopic() throws Exception {
String EXCHANGE_NAME = "TEST_EXCHANGE_TOPIC";
//
String message = "Hello World";
com.rabbitmq.client.AMQP.Exchange.DeclareOk declare = channel
.exchangeDeclare(EXCHANGE_NAME, "topic");
// System.out.println("declare: " + declare);
String routingKey = "kern.critical";
channel.basicPublish(EXCHANGE_NAME, routingKey, null,
message.getBytes());
System.out.println(" [x] Sent '" + routingKey + "':'" + message + "'");
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:14,代码来源:RabbitMqTest.java
示例15: rpcServer
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Test
public void rpcServer() throws Exception {
String QUEUE_NAME = "TEST_RPC";
//
DeclareOk declare = channel.queueDeclare(QUEUE_NAME, false, false,
false, null);
// System.out.println("declare: " + declare);
channel.basicQos(1);
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(QUEUE_NAME, false, consumer);
System.out.println(" [x] Awaiting RPC requests");
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
BasicProperties props = delivery.getProperties();
BasicProperties replyProps = new BasicProperties.Builder()
.correlationId(props.getCorrelationId()).build();
String message = new String(delivery.getBody());
int n = Integer.parseInt(message);
System.out.println(" [.] fib(" + message + ")");
String response = "" + fib(n);
channel.basicPublish("", props.getReplyTo(), replyProps,
response.getBytes());
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
}
}
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:34,代码来源:RabbitMqTest.java
示例16: run
import com.rabbitmq.client.AMQP.Queue.DeclareOk; //导入依赖的package包/类
@Override
public void run() {
try {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.exchangeDeclare(EXCHANGE_NAME, "fanout", durable);
DeclareOk ok = channel.queueDeclare(queue_name, durable, false, false, null);
String queueName = ok.getQueue();
channel.queueBind(queueName, EXCHANGE_NAME, "");
System.out.println(" [" + queue_name + "] Waiting for messages. To exit press CTRL+C");
channel.basicQos(1); // 消息分发处理
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(queueName, false, consumer);
while (true) {
Thread.sleep(2000);
Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
System.out.println(" [" + queue_name + "] Received '" + message + "'");
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
}
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:colddew,项目名称:mix-web,代码行数:34,代码来源:SubscriberThead.java
注:本文中的com.rabbitmq.client.AMQP.Queue.DeclareOk类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论