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.worldbank.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.model.external.worldbank.countries.impl.CountryElement;
33 import com.hack23.cia.service.component.agent.impl.worldbank.workers.data.WorldbankUpdateService;
34
35
36
37
38 @Service("worldbankCountryElementWorkConsumerImpl")
39 @Transactional
40 final class WorldbankCountryElementWorkConsumerImpl implements
41 MessageListener {
42
43
44 private static final Logger LOGGER = LoggerFactory
45 .getLogger(WorldbankCountryElementWorkConsumerImpl.class);
46
47
48 @Autowired
49 private WorldbankUpdateService updateService;
50
51
52
53
54 public WorldbankCountryElementWorkConsumerImpl() {
55 super();
56 }
57
58 @Override
59 public void onMessage(final Message message) {
60 try {
61 updateService.updateCountryElement((CountryElement)((ObjectMessage) message).getObject());
62 } catch (final RuntimeException | JMSException e) {
63 LOGGER.warn("Error loading worldbank country:" , e);
64 }
65 }
66 }