3

現在のアプリでは、Spring AMQP を次のように使用しています。

<rabbit:connection-factory  id="cachingConnectionFactory" 
                            username="${rabbitmq.connection.username}"
                            password="${rabbitmq.connection.password}"
                            host="${rabbitmq.connection.host}" 
                            port="${rabbitmq.connection.port}"
                            executor="rabbitmqPoolTaskExecutor"
                            requested-heartbeat="${rabbitmq.connection.requested-heartbeat}"
                            channel-cache-size="${rabbitmq.connection.channel-cache-size}"
                            virtual-host="${rabbitmq.connection.virtual-host}" />

<rabbit:admin   id="adminRabbit" 
                connection-factory="cachingConnectionFactory"
                auto-startup="true" />

<rabbit:template    id="rabbitTemplate"
                    connection-factory="cachingConnectionFactory"
                    exchange="v1.general.exchange"
                    message-converter="jsonMessageConverter" 
                    encoding="${rabbitmq.template.encoding}"
                    channel-transacted="${rabbitmq.template.channel-transacted}" />

<rabbit:queue id="v1.queue.1" name="v1.queue.1"  />
<rabbit:queue id="v1.queue.2" name="v1.queue.2" />
<rabbit:queue id="v1.queue.3" name="v1.queue.3" />

<fanout-exchange name="v1.general.exchange" xmlns="http://www.springframework.org/schema/rabbit" >
    <bindings>
        <binding queue="v1.queue.1" />
        <binding queue="v1.queue.2" />
        <binding queue="v1.queue.3" />
    </bindings>
</fanout-exchange>

<listener-container xmlns="http://www.springframework.org/schema/rabbit"
                    connection-factory="cachingConnectionFactory" 
                    message-converter="jsonMessageConverter" 
                    task-executor="rabbitmqPoolTaskExecutor"
                    auto-startup="${rabbitmq.listener-container.auto-startup}"
                    concurrency="${rabbitmq.listener-container.concurrency}"
                    channel-transacted="${rabbitmq.listener-container.channel-transacted}"
                    prefetch="${rabbitmq.listener-container.prefetch}"
                    transaction-size="${rabbitmq.listener-container.transaction-size}" >

    <listener id="v1.listener.queue.1" ref="listener1" method="handleMessage" queues="v1.queue.1" />
    <listener id="v1.listener.queue.2" ref="listener2" method="handleMessage" queues="v1.queue.2" />
    <listener id="v1.listener.queue.3" ref="listener3" method="handleMessage" queues="v1.queue.3" />

</listener-container>

<bean id="amqpServerConnection" class="com.sub1.sub2.RabbitGatewayConnectionImpl">
    <property name="rabbitTemplate" ref="rabbitTemplate" />
</bean>

新しいSpring 4ベースのアプリでwebsocketを構成しているとき、交換、キューなどを宣言する方法/場所がわかりません...

registry.enableStompBrokerRelay("/example1/", "/example2/")
            .setApplicationLogin("guest")
            .setApplicationPasscode("guest")
            .setAutoStartup(true)
            .setRelayHost("localhost")
            .setRelayPort(5672)
            .setSystemHeartbeatReceiveInterval(10000)
            .setSystemHeartbeatSendInterval(10000);

このようなものはまだ AMPQ で実装する必要がありますか?

4

1 に答える 1

9

基本的に、クライアントは WebSocket セッションを確立し、メッセージングに AMQP ではなく STOMP (STOMP over WebSocket) を使用します。STOMP では、すべてが宛先ヘッダーによって駆動され、その意味を定義するのはメッセージ ブローカー次第です。たとえば、RabbitMQ STOMP プラグインページをチェックして、Rabbit が STOMP 宛先をキューと交換にどのようにマッピングするかを確認してください。

したがって、RabbitMQ を、キューや交換などを既に管理しているメッセージ ブローカーと考えるとします。Web アプリケーション側では、メッセージング プロトコルは STOMP であり、クライアントは@MessageMappingコントローラー メソッドにマップされた STOMP 宛先または RabbitMQ によってサポートされる宛先にメッセージを送信できます。さらに、コントローラー、または が注入されたその他のコンポーネントSimpMessagingTemplateは、ブローカー (Rabbit) にメッセージを送信できます。メッセージは、接続された Web クライアントにブロードキャストされます。

お役に立てれば。

于 2014-01-23T21:49:40.490 に答える