私は非常に興味を持っているものの、春の統合をもっとしていますが、私の意見では奇妙な振る舞いがあります。今、それが唯一の可能性がされなければならない、私の理解では春の統合キューチャネルの容量が間違っている
<int:channel id="ticketChannel" datatype="ch.elca.prototype.model.Ticket">
<int:rendezvous-queue/>
</int:channel>
:私も同じ効果を持つランデブー・キューを試してみました
<int:channel id="ticketChannel" datatype="ch.elca.prototype.model.Ticket">
<int:queue capacity="1"/>
</int:channel>
:
私はキューチャンネルを使用して簡単なアプリケーションを持っています1つのメッセージをそのチャネルで一度に移動します。たぶん2、あなたは1つの追加容量があると思う場合。私はそれを読む方法がわかりません。しかし、私はそのチャンネルに4回送ることができます。消費することなく、私には奇妙なビットがあり、それでは容量を理解できません。、以下を参照してください。
主な用途:ここ を私は10枚の切符をストリーミングし、それぞれにopenTicketを呼び出す:
public static void main(final String[] args) throws InterruptedException {
try (ConfigurableApplicationContext context = SpringApplication.run(SassSimulatorApplication2.class, args)) {
final TicketGenerator generator = context.getBean(TicketGenerator.class);
final ProblemReporter reporter = context.getBean(ProblemReporter.class);
generator.createTickets().limit(10).forEach(reporter::openTicket);
context.close();
}
}
ProblemReporter:
public class ProblemReporter {
private volatile QueueChannel channel;
public synchronized void openTicket(final Ticket ticket){
final Message<Ticket> build = TicketMessageBuilder.buildMessage(ticket);
boolean send = channel.send(build);
System.out.println("send: " + send);
System.out.println("getQueueSize: " + channel.getQueueSize());
System.out.println("getSendCount: " + channel.getSendCount());
System.out.println("getReceiveCount: " + channel.getReceiveCount());
System.out.println("getSendErrorCount: " + channel.getSendErrorCount());
System.out.println("getRemainingCapacity: " + channel.getRemainingCapacity());
}
@Value("#{ticketChannel}")
public void setChannel(final QueueChannel channel) {
this.channel = channel;
}
}
アプリケーションを起動すると、私は次のように:
send: true
getQueueSize: 0
getSendCount: 0
getReceiveCount: 0
getSendErrorCount: 0
getRemainingCapacity: 1
send: true
getQueueSize: 0
getSendCount: 0
getReceiveCount: 0
getSendErrorCount: 0
getRemainingCapacity: 1
send: true
getQueueSize: 1
getSendCount: 0
getReceiveCount: 0
getSendErrorCount: 0
getRemainingCapacity: 0
send: true
getQueueSize: 1
getSendCount: 0
getReceiveCount: 0
getSendErrorCount: 0
getRemainingCapacity: 0
私はSpring-Boot 1.3.3、Sprint-Integration 4.2.5.RELEASEを使用しています。また、Spring-Integration 4.1.9でSpring-Boot 1.2.8を試しました。
これは期待された動作ですか?
ありがとうございます。
返信ありがとうございました。私は共有ビーンでは何を意味するのか分かりません。私は上の私の授業でクラスを拡張しました。 @Valueでチャンネルを注入するので、Springによって管理されます。私が偶然の能力を、例えば、 50、その後、私は200にチャンネルを取得します... –
OK。 Springブートアプリケーションのように見えるので、GitHubのどこかで共有すれば素晴らしいでしょう。そして、我々はそれをローカルで演奏します。 –
本当にすみません、私は本当に愚かでした。私は既にトランスフォーマーを持っていたので、彼はすでにチケットを消費していました。とても恥ずかしい、助けてくれてありがとう。 –