I'm having problem in replacing this particular example:
Consumer consumer = new DefaultConsumer(channel) {
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
throws IOException {
String message = new String(body, "UTF-8");
System.out.println(" [x] Received '" + message + "'");
}
};
Is it possible to replace that with lambda as it uses non-default constructor for DefaultConsumer?
It's from rabbitMQ java tutorial -> LINK to whole class
DefaultConsumer. Is there more than one abstract method ? How are you usingConsumer consumer?DefaultConsumers though, you could create a helper method, taking alambdaas input and returning an anonymous subclass ofDefaultconsumer.