public void stop() {
    isStopped = true;
    try {
      queue.put(Message.POISON_PILL);
    } catch (InterruptedException e) {
      // allow thread to exit
      LOGGER.error("Exception caught.", e);
    }
  }
@Test
  void testStop() throws Exception {
    final var publishPoint = mock(MqPublishPoint.class);
    final var producer = new Producer("producer", publishPoint);
    verifyNoMoreInteractions(publishPoint);

    producer.stop();
    verify(publishPoint).put(eq(Message.POISON_PILL));

    try {
      producer.send("Hello!");
      fail("Expected 'IllegalStateException' at this point, since the producer has stopped!");
    } catch (IllegalStateException e) {
      assertNotNull(e);
      assertNotNull(e.getMessage());
      assertEquals("Producer Hello! was stopped and fail to deliver requested message [producer].",
          e.getMessage());
    }

    verifyNoMoreInteractions(publishPoint);
  }