WSO2 esb 作为具有故障转移传输超时的 jms 生产者
WSO2 esb as a jms producer with failover transport timeout
使用 wso2 esb 4.9.0,我想要一个 HTTP api 在 JMS 队列 (activemq) 中推送消息。 jms 发送应该使用故障转移,但是如果 none 个 activemq 代理可用,它应该在超时后执行故障序列(例如 15 秒)(在故障序列中,应该将 http 响应发送到原始客户端带有 http 错误代码 500 和 JSON 主体)
我尝试将以下 url 用于我的 activemq 连接工厂:
<parameter name="java.naming.provider.url" locked="false">failover:(tcp://localhost:61616)?timeout=3000</parameter>
我也尝试在我的 api.xml 中的 uri 中设置超时参数(省略其他参数):
<send>
<endpoint>
<address uri="jms:/MyQueue?java.naming.provider.url=failover:(tcp://localhost:616161)?timeout=3000"/>
</endpoint>
</send>
当我杀死所有 activemq 代理时,我的 api 仍然无限期阻塞:
curl -XPOST -H "Content-Type: application/json" -d '{}' -k "https://localhost:8243/myApi/send"
^C # I have to kill it manually; instead it should return an error
如何使用 wso2 esb 实现它?
有关超时参数的文档,请参阅 activemq 故障转移传输参考:http://activemq.apache.org/failover-transport-reference.html
Notes
Under the Failover transport send operations will, by default, block indefinitely when the broker becomes unavailable. There are two options available for handling this scenario. First, either set a TransportListener directly on the ActiveMQConnectionFactory, so that it is in place before any request that may require a network hop or second, set the timeout option. The timeout option causes the current send operation to fail after the specified timeout.
Example:
failover:(tcp://primary:61616)?timeout=3000
In this example if the connection isn't established the send operation will timeout after 3 seconds. It is important to note that the connection is not killed when a timeout occurs. It is possible, therefore, to resend the affected message(s) later using the same connection once a broker becomes available.
尝试使用
<property name="ClientApiNonBlocking" action="remove" scope="axis2"/>
在发送中介之前。
在我的例子中,这是一个连接创建,因此设置 startupMaxReconnectAttempts=X 允许我在多次重新连接尝试后 "timeout"。使用默认设置(指数退避),X=10 的值在大约 5 秒后超时。所以我用了
<address uri="jms:/MyQueue?java.naming.provider.url=failover:(tcp://localhost:616161)?startupMaxReconnectAttempts=10"/>
使用 wso2 esb 4.9.0,我想要一个 HTTP api 在 JMS 队列 (activemq) 中推送消息。 jms 发送应该使用故障转移,但是如果 none 个 activemq 代理可用,它应该在超时后执行故障序列(例如 15 秒)(在故障序列中,应该将 http 响应发送到原始客户端带有 http 错误代码 500 和 JSON 主体)
我尝试将以下 url 用于我的 activemq 连接工厂:
<parameter name="java.naming.provider.url" locked="false">failover:(tcp://localhost:61616)?timeout=3000</parameter>
我也尝试在我的 api.xml 中的 uri 中设置超时参数(省略其他参数):
<send>
<endpoint>
<address uri="jms:/MyQueue?java.naming.provider.url=failover:(tcp://localhost:616161)?timeout=3000"/>
</endpoint>
</send>
当我杀死所有 activemq 代理时,我的 api 仍然无限期阻塞:
curl -XPOST -H "Content-Type: application/json" -d '{}' -k "https://localhost:8243/myApi/send"
^C # I have to kill it manually; instead it should return an error
如何使用 wso2 esb 实现它?
有关超时参数的文档,请参阅 activemq 故障转移传输参考:http://activemq.apache.org/failover-transport-reference.html
Notes
Under the Failover transport send operations will, by default, block indefinitely when the broker becomes unavailable. There are two options available for handling this scenario. First, either set a TransportListener directly on the ActiveMQConnectionFactory, so that it is in place before any request that may require a network hop or second, set the timeout option. The timeout option causes the current send operation to fail after the specified timeout.
Example:
failover:(tcp://primary:61616)?timeout=3000
In this example if the connection isn't established the send operation will timeout after 3 seconds. It is important to note that the connection is not killed when a timeout occurs. It is possible, therefore, to resend the affected message(s) later using the same connection once a broker becomes available.
尝试使用
<property name="ClientApiNonBlocking" action="remove" scope="axis2"/>
在发送中介之前。
在我的例子中,这是一个连接创建,因此设置 startupMaxReconnectAttempts=X 允许我在多次重新连接尝试后 "timeout"。使用默认设置(指数退避),X=10 的值在大约 5 秒后超时。所以我用了
<address uri="jms:/MyQueue?java.naming.provider.url=failover:(tcp://localhost:616161)?startupMaxReconnectAttempts=10"/>