[rabbitmq-discuss] Compile error for Rabbit RPC server - RabbitMQ version 3.2.4
j.b.davis at accenturefederal.com
j.b.davis at accenturefederal.com
Fri Mar 7 15:53:42 GMT 2014
I'm trying to compile the RPC server example for Java found on https://www.rabbitmq.com/tutorials/tutorial-six-java.html (using the Netbeans IDE) and getting this error:
C:\Users\j.b.davis\Documents\NetBeansProjects\BunnyRPCserver\src\bunnyrpcserver\BunnyRPCserver.java:82: error: cannot find symbol
BasicProperties replyProps = new BasicProperties.Builder()
symbol: class Builder
location: interface BasicProperties
my source = :
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bunnyrpcserver;
/**
*
* @author j.b.davis
*/
import com.rabbitmq.client.BasicProperties;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.ConsumerCancelledException;
import com.rabbitmq.client.QueueingConsumer;
import com.rabbitmq.client.ShutdownSignalException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class BunnyRPCserver
{
/**
* @param args the command line arguments
*/
private static final String RPC_QUEUE_NAME = "rpc_queue";
public static void main(String[] args)
{
try
{
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare(RPC_QUEUE_NAME, false, false, false, null);
channel.basicQos(1);
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume(RPC_QUEUE_NAME, false, consumer);
System.out.println(" [x] Awaiting RPC requests");
while (true)
{
QueueingConsumer.Delivery delivery = null;
try
{
delivery = consumer.nextDelivery();
}
catch (InterruptedException ex)
{
Logger.getLogger(BunnyRPCserver.class.getName()).log(
Level.SEVERE, null, ex);
}
catch (ShutdownSignalException ex)
{
Logger.getLogger(BunnyRPCserver.class.getName()).log(
Level.SEVERE, null, ex);
}
catch (ConsumerCancelledException ex)
{
Logger.getLogger(BunnyRPCserver.class.getName()).log(
Level.SEVERE, null, ex);
}
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 = null;
try
{
response = "" + fib(n);
}
catch (Exception ex)
{
Logger.getLogger(BunnyRPCserver.class.getName()).log(
Level.SEVERE, null, ex);
}
channel.basicPublish("", props.getReplyTo(), replyProps,
response.getBytes());
channel.basicAck(delivery.getEnvelope().getDeliveryTag(),
false);
}
}
catch (IOException ex)
{
Logger.getLogger(BunnyRPCserver.class.getName()).log(Level.SEVERE,
null, ex);
}
}
private static int fib(int n) throws Exception
{
if (n == 0)
return (0);
if (n == 1)
return (1);
return (fib(n - 1) + fib(n - 2));
}
}
I must be doing something wrong, but what??
John Davis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140307/07a81960/attachment.html>
More information about the rabbitmq-discuss
mailing list