-
Notifications
You must be signed in to change notification settings - Fork 22
Factory
业余布道师 edited this page May 31, 2018
·
7 revisions
Factory is for multiple Producer
or Consumer
, use the producerKey
or consumerKey
to get them. The producerKey
default value is TopicName, the consumerKey
is natural key of your define, such as messageType
from the MessageBean. Factory config with Spring like this.
<!-- Message Producer Factory -->
<bean id="messageProducerFactory" class="org.darkphoenixs.mq.common.MessageProducerFactory"
init-method="init" destroy-method="destroy">
<property name="producers">
<array>
<ref bean="messageProducer" />
</array>
</property>
</bean>
<!-- Message Consumer Factory -->
<bean id="messageConsumerFactory" class="org.darkphoenixs.mq.common.MessageConsumerFactory"
init-method="init" destroy-method="destroy">
<property name="consumers">
<array>
<ref bean="messageConsumer" />
</array>
</property>
</bean>
Consumer Factory need inject the MessageFactoryConsumerListener
, the listener implement MessageListener
interface the same as MessageConsumerListener
, config like this.
<!-- Message Factory Consumer Listener -->
<bean id="factoryConsumerListener" class="org.darkphoenixs.xxx.listener.MessageFactoryConsumerListener">
<property name="consumerFactory" ref="messageConsumerFactory" />
<property name="consumerKeyField" value="Your consumerKey field name in the messagebean" />
</bean>