Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring:如何配置带有注释的消息传递桥轮询器_Java_Spring_Spring Mvc_Spring Integration_Spring Messaging - Fatal编程技术网

Java Spring:如何配置带有注释的消息传递桥轮询器

Java Spring:如何配置带有注释的消息传递桥轮询器,java,spring,spring-mvc,spring-integration,spring-messaging,Java,Spring,Spring Mvc,Spring Integration,Spring Messaging,我希望能够限制从订阅频道接收的请求。我不使用PollableChannel。我能做一个类似的工作吗 <bridge input-channel="pollable" output-channel="subscribable"> <poller max-messages-per-poll="10"> <interval-trigger interval="5" time-unit="SECONDS"/> </polle

我希望能够限制从订阅频道接收的请求。我不使用PollableChannel。我能做一个类似的工作吗

<bridge input-channel="pollable" output-channel="subscribable">
     <poller max-messages-per-poll="10">
         <interval-trigger interval="5" time-unit="SECONDS"/>
     </poller>
 </bridge>


使用批注?

和桥处理程序

@Bean
@ServiceActivator(inputChannel = "polled", 
        poller = @Poller(fixedRate = "5000", maxMessagesPerPoll = "10"))
public BridgeHandler bridge() {
    BridgeHandler bridge = new BridgeHandler();
    bridge.setOutputChannelName("direct");
    return bridge;
}
……或者干脆

@Bean
@BridgeTo(value = "direct", poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "10"))
public PollableChannel polled() {
    return new QueueChannel();
}

@Bean
public SubscribableChannel direct() {
    return new DirectChannel();
}


和一个桥牌手

@Bean
@ServiceActivator(inputChannel = "polled", 
        poller = @Poller(fixedRate = "5000", maxMessagesPerPoll = "10"))
public BridgeHandler bridge() {
    BridgeHandler bridge = new BridgeHandler();
    bridge.setOutputChannelName("direct");
    return bridge;
}
……或者干脆

@Bean
@BridgeTo(value = "direct", poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "10"))
public PollableChannel polled() {
    return new QueueChannel();
}

@Bean
public SubscribableChannel direct() {
    return new DirectChannel();
}


有点晚了,但我为我的用例找到了一个解决方案:

<int-amqp:inbound-channel-adapter id="inbound-channel" prefetch-count="100"  concurrent-consumers="1" connection-factory="connectionFactory" queue-names="${queue.name}" error-channel="error-channel" />

<int:json-to-object-transformer input-channel="inbound-channel" output-channel="queue-channel" />

<int:channel id="queue-channel">
    <int:queue capacity="100" />
</int:channel>

<int:bridge input-channel="queue-channel" output-channel="outbound-channel">
    <int:poller max-messages-per-poll="100" fixed-delay="1000" />
</int:bridge>

<int:outbound-channel-adapter id="outbound-channel" ref="myServiceBean" method="onMessage" />

说明:

amqp入站通道适配器是可订阅的。A使用“队列样式”通道切换到可轮询通道,并使用网桥执行从队列通道到出站通道的轮询

在我的情况下,我应该配置消息存储或将amqp入站通道适配器的确认模式设置为手动,并自行确认以避免丢失消息


有点晚了,但我为我的用例找到了一个解决方案:

<int-amqp:inbound-channel-adapter id="inbound-channel" prefetch-count="100"  concurrent-consumers="1" connection-factory="connectionFactory" queue-names="${queue.name}" error-channel="error-channel" />

<int:json-to-object-transformer input-channel="inbound-channel" output-channel="queue-channel" />

<int:channel id="queue-channel">
    <int:queue capacity="100" />
</int:channel>

<int:bridge input-channel="queue-channel" output-channel="outbound-channel">
    <int:poller max-messages-per-poll="100" fixed-delay="1000" />
</int:bridge>

<int:outbound-channel-adapter id="outbound-channel" ref="myServiceBean" method="onMessage" />

说明:

amqp入站通道适配器是可订阅的。A使用“队列样式”通道切换到可轮询通道,并使用网桥执行从队列通道到出站通道的轮询

在我的情况下,我应该配置消息存储或将amqp入站通道适配器的确认模式设置为手动,并自行确认以避免丢失消息


关于

我使用第二种方法创建了Bean polled(),但是我没有从频道接收任何消息,我在管理控制台中看到了2条消息。我使用第二种方法创建了Bean polled(),但是我没有从频道接收任何消息,我在管理控制台中看到了2条消息。