class SubscriptionService implements MqttClientEventHandler {

    @Override
    public void onReceive(final MqttClientAdapter mqttClientAdapter, final byte[] payloadAsBytes) {
        final String payload = new String(payloadAsBytes);
        final MessageMetadata messageMetadata = mqttClientAdapter.getMessageMetadata();
        LOG.info(String.format("Client for device:%s received payload:%s", messageMetadata.getDeviceIdentification(),
                payload));
        final ResponseMessage responseMessage = new ProtocolResponseMessage.Builder()
                .deviceMessageMetadata(new DeviceMessageMetadata(messageMetadata))
                .domain(messageMetadata.getDomain())
                .domainVersion(messageMetadata.getDomainVersion())
                .dataObject(payload)
                .result(ResponseMessageResultType.OK)
                .build();
        this.outboundOsgpCoreResponseMessageSender.send(responseMessage);
    }

    public  SubscriptionService(final MqttDeviceRepository mqttDeviceRepository,
            final MqttClientAdapterFactory mqttClientAdapterFactory,
            final OutboundOsgpCoreResponseMessageSender outboundOsgpCoreResponseMessageSender,
            @Value("#{new Integer('${mqtt.broker.defaultPort}')}") final int defaultPort,
            @Value("${mqtt.broker.defaultTopics}") final String defaultTopics,
            @Value("${mqtt.broker.defaultQos}") final String defaultQos);

}