// Path: src/nifi-jms-jndi/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java
// static interface ConsumerCallback {
//     void accept(JMSResponse response);
// }
// 
// Path: src/nifi-jms-jndi/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java
// static class JMSResponse {
//     private final byte[] messageBody;
// 
//     private final Map<String, Object> messageHeaders;
// 
//     private final Map<String, String> messageProperties;
// 
//     JMSResponse(byte[] messageBody, Map<String, Object> messageHeaders, Map<String, String> messageProperties) {
//         this.messageBody = messageBody;
//         this.messageHeaders = Collections.unmodifiableMap(messageHeaders);
//         this.messageProperties = Collections.unmodifiableMap(messageProperties);
//     }
// 
//     public byte[] getMessageBody() {
//         return this.messageBody;
//     }
// 
//     public Map<String, Object> getMessageHeaders() {
//         return this.messageHeaders;
//     }
// 
//     public Map<String, String> getMessageProperties() {
//         return messageProperties;
//     }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.BytesMessage;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import org.apache.nifi.jms.processors.JMSConsumer.ConsumerCallback;
import org.apache.nifi.jms.processors.JMSConsumer.JMSResponse;
import org.apache.nifi.logging.ComponentLog;
import org.junit.Test;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.jms.support.JmsHeaders;
                    callbackInvoked.set(true);
                    assertEquals("1", new String(response.getMessageBody()));
                    throw new RuntimeException("intentional to avoid explicit ack");
                }
            });
        } catch (Exception e) {
            // ignore
        }
        assertTrue(callbackInvoked.get());
        callbackInvoked.set(false);

        // should receive the same message, but will process it successfully
        try {
            consumer.consume(destinationName, new ConsumerCallback() {
                @Override
                public void accept(JMSResponse response) {
                    callbackInvoked.set(true);
                    assertEquals("1", new String(response.getMessageBody()));
                }
            });
        } catch (Exception e) {
            // ignore
        }
        assertTrue(callbackInvoked.get());
        callbackInvoked.set(false);

        // receiving next message and fail again
        try {
            consumer.consume(destinationName, new ConsumerCallback() {
                @Override
// Path: src/nifi-jms-jndi/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java
// static interface ConsumerCallback {
//     void accept(JMSResponse response);
// }
// 
// Path: src/nifi-jms-jndi/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/JMSConsumer.java
// static class JMSResponse {
//     private final byte[] messageBody;
// 
//     private final Map<String, Object> messageHeaders;
// 
//     private final Map<String, String> messageProperties;
// 
//     JMSResponse(byte[] messageBody, Map<String, Object> messageHeaders, Map<String, String> messageProperties) {
//         this.messageBody = messageBody;
//         this.messageHeaders = Collections.unmodifiableMap(messageHeaders);
//         this.messageProperties = Collections.unmodifiableMap(messageProperties);
//     }
// 
//     public byte[] getMessageBody() {
//         return this.messageBody;
//     }
// 
//     public Map<String, Object> getMessageHeaders() {
//         return this.messageHeaders;
//     }
// 
//     public Map<String, String> getMessageProperties() {
//         return messageProperties;
//     }
// }


// Path: src/nifi-jms-jndi/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/processors/JMSPublisherConsumerTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.BytesMessage;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import org.apache.nifi.jms.processors.JMSConsumer.ConsumerCallback;
import org.apache.nifi.jms.processors.JMSConsumer.JMSResponse;
import org.apache.nifi.logging.ComponentLog;
import org.junit.Test;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.jms.support.JmsHeaders;

                    callbackInvoked.set(true);
                    assertEquals("1", new String(response.getMessageBody()));
                    throw new RuntimeException("intentional to avoid explicit ack");
                }
            });
        } catch (Exception e) {
            // ignore
        }
        assertTrue(callbackInvoked.get());
        callbackInvoked.set(false);

        // should receive the same message, but will process it successfully
        try {
            consumer.consume(destinationName, new ConsumerCallback() {
                @Override
                public void accept(JMSResponse response) {
                    callbackInvoked.set(true);
                    assertEquals("1", new String(response.getMessageBody()));
                }
            });
        } catch (Exception e) {
            // ignore
        }
        assertTrue(callbackInvoked.get());
        callbackInvoked.set(false);

        // receiving next message and fail again
        try {
            consumer.consume(destinationName, new ConsumerCallback() {
                @Override
                public void accept(JMSResponse response) {