首页 \ 问答 \ 设置重试策略(Setting up a retry policy)

设置重试策略(Setting up a retry policy)

我试图建立一个像这样的重试策略:

<spring:beans>
        <spring:bean id="threadingPolicyTemplate"
            class="org.mule.retry.async.AsynchronousRetryTemplate">
            <spring:constructor-arg index="0">
                <spring:bean id="foreverRetryPolicyTemplate"
                    class="com.Component.ChatConnectionRetryPolicyTemplate">
                    <spring:property name="sleepTime" value="${connector.retryInterval}" />
                </spring:bean>
            </spring:constructor-arg>
        </spring:bean>
    </spring:beans>

    <jdbc:connector name="jdbcConnector" dataSource-ref="SQLServerjdbcDataSource">
        <spring:property name="retryPolicyTemplate" ref="threadingPolicyTemplate"/>
        <jdbc:query key="PollDB"
            value="select * from ofMessageArchive where ID >  #[payload:]" />
    </jdbc:connector>

我在我的流程中使用所述连接器作为出站端点,但我甚至没有看到重试策略被调用。 (我设置了断点,因此并没有调用它们)。

我正在使用某种线程SimpleRetryPolicy (没什么特别的)。

关于此事的另一个问题 - 假设连接器未启动(正在尝试重试策略) - 使用连接器作为端点的流会发生什么?

骡子如何对待这些东西?


I am attempting to set up a retry policy like so:

<spring:beans>
        <spring:bean id="threadingPolicyTemplate"
            class="org.mule.retry.async.AsynchronousRetryTemplate">
            <spring:constructor-arg index="0">
                <spring:bean id="foreverRetryPolicyTemplate"
                    class="com.Component.ChatConnectionRetryPolicyTemplate">
                    <spring:property name="sleepTime" value="${connector.retryInterval}" />
                </spring:bean>
            </spring:constructor-arg>
        </spring:bean>
    </spring:beans>

    <jdbc:connector name="jdbcConnector" dataSource-ref="SQLServerjdbcDataSource">
        <spring:property name="retryPolicyTemplate" ref="threadingPolicyTemplate"/>
        <jdbc:query key="PollDB"
            value="select * from ofMessageArchive where ID >  #[payload:]" />
    </jdbc:connector>

I use said connector as an outbound endpoint in my flow but I don't see the retry policy even being called. (I've set breakpoints and so and they were not called).

I am using some sort of threaded SimpleRetryPolicy (nothing fancy).

One more question regarding the matter - suppose the connector doesn't start up (retry policy is being attempted) - What would happen to a flow which uses the connector as an endpoint??

How does mule treat these things?


原文:https://stackoverflow.com/questions/8049939
更新时间:2021-12-11 17:12

最满意答案

只是快速,脱下袖口的答案。

如何使用.NETReactive Extensions(Rx)

然后,您可以将存储库定义为:

public interface IObservableRepository<T> where T : class
{
    IObservable<T> GetById(int id);
    IObservable<T> GetAll(Func<IQueryable<T>, IQueryable<T>> query);
    IObservable<Unit> InsertOnSubmit(T entity);
    IObservable<Unit> DeleteOnSubmit(T entity);
    IObservable<int> SubmitChanges();
}

所有返回的observable都将包含单个值,但GetAll除外,它将具有零或更多。

Rx世界中的Unit类型void 。 这只是一种不需要定义非通用IObservable接口的方法。

然后你会这样查询:

IObservableRepository<Foo> repo = ...;

var foos = repo.GetAll(ts => ts.Where(t => t.Bar == "Hello"));

foos.Subscribe(foo =>
{
    // Do something asynchronously with each `Foo`.
});

提交可以这样做:

var submit =
    foos
        .Select(foo => repo.InsertOnSubmit(foo)).ToArray()
        .Select(s => repo.SubmitChanges());

submit.Subscribe(result =>
{
    // handle the asynchronous result of submit.
});

这都是基于尝试使存储库方法尽可能接近原始方法,但在Silverlight方面可能需要重构这样的事情:

public interface IObservableRepository<T> where T : class
{
    IObservable<T> GetById(int id);
    IObservable<T[]> GetAll(Func<IQueryable<T>, IQueryable<T>> query);
    IObservable<int> Submit(T[] insertsOrUpdates);
    IObservable<int> Submit(T[] insertsOrUpdates, T[] deletes);
}

现在提交会更好一些:

repo.Submit(foos).Subscribe(result =>
{
    // Handle asynchronous result of submit;
});

就像我说的那样,袖口。 :-)


Just a quick, off the cuff answer.

How about using the Reactive Extensions for .NET (Rx)?

You could then define your repository as:

public interface IObservableRepository<T> where T : class
{
    IObservable<T> GetById(int id);
    IObservable<T> GetAll(Func<IQueryable<T>, IQueryable<T>> query);
    IObservable<Unit> InsertOnSubmit(T entity);
    IObservable<Unit> DeleteOnSubmit(T entity);
    IObservable<int> SubmitChanges();
}

All of the returned observables would contain single values, except for GetAll which would have zero or more.

The Unit type is void in the Rx world. It's just a way of not needing to define a non-generic IObservable interface.

You would then query like so:

IObservableRepository<Foo> repo = ...;

var foos = repo.GetAll(ts => ts.Where(t => t.Bar == "Hello"));

foos.Subscribe(foo =>
{
    // Do something asynchronously with each `Foo`.
});

And submit could be done like this:

var submit =
    foos
        .Select(foo => repo.InsertOnSubmit(foo)).ToArray()
        .Select(s => repo.SubmitChanges());

submit.Subscribe(result =>
{
    // handle the asynchronous result of submit.
});

This is all based on trying to keep the repository methods as close as possible to the original, but it may be worth refactoring on the Silverlight side to something like this:

public interface IObservableRepository<T> where T : class
{
    IObservable<T> GetById(int id);
    IObservable<T[]> GetAll(Func<IQueryable<T>, IQueryable<T>> query);
    IObservable<int> Submit(T[] insertsOrUpdates);
    IObservable<int> Submit(T[] insertsOrUpdates, T[] deletes);
}

Submit would be a bit nicer now:

repo.Submit(foos).Subscribe(result =>
{
    // Handle asynchronous result of submit;
});

Like I said, off the cuff. :-)

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。