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 ;
2327import de .taimos .dvalin .interconnect .model .event .EventDomain ;
2428import de .taimos .dvalin .interconnect .model .event .IEvent ;
2529import de .taimos .dvalin .interconnect .model .service .DaemonError ;
2630import de .taimos .dvalin .jms .IJmsConnector ;
2731import de .taimos .dvalin .interconnect .core .exceptions .TimeoutException ;
32+ import de .taimos .dvalin .jms .model .JmsContext .JmsContextBuilder ;
33+ import de .taimos .dvalin .jms .model .JmsTarget ;
2834import org .springframework .core .annotation .AnnotationUtils ;
2935
36+ import java .io .IOException ;
3037import 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