0
votes

I am modifying in a Standalone application (using Spring) and finally I have found that in some Step I need to use Spring Integration in order to process some messages and send them to Mqtt broker : I have used a int-mqtt:outbound-channel-adapter. For that I have declared :

<int:channel id="messages" />
<bean id="clientFactory" class="org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory">
     <property name="userName" value="login"/>
     <property name="password" value="${mqtt.password}"/>
</bean>


 <int-mqtt:outbound-channel-adapter id="mqttPublishToMDD"
                                   client-id="MM" 
                                   url="tcp://127.0.0.1:12345"
                                   client-factory="clientFactory" 
                                   default-qos="0"
                                   auto-startup="true"
                                   default-retained="true"
                                   channel="messages"
                                   default-topic="mdd/nr" />

The Idea is that when I got a message (event), I process that message, and finally I autowire the channel and then I send directly the message to the channel :

    @Qualifier(value="messages")
    @Autowired(required=false)
    QueueChannel  messageQueue;            

So my first Question, is should I use it like that or I need to specify some Service-Activator or Gateway.. ??

My sencond Question, is that I have manually added all the Spring-Integration lib, but when I import the org.springframework.integration.channel.QueueChannel, this is not found in the lib (which is empty). Is this normal ?

1

1 Answers

0
votes
  1. Yes, you can use MessageChannel injection, if your application is so trivial.
  2. org.springframework.integration.channel.QueueChannel is a part of spring-integration-core jar. Be sure that you have it in your CLASSPATH