Skip to content

Commit

Permalink
propagate ditto headers with exception (e.g. containing the required …
Browse files Browse the repository at this point in the history
…replyTo header)

Signed-off-by: Dominik Guggemos <dominik.guggemos@bosch-si.com>
  • Loading branch information
dguggemos committed Apr 19, 2018
1 parent 2cc5b30 commit 8b8a0dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Expand Up @@ -194,7 +194,7 @@ private void handle(final ExternalMessage externalMessage) {
commandRouter.tell(adjustedSignal, getSelf());
});
} catch (final DittoRuntimeException e) {
handleDittoRuntimeException(e);
handleDittoRuntimeException(e, DittoHeaders.of(externalMessage.getHeaders()));
} catch (final Exception e) {
log.warning("Got <{}> when message was processed: <{}>", e.getClass().getSimpleName(), e.getMessage());
}
Expand All @@ -206,7 +206,14 @@ private void enhanceLogUtil(final WithDittoHeaders<?> signal) {
}

private void handleDittoRuntimeException(final DittoRuntimeException exception) {
final ThingErrorResponse errorResponse = ThingErrorResponse.of(exception);
handleDittoRuntimeException(exception, DittoHeaders.empty());
}

private void handleDittoRuntimeException(final DittoRuntimeException exception,
final DittoHeaders dittoHeaders) {
final DittoHeaders mergedHeaders =
DittoHeaders.newBuilder(exception.getDittoHeaders()).putHeaders(dittoHeaders).build();
final ThingErrorResponse errorResponse = ThingErrorResponse.of(exception, mergedHeaders);

enhanceLogUtil(exception);

Expand Down
Expand Up @@ -69,16 +69,13 @@ public class RabbitMQClientActorTest {
private final ConnectionStatus connectionStatus = ConnectionStatus.OPEN;

@Mock
@SuppressWarnings("FieldMayBeFinal")
private ConnectionFactory mockConnectionFactory = Mockito.mock(ConnectionFactory.class);
private final ConnectionFactory mockConnectionFactory = Mockito.mock(ConnectionFactory.class);
private final RabbitConnectionFactoryFactory
rabbitConnectionFactoryFactory = (con, exHandler) -> mockConnectionFactory;
@Mock
@SuppressWarnings("FieldMayBeFinal")
private com.rabbitmq.client.Connection mockConnection = Mockito.mock(com.rabbitmq.client.Connection.class);
private final com.rabbitmq.client.Connection mockConnection = Mockito.mock(com.rabbitmq.client.Connection.class);
@Mock
@SuppressWarnings("FieldMayBeFinal")
private Channel mockChannel = Mockito.mock(Channel.class);
private final Channel mockChannel = Mockito.mock(Channel.class);

@BeforeClass
public static void setUp() {
Expand Down

0 comments on commit 8b8a0dc

Please sign in to comment.