@Override public Object convertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint) { Object result = null; try { Object payload = message.getPayload(); if (payload instanceof byte[]) { try { result = this.mapper.readValue((byte[]) payload, targetClass); } catch (InvalidTypeIdException e) { return new UnknownRemoteApplicationEvent(new Object(), e.getTypeId(), (byte[]) payload); } } else if (payload instanceof String) { try { result = this.mapper.readValue((String) payload, targetClass); } catch (InvalidTypeIdException e) { return new UnknownRemoteApplicationEvent(new Object(), e.getTypeId(), ((String) payload).getBytes()); } // workaround for https://github.com/spring-cloud/spring-cloud-stream/issues/1564 } else if (payload instanceof RemoteApplicationEvent) { return payload; } } catch (Exception e) { this.logger.error(e.getMessage(), e); return null; } return result; }
@Override public Object convertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint) { Object result = null; try { Object payload = message.getPayload(); if (payload instanceof byte[]) { try { result = this.mapper.readValue((byte[]) payload, targetClass); } catch (InvalidTypeIdException e) { return new UnknownRemoteApplicationEvent(new Object(), e.getTypeId(), (byte[]) payload); } } else if (payload instanceof String) { try { result = this.mapper.readValue((String) payload, targetClass); } catch (InvalidTypeIdException e) { return new UnknownRemoteApplicationEvent(new Object(), e.getTypeId(), ((String) payload).getBytes()); } // workaround for https://github.com/spring-cloud/spring-cloud-stream/issues/1564 } else if (payload instanceof RemoteApplicationEvent) { return payload; } } catch (Exception e) { this.logger.error(e.getMessage(), e); return null; } return result; }