サポート付きでテストSpring-AMQP
しSpring-Integration
ています。次の構成とテストを行いました。
<rabbit:connection-factory id="connectionFactory" />
<rabbit:queue name="durableQ"/>
<int:channel id="consumingChannel">
<int:queue capacity="2"/> <!-- Message get Acked as-soon-as filled in Q -->
</int:channel>
<int-amqp:inbound-channel-adapter
channel="consumingChannel"
queue-names="durableQ"
connection-factory="connectionFactory"
concurrent-consumers="1"
acknowledge-mode="AUTO"
/>
public static void main(String[] args) {
System.out.println("Starting consumer with integration..");
AbstractApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:META-INF/spring/integration/spring-integration-context-consumer.xml");
PollableChannel consumingChannel = context.getBean("consumingChannel",
PollableChannel.class);
int count = 0;
while (true) {
Message<?> msg = consumingChannel.receive(1000);
System.out.println((count++) + " \t -> " + msg);
try { //sleep to check number of messages in queue
Thread.sleep(50000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
この構成では、メッセージが に到着するとすぐにconsumingChannel
確認応答され、キューから削除されることが明らかでした。と checkのsleep
後に高い値を付けることで、これを検証しました。それ以上の制御はありません。receive
queue-size
今私が設定した場合、春の統合を介しacknowledge-mode=MANUAL
て手動で行うように見える方法はありません。ack
メッセージを処理する必要があり、処理後、メッセージがに保持さmanual-ack
れるまでそうします。ack
durableQ
MANUAL
でackを処理する方法はありますspring-amqp-integration
か? 消費者の を制御したいので、に渡すことは避けたいChannelAwareMessageListener
です。inbound-channel-adapter
receive
アップデート:
listener-container
ownをinbound-channel-adapter
次のように使用する場合、それは可能ではないようです。
// Below creates a default direct-channel (spring-integration channel) named "adapter", to receive poll this channel which is same as above
<int-amqp:inbound-channel-adapter id="adapter" listener-container="amqpListenerContainer" />
<bean id="amqpListenerContainer" class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="queueNames" value="durableQ" />
<property name="acknowledgeMode" value="MANUAL" />
// messageListener not allowed when using with adapter, so no way of having own ChannelAwareMessageListener, so no channel exposed onMessage, hence no way to ack
<property name="messageListener" ref="listener"/>
</bean>
<bean id="listener" class="com.sd.springint.rmq.MsgListener"/>
プロパティが許可されていないため、上記の構成ではエラーがスローされmessageListener
ます。タグのインライン コメントを参照してください。そのため、使用目的が無効になりました(を介しlistner-container
て公開するため)。channel
ChannelAwareMessageListener
私spring-integration
には使用できませんmanual-acknowledgement
(私は知っています、これは難しい言い方です!)、誰かがこれを検証するのを手伝ってくれますか、またはこれに必要な特定のアプローチ/構成がありませんか?