Skip to main content
edited tags
Link
improved formatting
Source Link

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

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

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

Source Link
doublemc
  • 3.3k
  • 10
  • 38
  • 74

Java 8: replace anonymous class with lambda

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