public class DefaultPahoMessageConverter extends java.lang.Object implements MqttMessageConverter, org.springframework.beans.factory.BeanFactoryAware
| Constructor and Description |
|---|
DefaultPahoMessageConverter()
Construct a converter with default options (qos=0, retain=false, charset=UTF-8).
|
DefaultPahoMessageConverter(int defaultQos,
boolean defaultRetained)
Construct a converter to create outbound messages with the supplied default qos and
retain settings and a UTF-8 charset for converting outbound String payloads to
byte[] and inbound byte[] to String (unless
payloadAdBytes is true). |
DefaultPahoMessageConverter(int defaultQos,
boolean defaultRetained,
java.lang.String charset)
Construct a converter to create outbound messages with the supplied default qos and
retain settings and the supplied charset.
|
DefaultPahoMessageConverter(int defaultQos,
MessageProcessor<java.lang.Integer> qosProcessor,
boolean defaultRetained,
MessageProcessor<java.lang.Boolean> retainedProcessor)
Construct a converter to create outbound messages with the supplied default qos and
retained message processors and a UTF-8 charset for converting outbound String payloads to
byte[] and inbound byte[] to String (unless
payloadAdBytes is true). |
DefaultPahoMessageConverter(int defaultQos,
MessageProcessor<java.lang.Integer> qosProcessor,
boolean defaultRetained,
MessageProcessor<java.lang.Boolean> retainedProcessor,
java.lang.String charset)
Construct a converter to create outbound messages with the supplied default qos and
retain settings and the supplied charset.
|
DefaultPahoMessageConverter(java.lang.String charset)
Construct a converter with default options (qos=0, retain=false) and
the supplied charset.
|
| Modifier and Type | Method and Description |
|---|---|
org.eclipse.paho.client.mqttv3.MqttMessage |
fromMessage(org.springframework.messaging.Message<?> message,
java.lang.Class<?> targetClass) |
protected org.springframework.beans.factory.BeanFactory |
getBeanFactory() |
protected MessageBuilderFactory |
getMessageBuilderFactory() |
boolean |
isPayloadAsBytes() |
protected byte[] |
messageToMqttBytes(org.springframework.messaging.Message<?> message)
Subclasses can override this method to convert the payload to a byte[].
|
protected java.lang.Object |
mqttBytesToPayload(org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
Subclasses can override this method to convert the byte[] to a payload.
|
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setBytesMessageMapper(BytesMessageMapper bytesMessageMapper)
Set a
BytesMessageMapper to use when mapping byte[]. |
void |
setPayloadAsBytes(boolean payloadAsBytes)
True if the converter should not convert the message payload to a String.
|
org.springframework.messaging.Message<?> |
toMessage(java.lang.Object mqttMessage,
org.springframework.messaging.MessageHeaders headers) |
org.springframework.messaging.Message<?> |
toMessage(java.lang.String topic,
org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
Convert to a Message.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdefaultQosProcessor, defaultRetainedProcessorpublic DefaultPahoMessageConverter()
public DefaultPahoMessageConverter(int defaultQos,
boolean defaultRetained)
byte[] and inbound byte[] to String (unless
payloadAdBytes is true).defaultQos - the default qos.defaultRetained - the default retained.public DefaultPahoMessageConverter(java.lang.String charset)
charset - the charset used to convert outbound String paylaods to byte[] and inbound
byte[] to String (unless payloadAdBytes is true).public DefaultPahoMessageConverter(int defaultQos,
boolean defaultRetained,
java.lang.String charset)
defaultQos - the default qos.defaultRetained - the default retained.charset - the charset used to convert outbound String paylaods to
byte[] and inbound byte[] to String (unless
payloadAdBytes is true).public DefaultPahoMessageConverter(int defaultQos,
MessageProcessor<java.lang.Integer> qosProcessor,
boolean defaultRetained,
MessageProcessor<java.lang.Boolean> retainedProcessor)
byte[] and inbound byte[] to String (unless
payloadAdBytes is true).defaultQos - the default qos.qosProcessor - a message processor to determine the qos.defaultRetained - the default retained.retainedProcessor - a message processor to determine the retained flag.public DefaultPahoMessageConverter(int defaultQos,
MessageProcessor<java.lang.Integer> qosProcessor,
boolean defaultRetained,
MessageProcessor<java.lang.Boolean> retainedProcessor,
java.lang.String charset)
defaultQos - the default qos.qosProcessor - a message processor to determine the qos.defaultRetained - the default retained.retainedProcessor - a message processor to determine the retained flag.charset - the charset used to convert outbound String paylaods to
byte[] and inbound byte[] to String (unless
payloadAdBytes is true).public final void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAwareprotected org.springframework.beans.factory.BeanFactory getBeanFactory()
protected MessageBuilderFactory getMessageBuilderFactory()
public void setPayloadAsBytes(boolean payloadAsBytes)
BytesMessageMapper is provided.payloadAsBytes - The payloadAsBytes to set.setBytesMessageMapper(BytesMessageMapper)public boolean isPayloadAsBytes()
public void setBytesMessageMapper(BytesMessageMapper bytesMessageMapper)
BytesMessageMapper to use when mapping byte[].
setPayloadAsBytes(boolean) is ignored when a BytesMessageMapper
is provided.bytesMessageMapper - the mapper.setPayloadAsBytes(boolean)public org.springframework.messaging.Message<?> toMessage(java.lang.Object mqttMessage,
org.springframework.messaging.MessageHeaders headers)
toMessage in interface org.springframework.messaging.converter.MessageConverterpublic org.springframework.messaging.Message<?> toMessage(java.lang.String topic,
org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
MqttMessageConvertertoMessage in interface MqttMessageConvertertopic - The topic.mqttMessage - The MQTT message.public org.eclipse.paho.client.mqttv3.MqttMessage fromMessage(org.springframework.messaging.Message<?> message,
java.lang.Class<?> targetClass)
fromMessage in interface org.springframework.messaging.converter.MessageConverterprotected java.lang.Object mqttBytesToPayload(org.eclipse.paho.client.mqttv3.MqttMessage mqttMessage)
throws java.lang.Exception
mqttMessage - The inbound message.java.lang.Exception - Any.protected byte[] messageToMqttBytes(org.springframework.messaging.Message<?> message)
BytesMessageMapper is provided, conversion to byte[]
is delegated to it, so any payload that it can handle is supported.message - The outbound Message.