Skip to content

Commit 282ddfc

Browse files
authored
Merge pull request #176 from cinovo/eventsenderbugfix
Eventsenderbugfix
2 parents db85e32 + 23ac53b commit 282ddfc

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
* Nimbus JOSE+JWT 10.3
1717
* Swagger 2.2.40
1818
* Velocity Engine 2.4.1
19-
* Fixing DaemonExceptionMapper
20-
* Fixing problem with retry messages in Interconnect
21-
* Better error handling in CloudconductorPropertyProvider
19+
* Bugfix: Fixing DaemonExceptionMapper
20+
* Bugfix: Serialize EventSender messages to json
21+
* Bugfix: Fixes problem with events time to live set to 10 seconds
22+
* Bugfix: Fixing problem with retry messages in Interconnect
23+
* Bugfix: Better error handling in CloudconductorPropertyProvider
2224
* Fixed vulnerabilities: CVE-2024-13009(Jetty), CVE-2025-23184(Apache CXF), CVE-2024-57699 (Json-smart),CVE-2025-27533 (ActiveMQ)
2325

2426
# 1.37

interconnect/core/src/main/java/de/taimos/dvalin/interconnect/core/AToTopicSender.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@ protected AToTopicSender(IJmsConnector jmsConnector) {
5454
* @throws DaemonError is throw if there is a problem with sending the event
5555
*/
5656
public void send(Serializable object, String topicName) throws DaemonError, TimeoutException {
57+
this.send(object, topicName, IJmsConnector.REQUEST_TIMEOUT);
58+
}
59+
60+
public void send(Serializable object, String topicName, Long timeout) throws DaemonError, TimeoutException {
5761
if (topicName == null) {
5862
this.logger.error("Invalid topic name: a non-null name is required");
5963
throw new IllegalArgumentException("Invalid topic name: a non-null name is required");
6064
}
6165
JmsContextBuilder context = new JmsContextBuilder().withTarget(JmsTarget.TOPIC)
62-
.withDestinationName(topicName).withBody(object);
66+
.withDestinationName(topicName).withTimeToLive(timeout, null).withBody(object);
6367

6468
try {
6569
this.jmsConnector.send(context.build());

interconnect/core/src/main/java/de/taimos/dvalin/interconnect/core/EventSender.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@
2020
* #L%
2121
*/
2222

23+
import de.taimos.dvalin.interconnect.core.daemon.util.DaemonExceptionMapper;
24+
import de.taimos.dvalin.interconnect.core.exceptions.InfrastructureException;
25+
import de.taimos.dvalin.interconnect.core.exceptions.SerializationException;
26+
import de.taimos.dvalin.interconnect.model.InterconnectMapper;
2327
import de.taimos.dvalin.interconnect.model.event.EventDomain;
2428
import de.taimos.dvalin.interconnect.model.event.IEvent;
2529
import de.taimos.dvalin.interconnect.model.service.DaemonError;
2630
import de.taimos.dvalin.jms.IJmsConnector;
2731
import de.taimos.dvalin.interconnect.core.exceptions.TimeoutException;
32+
import de.taimos.dvalin.jms.model.JmsContext.JmsContextBuilder;
33+
import de.taimos.dvalin.jms.model.JmsTarget;
2834
import org.springframework.core.annotation.AnnotationUtils;
2935

36+
import java.io.IOException;
3037
import java.io.Serializable;
3138

3239
/**
@@ -54,10 +61,14 @@ public EventSender(IJmsConnector jmsConnector) {
5461

5562
@Override
5663
public void send(Serializable object, String topicName) throws DaemonError, TimeoutException {
57-
if (object instanceof IEvent) {
58-
this.send((IEvent) object);
59-
} else {
60-
super.send(object, topicName);
64+
try {
65+
if (object instanceof IEvent) {
66+
super.send(InterconnectMapper.toJson((IEvent) object), topicName, 0L);
67+
} else {
68+
super.send(object, topicName);
69+
}
70+
} catch (IOException e) {
71+
throw new RuntimeException(e);
6172
}
6273
}
6374

@@ -67,15 +78,19 @@ public void send(Serializable object, String topicName) throws DaemonError, Time
6778
* @throws TimeoutException in case of communication timeout
6879
*/
6980
public void send(IEvent object) throws DaemonError, TimeoutException {
81+
this.send(object, getTopicName(object));
82+
}
83+
84+
private String getTopicName(IEvent object){
7085
EventDomain domainAnnotation = AnnotationUtils.findAnnotation(object.getClass(), EventDomain.class);
7186
if (domainAnnotation == null) {
7287
this.logger.error("The event {} has no domain annotation", object.getClass().getSimpleName());
73-
return;
88+
return null;
7489
}
7590
if (domainAnnotation.value().isEmpty()) {
7691
this.logger.error("The domainname for the event {} is empty", object.getClass().getSimpleName());
77-
return;
92+
return null;
7893
}
79-
super.send(object, this.virtualTopicPrefix + "." + domainAnnotation.value());
94+
return this.virtualTopicPrefix + "." + domainAnnotation.value();
8095
}
8196
}

0 commit comments

Comments
 (0)