设置重试策略(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
最满意答案
只是快速,脱下袖口的答案。
如何使用.NET的Reactive 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 isvoid
in the Rx world. It's just a way of not needing to define a non-genericIObservable
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. :-)
相关问答
更多-
只需添加Expand(“Customers / Addresses”),即可在服务器上添加更多限制。 像10个扩展实体应该工作,更多可能有问题。 Just add Expand("Customers/Addresses"), you can add more of these, although there's a limit usually on the server. Something like 10 expanded entities should work, more might be probl ...
-
这是一个主观问题,所以这里是一个主观的答案。 IMO,WCF对于简单的RESTful服务的开销太大了。 另一方面,Web API专为RESTful服务而设计。 我和Dave Ward就此达成一致。 查看他的博客了解更多信息。 在WebForms项目中,我一直坚持从ASMX转移到WCF的压力,因为接受WCF的复杂性主要只是使用较少灵活性的JSON序列化给我奖励。 相比之下,我已经开始将我的一些项目从ASMX转换为Web API,并且很高兴Web API替代ASMX。 我相信微软终于找到了ASMX的简单性和WC ...
-
在大多数情况下,它可能是由数据库访问引起的。 所以下面的步骤可能对你有所帮助: 检查您的WCF服务是否可访问。 检查WCF配置中的连接字符串是否正确。 Actually the issue was on setting up endpoint address in web.config file and also as the services was getting deployed in other machine, the URL of the application was getting chan ...
-
我找到了解决问题的方法。 所以在这里,如果有人遇到同样的事情: 而不是来自settings.xml的我的GetMyServiceClient() 。 我初始化了我的服务客户端,如下所示: MyServiceClient client = new MyServiceClient("MyService_CustomBinding"); 参数是我在ServiceReferences.ClientConfig中的绑定,瞧它就像一个魅力! I found the solution for my problem. S ...
-
将WCF RIA服务包括在现有的Silverlight项目中(Including WCF RIA Services to an existing Silverlight Project)[2023-03-13]
打开Silverlight项目配置并添加“WCF RIA服务链接”。 请参阅MSDN 。 Open your Silverlight project configuration and add a "WCF RIA Services link". See MSDN. -
WCF数据服务(WCF Data Services)[2022-03-24]
快速入门从这一步开始: 创建一个ASP.NET Web应用程序。 就创建WCF数据服务而言,这就是关于ASP.NET所需要做的所有事情。 您可能感兴趣的其他与ASP.NET / IIS相关的事情是身份验证和各种配置问题,但是一旦遇到问题,您可以确定它已在Stack Overflow上得到解答。 The quickstart starts with this step: Create an ASP.NET Web application. And as far as creating a WCF Data S ... -
使用OData(也称为WCF数据服务)无法加入数据并不完全正确。 只是LINQ to OData不支持连接语法。 但是,您仍然可以使用Expand方法或仅通过在select子句中指定关系来从多个表的交集中检索结果。 例如,如果你有一个与Phone表有关系的表User,你可以在ctx.User.Expand(“Phone”)...“中写一下”,或者你可以在ctx.User中写一下“来自你{u.Name,u.Phone}“,它将恢复电话收藏。 我不知道任何其他支持查询SQL数据的RESTful LINQ提供程序 ...
-
只是快速,脱下袖口的答案。 如何使用.NET的Reactive Extensions(Rx) ? 然后,您可以将存储库定义为: public interface IObservableRepository
where T : class { IObservable GetById(int id); IObservable GetAll(Func , IQueryable > query); IObservable Inser ... -
我知道VS2010中没有Wcf数据服务模板, 不是项目模板 - 只是一个项目模板(用于ASP.NET网站或Web应用程序)。 WCF DataServices与HTTP紧密耦合,因此它们只在网站/应用程序中有意义。 WCF数据服务通过服务公开实际的表名。 不! 至少不一定。 EF的重点在于,您可以将数据库的实际物理结构与暴露的(概念) 模型分离 。 你可以完全重命名实体,你可以将几个实体映射到一个表上,将实体分成几个表,你可以省略属性 - 你喜欢的任何东西! 乍一看,检查由wcf数据服务公开的类似乎比EF公 ...
-
Silverlight 4安全LOB应用程序 - WCF与WCF Ria服务(Silverlight 4 Secure LOB Application - WCF vs WCF Ria Services)[2023-03-12]
这是我的想法。 (为了完整披露,我在RIA团队工作。) 当您将它们分区为工作单元块时,RIA DomainServices的工作效果最佳。 但是,将数据库关系分开以正确执行此操作可能会非常棘手,而且人们通常会在整个应用程序中使用单个DomainService。 DomainService的大小随着您拥有的表/实体的数量而扩展,因此有时会变得难以处理。 允许客户端上的LINQ暴露不会超出您的服务所暴露的范围。 它实际上只允许客户缩小和整形返回的数据。 如果您担心安全性,RIA会提供可用于保护您的服务的授权属性 ...