Skip to content

Commit ac9afad

Browse files
committed
lazy MessageBroker connection
1 parent 650ccd1 commit ac9afad

File tree

3 files changed

+103
-2
lines changed

3 files changed

+103
-2
lines changed

farolapi-2018-07-25.0.log

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
20180725-15:34:08.714 [API] [main] INFO  e.u.o.f.Application - Starting Application on usuariop112.fi.upm.es with PID 29700 (/Users/cbadenes/Projects/farolapi/target/classes started by cbadenes in /Users/cbadenes/Projects/farolapi)
2+
20180725-15:34:08.720 [API] [main] INFO  e.u.o.f.Application - No active profile set, falling back to default profiles: default
3+
20180725-15:34:11.247 [API] [main] INFO  e.u.o.f.c.CellController - Service: /cells available
4+
20180725-15:34:11.256 [API] [main] INFO  e.u.o.f.c.LamppostController - Service: /lampposts available
5+
20180725-15:34:11.858 [API] [main] ERROR o.a.c.h.Http11NioProtocol - Failed to start end point associated with ProtocolHandler ["http-nio-80"]
6+
java.net.SocketException: Permission denied
7+
at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_73]
8+
at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_73]
9+
at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_73]
10+
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_73]
11+
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_73]
12+
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:340) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
13+
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:773) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
14+
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:473) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
15+
at org.apache.catalina.connector.Connector.startInternal(Connector.java:986) [tomcat-embed-core-8.0.33.jar:8.0.33]
16+
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [tomcat-embed-core-8.0.33.jar:8.0.33]
17+
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:239) [tomcat-embed-core-8.0.33.jar:8.0.33]
18+
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:194) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
19+
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:151) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
20+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
21+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
22+
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) [spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
23+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
24+
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
25+
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
26+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
27+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
28+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
29+
at es.upm.oeg.farolapi.Application.main(Application.java:47) [classes/:na]
30+
20180725-15:34:11.859 [API] [main] ERROR o.a.c.c.StandardService - Failed to start connector [Connector[HTTP/1.1-80]]
31+
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-80]]
32+
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
33+
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:239) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
34+
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:194) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
35+
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:151) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
36+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
37+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
38+
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) [spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
39+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
40+
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
41+
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
42+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
43+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
44+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
45+
at es.upm.oeg.farolapi.Application.main(Application.java:47) [classes/:na]
46+
Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed
47+
at org.apache.catalina.connector.Connector.startInternal(Connector.java:993) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
48+
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
49+
... 13 common frames omitted
50+
Caused by: java.net.SocketException: Permission denied
51+
at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_73]
52+
at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_73]
53+
at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_73]
54+
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_73]
55+
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_73]
56+
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:340) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
57+
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:773) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
58+
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:473) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
59+
at org.apache.catalina.connector.Connector.startInternal(Connector.java:986) ~[tomcat-embed-core-8.0.33.jar:8.0.33]
60+
... 14 common frames omitted
61+
20180725-15:34:11.879 [API] [main] ERROR o.s.b.SpringApplication - Application startup failed
62+
org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat servlet container
63+
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:165) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
64+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
65+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
66+
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
67+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
68+
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
69+
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
70+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
71+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
72+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
73+
at es.upm.oeg.farolapi.Application.main(Application.java:47) [classes/:na]
74+
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
75+
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:159) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
76+
... 10 common frames omitted
77+
20180725-15:34:11.881 [API] [main] ERROR e.u.o.f.Application - Error executing test
78+
org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat servlet container
79+
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:165) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
80+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
81+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
82+
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.2.6.RELEASE.jar:4.2.6.RELEASE]
83+
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
84+
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
85+
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
86+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
87+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
88+
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
89+
at es.upm.oeg.farolapi.Application.main(Application.java:47) ~[classes/:na]
90+
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
91+
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:159) ~[spring-boot-1.3.5.RELEASE.jar:1.3.5.RELEASE]
92+
... 10 common frames omitted

src/main/java/es/upm/oeg/farolapi/bus/BusManager.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public class BusManager {
4646

4747
private BusClient client;
4848

49-
@PostConstruct
49+
private boolean initialized = false;
50+
5051
public void init() {
5152
try {
5253
String uri = new StringBuilder().
@@ -61,6 +62,8 @@ public void init() {
6162
LOG.info("RabbitMQ Event-Bus initialized successfully");
6263
} catch (IOException | TimeoutException | NoSuchAlgorithmException | KeyManagementException | URISyntaxException e) {
6364
throw new RuntimeException(e);
65+
} finally {
66+
initialized = true;
6467
}
6568
}
6669

@@ -76,6 +79,9 @@ public void destroy() {
7679
}
7780

7881
public void subscribe(BusSubscriber subscriber, String queue, String key) {
82+
83+
if (!initialized) init();
84+
7985
try {
8086
LOG.debug("subscribing: " + subscriber + " to: " + queue + "/" + key);
8187
this.client.consume(exchange, queue, key, subscriber);
@@ -85,6 +91,7 @@ public void subscribe(BusSubscriber subscriber, String queue, String key) {
8591
}
8692

8793
public void unsubscribe(BusSubscriber subscriber) {
94+
if (!initialized) init();
8895
try {
8996
LOG.debug("unsubscribing: " + subscriber);
9097
this.client.clean(subscriber);
@@ -96,6 +103,7 @@ public void unsubscribe(BusSubscriber subscriber) {
96103
}
97104

98105
public boolean post(String msg, String key) {
106+
if (!initialized) init();
99107
try {
100108
LOG.debug("post event: " + msg + " to: " + key);
101109
this.client.publish(channel, exchange, key, msg.getBytes());

src/main/resources/application.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ farolapp.achannel.key=annotations.raw
1111
farolapp.achannel.exchange=farolapp
1212

1313
## Virtuoso Remote
14-
farolapp.virtuoso.endpoint=http://138.4.249.224/virtuoso/sparql
14+
#farolapp.virtuoso.endpoint=http://138.4.249.224/virtuoso/sparql
15+
farolapp.virtuoso.endpoint=http://farolas.linkeddata.es/sparql
1516

1617
## Consensus API Endpoint
1718
farolapp.prefix=tmp

0 commit comments

Comments
 (0)