Skip to content

Commit

Permalink
[sre] Send events locally event if an error occured when sending over…
Browse files Browse the repository at this point in the history
… the network.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Nov 8, 2018
1 parent d3eaaec commit 9d3adb6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Expand Up @@ -42,6 +42,7 @@ public class Messages extends NLS {
public static String ZeroMQNetworkService_14;
public static String ZeroMQNetworkService_15;
public static String ZeroMQNetworkService_16;
public static String ZeroMQNetworkService_17;
public static String ZeroMQNetworkService_2;
public static String ZeroMQNetworkService_20;
public static String ZeroMQNetworkService_3;
Expand Down
Expand Up @@ -279,10 +279,17 @@ public synchronized void publish(Scope<?> scope, Event data) throws Exception {
if (this.validatedURI == null) {
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_0, data.getSource().getSpaceID(), scope, data));
} else if (!this.receptionSocketsPerRemoteKernel.isEmpty()) {
final SpaceID spaceID = data.getSource().getSpaceID();
final EventEnvelope env = this.serializer.serialize(new EventDispatch(spaceID, data, scope));
send(env);
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_1, spaceID, data));
// Send asynchronously
this.executorService.execute(() -> {
try {
final SpaceID spaceID = data.getSource().getSpaceID();
final EventEnvelope env = this.serializer.serialize(new EventDispatch(spaceID, data, scope));
send(env);
this.logger.getKernelLogger().fine(MessageFormat.format(Messages.ZeroMQNetworkService_1, spaceID, data));
} catch (Exception exception) {
this.logger.getKernelLogger().severe(MessageFormat.format(Messages.ZeroMQNetworkService_17, data, scope, exception));
}
});
}
}

Expand Down
Expand Up @@ -7,6 +7,7 @@ ZeroMQNetworkService_13=Error in poller for {0}
ZeroMQNetworkService_14=An unexpected error occured in the ZeroMQ layer: {0}
ZeroMQNetworkService_15=ZeroMQ PUB socket is binded to {0}
ZeroMQNetworkService_16=ZeroMQ shutdown
ZeroMQNetworkService_17=Cannot emit the event ''{0}'' with the scope ''{1}'' to remote hosts: {2}.
ZeroMQNetworkService_2=Connecting peer {0} => {1}
ZeroMQNetworkService_20=The space {0} is not a subclass of DistributedSpace.
ZeroMQNetworkService_3=Connected to peer {0}
Expand Down
Expand Up @@ -64,7 +64,7 @@ public void runSender() throws Exception {
}

@SarlSpecification(SARLVersion.SPECIFICATION_RELEASE_VERSION_STRING)
@SarlElementType(SarlPackage.SARL_AGENT)
@SarlElementType(SarlPackage.SARL_EVENT)
static class TestEvent extends Event {
}

Expand Down

0 comments on commit 9d3adb6

Please sign in to comment.