1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.service.component.agent.impl.riksdagen.workers;
20
21 import javax.jms.JMSException;
22 import javax.jms.Message;
23 import javax.jms.MessageListener;
24 import javax.jms.ObjectMessage;
25
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Service;
30 import org.springframework.transaction.annotation.Transactional;
31
32 import com.hack23.cia.service.component.agent.impl.riksdagen.workers.data.RiksdagenUpdateService;
33 import com.hack23.cia.service.external.riksdagen.api.DataFailureException;
34 import com.hack23.cia.service.external.riksdagen.api.RiksdagenDocumentApi;
35
36
37
38
39 @Service("riksdagenDocumentStatusContainerWorkConsumerImpl")
40 @Transactional
41 final class RiksdagenDocumentStatusContainerWorkConsumerImpl implements
42 MessageListener {
43
44
45 private static final Logger LOGGER = LoggerFactory
46 .getLogger(RiksdagenDocumentStatusContainerWorkConsumerImpl.class);
47
48
49 @Autowired
50 private RiksdagenUpdateService updateService;
51
52
53 @Autowired
54 private RiksdagenDocumentApi riksdagenApi;
55
56
57
58
59
60 public RiksdagenDocumentStatusContainerWorkConsumerImpl() {
61 super();
62 }
63
64 @Override
65 public void onMessage(final Message message) {
66 try {
67 updateService.updateDocumentData(riksdagenApi
68 .getDocumentStatus((String) ((ObjectMessage) message).getObject()));
69 } catch (final DataFailureException | RuntimeException | JMSException e) {
70 LOGGER.warn("Error loading riksdagen documentstatus:" , e);
71 }
72 }
73 }