use of org.springframework.integration.mqtt.support.DefaultPahoMessageConverter in project spring-integration by spring-projects.
the class AbstractMqttMessageHandler method onInit.
@Override
protected void onInit() throws Exception {
super.onInit();
if (this.topicProcessor instanceof BeanFactoryAware && getBeanFactory() != null) {
((BeanFactoryAware) this.topicProcessor).setBeanFactory(getBeanFactory());
}
if (this.qosProcessor instanceof BeanFactoryAware && getBeanFactory() != null) {
((BeanFactoryAware) this.qosProcessor).setBeanFactory(getBeanFactory());
}
if (this.retainedProcessor instanceof BeanFactoryAware && getBeanFactory() != null) {
((BeanFactoryAware) this.retainedProcessor).setBeanFactory(getBeanFactory());
}
if (this.converter == null) {
DefaultPahoMessageConverter defaultConverter = new DefaultPahoMessageConverter(this.defaultQos, this.qosProcessor, this.defaultRetained, this.retainedProcessor);
if (getBeanFactory() != null) {
defaultConverter.setBeanFactory(getBeanFactory());
}
this.converter = defaultConverter;
}
}
use of org.springframework.integration.mqtt.support.DefaultPahoMessageConverter in project spring-integration by spring-projects.
the class AbstractMqttMessageDrivenChannelAdapter method onInit.
@Override
protected void onInit() {
super.onInit();
if (this.converter == null) {
DefaultPahoMessageConverter pahoMessageConverter = new DefaultPahoMessageConverter();
pahoMessageConverter.setBeanFactory(getBeanFactory());
this.converter = pahoMessageConverter;
}
}
use of org.springframework.integration.mqtt.support.DefaultPahoMessageConverter in project sinsim by WilsonHu.
the class MqttService method inbound.
@Bean
public MessageProducer inbound() {
String addressFormat = "tcp://%s:1883";
MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter(String.format(addressFormat, brokerHost), "server", "topic/client/send/#");
adapter.setCompletionTimeout(5000);
adapter.setConverter(new DefaultPahoMessageConverter());
adapter.setQos(1);
adapter.setOutputChannel(mqttInputChannel());
return adapter;
}
use of org.springframework.integration.mqtt.support.DefaultPahoMessageConverter in project spring-integration-samples by spring-projects.
the class Application method mqttInbound.
@Bean
public MessageProducerSupport mqttInbound() {
MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter("siSampleConsumer", mqttClientFactory(), "siSampleTopic");
adapter.setCompletionTimeout(5000);
adapter.setConverter(new DefaultPahoMessageConverter());
adapter.setQos(1);
return adapter;
}
use of org.springframework.integration.mqtt.support.DefaultPahoMessageConverter in project spring-integration by spring-projects.
the class MqttOutboundChannelAdapterParserTests method testWithDefaultConverter.
@Test
public void testWithDefaultConverter() {
GenericMessage<String> message = new GenericMessage<>("foo");
assertEquals("tcp://localhost:1883", TestUtils.getPropertyValue(withDefaultConverterHandler, "url"));
assertEquals("foo", TestUtils.getPropertyValue(withDefaultConverterHandler, "clientId"));
assertEquals("bar", TestUtils.getPropertyValue(withDefaultConverterHandler, "defaultTopic"));
assertEquals(1, TestUtils.getPropertyValue(withDefaultConverterHandler, "defaultQos"));
assertEquals(Boolean.TRUE, TestUtils.getPropertyValue(withDefaultConverterHandler, "defaultRetained", Boolean.class));
DefaultPahoMessageConverter defaultConverter = TestUtils.getPropertyValue(withDefaultConverterHandler, "converter", DefaultPahoMessageConverter.class);
assertEquals(1, defaultConverter.fromMessage(message, null).getQos());
assertTrue(defaultConverter.fromMessage(message, null).isRetained());
assertSame(clientFactory, TestUtils.getPropertyValue(withDefaultConverterHandler, "clientFactory"));
assertTrue(TestUtils.getPropertyValue(withDefaultConverterHandler, "async", Boolean.class));
assertTrue(TestUtils.getPropertyValue(withDefaultConverterHandler, "asyncEvents", Boolean.class));
}
Aggregations