@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 testUnmarshallingAfnemersberichtAanDGL() throws IOException {
        List<AfnemersberichtAanDGL> captureList = new ArrayList<>();
        Receiver<AfnemersberichtAanDGL> afnemersberichtAanDGLReceiver = new Receiver<>(new AfnemersberichtAanDGL()) {
            @Override
            protected void processMessage(AfnemersberichtAanDGL message, MessageHeaders headers) {
                captureList.add(message);
            }
        };

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

        assertThat(captureList.size(), is(1));
        AfnemersberichtAanDGL afnemersberichtAanDGL = captureList.get(0);
        assertThat(afnemersberichtAanDGL.getBerichtHeader().getOntvangerId(), is("55555555555555555555"));
        assertThat(afnemersberichtAanDGL.getBerichtHeader().getVerstrekkerId(), is("77777777777777777777"));
        assertThat(afnemersberichtAanDGL.getBerichtHeader().getDatumtijdstempelVerstrekker(), is(parseTime("2020-08-16T11:12:42.566+02:00")));
        assertThat(afnemersberichtAanDGL.getBerichtHeader().getKenmerkVerstrekker(), is("kenmerk.verstrekker.1"));
        assertThat(afnemersberichtAanDGL.getBerichtHeader().getBerichtversie(), is("1.0"));
        assertThat(afnemersberichtAanDGL.getStuurgegevens().getVersieBerichttype(), is("3.10"));
        assertThat(afnemersberichtAanDGL.getStuurgegevens().getBerichtsoort().getNaam(), is("Ap01"));
        assertThat(afnemersberichtAanDGL.getStuurgegevens().getBerichtsoort().getVersie(), is("1.0"));

        assertThat(afnemersberichtAanDGL.getInhoud().getAv01(), nullValue());
        assertThat(afnemersberichtAanDGL.getInhoud().getAp01(), notNullValue());
        Ap01 ap01 = afnemersberichtAanDGL.getInhoud().getAp01();
        assertThat(ap01.getHerhaling(), is(0));
        assertThat(ap01.getRandomKey(), is("00000000"));
        assertThat(ap01.getCategorie().size(), is(1));
        assertThat(ap01.getCategorie().get(0).getNummer(), is("01"));
        assertThat(ap01.getCategorie().get(0).getElement().size(), is(1));
        assertThat(ap01.getCategorie().get(0).getElement().get(0).getNummer(), is("0120"));
        assertThat(ap01.getCategorie().get(0).getElement().get(0).getValue(), is("PPPPPPPPP"));
    }