Hai*_*man 2 rabbitmq spring-rabbit
我想从 java 客户端使用rabbitmq-consistency-hash-exchange 的功能,或者最好使用 spring 抽象 spring-amqp。不幸的是,我未能找到一个解释 java 用法并引用要包含的 jar 依赖项的示例,请提出建议。
小智 5
“x-”交换没有特定的标签。使用 CustomExchange 来实现:
<bean id="requestHashExchangeTest" class="org.springframework.amqp.core.CustomExchange">
<constructor-arg name="name" value="test.hash.RequestExchange"/>
<constructor-arg name="type" value="x-consistent-hash"/>
<constructor-arg name="durable" value="true"/>
<constructor-arg name="autoDelete" value="false"/>
<property name="adminsThatShouldDeclare">
<list>
<ref bean="rabbitAdminConnectionFactory" />
</list>
</property>
</bean>
<bean name="binding" class="org.springframework.amqp.rabbit.config.BindingFactoryBean">
<property name="exchange" value="test.random.RequestExchange" />
<property name="destinationQueue" ref="request.queue" />
<property name="shouldDeclare" value="true" />
<property name="adminsThatShouldDeclare">
<list>
<ref bean="rabbitAdminConnectionFactory" />
</list>
</property>
<property name="routingKey" value="10" />
</bean>
Run Code Online (Sandbox Code Playgroud)