@SuppressWarnings("unchecked")
    @JmsListener(destination = "${digilevering.topic.in}", containerFactory = "jmsListenerContainerFactory")
    public void receiveMessage(@Payload String message, MessageHeaders headers) {
        try {
            JAXBContext context = JAXBContext.newInstance(messageClass, ObjectFactory.class);
            Unmarshaller unmarshaller = context.createUnmarshaller();
            Object unmarshalledObject = unmarshaller.unmarshal(new StreamSource(new StringReader(message)));
            if (messageClass.isInstance(unmarshalledObject)) {
                M unmarshalledMessage = (M) unmarshalledObject;
                processMessage(unmarshalledMessage, headers);
            }
        } catch (JAXBException e) {
            e.printStackTrace();
        }
    }
@Test
    public void testUnmarshallingVerstrekkingAanAfnemer() throws IOException {
        List<VerstrekkingAanAfnemer> captureList = new ArrayList<>();
        Receiver<VerstrekkingAanAfnemer> verstrekkingAanAfnemerReceiver = new Receiver<>(new VerstrekkingAanAfnemer()) {
            @Override
            protected void processMessage(VerstrekkingAanAfnemer message, MessageHeaders headers) {
                captureList.add(message);
            }
        };

        Path xmlFile = Paths.get("src","test","resources", "verstrekkingAanAfnemer.xml");
        String xmlMessage = Files.readString(xmlFile);
        verstrekkingAanAfnemerReceiver.receiveMessage(xmlMessage, new MessageHeaders(new HashMap<>()));

        assertThat(captureList.size(), is(1));
        VerstrekkingAanAfnemer verstrekkingAanAfnemer = captureList.get(0);
        assertThat(verstrekkingAanAfnemer.getDatumtijdstempelDigilevering().toString(), is("2018-02-02T11:59:04.170+01:00"));
        assertThat(verstrekkingAanAfnemer.getDatumtijdstempelLV().toString(), is("2017-11-27T14:33:05.010+01:00"));
        assertThat(verstrekkingAanAfnemer.getKenmerkDigilevering(), is("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS"));
        assertThat(verstrekkingAanAfnemer.getKenmerkLV(), is("SSSSSSSSSSSSSSSSSSSSSSSSSSSSS"));
        assertThat(verstrekkingAanAfnemer.getVersieBerichttype(), is("3.10"));
        assertThat(verstrekkingAanAfnemer.getAbonnement().getNaam(), is(""));
        assertThat(verstrekkingAanAfnemer.getAbonnement().getVersie(), is(""));
        assertThat(verstrekkingAanAfnemer.getBasisregistratie(), is("BRP"));
        assertThat(verstrekkingAanAfnemer.getGebeurtenissoort().getNaam(), is("Gv01"));
        assertThat(verstrekkingAanAfnemer.getGebeurtenissoort().getVersie(), is("1.0"));

        assertThat(verstrekkingAanAfnemer.getGebeurtenisinhoud().getAf01(), nullValue());
        assertThat(verstrekkingAanAfnemer.getGebeurtenisinhoud().getAf11(), nullValue());
        assertThat(verstrekkingAanAfnemer.getGebeurtenisinhoud().getAg01(), nullValue());
        assertThat(verstrekkingAanAfnemer.getGebeurtenisinhoud().getNg01(), nullValue());
        assertThat(verstrekkingAanAfnemer.getGebeurtenisinhoud().getNull(), nullValue());
        assertThat(verstrekkingAanAfnemer.getGebeurtenisinhoud().getGv01(), notNullValue());
        Gv01 gv01 = verstrekkingAanAfnemer.getGebeurtenisinhoud().getGv01();
        assertThat(gv01.getANummer(), is("SSSSSSSSSS"));
        assertThat(gv01.getRandomKey(), is("00000000"));
        assertThat(gv01.getCategorie().size(), is(2));
        assertThat(gv01.getCategorie().get(0).getNummer(), is("08"));
        assertThat(gv01.getCategorie().get(0).getElement().size(), is(3));
        assertThat(gv01.getCategorie().get(0).getElement().get(0).getNummer(), is("PPPP"));
        assertThat(gv01.getCategorie().get(0).getElement().get(0).getValue(), is("PPPPPPPPPPPPPPPPPPPP"));
        assertThat(gv01.getCategorie().get(0).getElement().get(1).getNummer(), is("PPPP"));
        assertThat(gv01.getCategorie().get(0).getElement().get(1).getValue(), is("PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"));
        assertThat(gv01.getCategorie().get(0).getElement().get(2).getNummer(), is("PPPP"));
        assertThat(gv01.getCategorie().get(0).getElement().get(2).getValue(), is(""));
        assertThat(gv01.getCategorie().get(1).getNummer(), is("58"));
        assertThat(gv01.getCategorie().get(1).getElement().size(), is(3));
        assertThat(gv01.getCategorie().get(1).getElement().get(0).getNummer(), is("PPPP"));
        assertThat(gv01.getCategorie().get(1).getElement().get(0).getValue(), is("PPPPPPPPPPPPPPPPPPPPP"));
        assertThat(gv01.getCategorie().get(1).getElement().get(1).getNummer(), is("PPPP"));
        assertThat(gv01.getCategorie().get(1).getElement().get(1).getValue(), is("PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"));
        assertThat(gv01.getCategorie().get(1).getElement().get(2).getNummer(), is("PPPP"));
        assertThat(gv01.getCategorie().get(1).getElement().get(2).getValue(), is("O"));
    }