src/main/java/com/redhat/messages/AcroBot.java
// Called when a message is received by the subscriber.
Called when a message is received by the subscriber.
Called when a message is received by the subscriber .
@Override
    public void receiveMessage(PubsubMessage pubsubMessage, AckReplyConsumer consumer) {
        System.out.println("Id : " + pubsubMessage.getMessageId());
        try {
            ObjectMapper mapper = new ObjectMapper();
            JsonNode dataJson = mapper.readTree(pubsubMessage.getData().toStringUtf8());
            System.out.println("Data : " + dataJson.toString());
            handle(dataJson);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            consumer.ack();
        }
    }
@ Override public void receiveMessage ( PubsubMessage pubsubMessage , AckReplyConsumer consumer ) { System . out . println ( "Id : " + pubsubMessage . getMessageId ( ) ) ; try { ObjectMapper mapper = new ObjectMapper ( ) ; JsonNode dataJson = mapper . readTree ( pubsubMessage . getData ( ) . toStringUtf8 ( ) ) ; System . out . println ( "Data : " + dataJson . toString ( ) ) ; handle ( dataJson ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { consumer . ack ( ) ; } }
Called when a message is received by the subscriber.
Called when a message is received by the subscriber .
// handle incoming message, then ack/nack the received message