rabbitmq-consistent-hash-exchange with java-client / spring-rabbit

rabbitmq-consistent-hash-exchange with java-client / spring-rabbit

我想使用来自 java 客户端的 rabbitmq-consistent-hash-exchange 的功能,或者最好使用 spring 抽象 spring-amqp。不幸的是,我未能找到一个示例来解释 java 用法并引用要包含的 jar 依赖项,请指教。

不支持使用 Spring AMQP 提供(声明)插件交换,但您可以将消息发送到服务器上配置的任何交换类型。

只需将交换直接添加到 rabbitmq,然后像向任何交换一样向它发送消息。

请参阅 reference documentation 了解如何使用 Spring AMQP;它有样本等的链接

"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>