通过弹簧集成自动配置ActiveMQ(Autoconfiguration of ActiveMQ with spring integration)
在当前版本中,spring boot还可以在检测到ActiveMQ在类路径上可用时配置ConnectionFactory。 如果存在代理,则会自动启动并配置嵌入式代理。
使用JMSTemplate时似乎也是如此。 如果我想使用弹簧集成自动配置,那么不幸的是这不起作用。 ActiveMQ似乎是在弹簧集成后配置的。 缺少连接工厂的Spring引导报告错误。 我正在使用spring boot版本1.1.4和最新版本的spring集成。
我从spring boot获得了这个堆栈跟踪:
2014-08-08 09:24:21.050 ERROR 6728 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.jms.JmsSendingMessageHandler#0': Cannot create inner bean '(inner bean)#54930080' of type [org.springframework.integration.jms.DynamicJmsTemplate] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#54930080': Cannot resolve reference to bean 'connectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'connectionFactory' is defined at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean( BeanDefinitionValueResolver.java:290) at org.springframework.beans.factory.support.BeanDefinitionValueResolver. resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
对我来说,弹簧启动自动配置中的依赖关系似乎与spring集成和jms模板不一致。 标准JMS自动配置如下所示:
@ConditionalOnClass(JmsTemplate.class) @ConditionalOnBean(ConnectionFactory.class) @EnableConfigurationProperties(JmsProperties.class) @AutoConfigureAfter({ HornetQAutoConfiguration.class, ActiveMQAutoConfiguration.class }) public class JmsAutoConfiguration
Spring集成如下所示:
@Configuration @ConditionalOnClass(EnableIntegration.class) @AutoConfigureAfter(JmxAutoConfiguration.class) public class IntegrationAutoConfiguration {
对于连接工厂和活动mq弹簧集成创建的动态jms模板,不应该至少有某种自动配置。 考虑到弹簧引导参考文档,我期望正确的自动配置与jms弹簧集成?
In current versions spring boot can also configure a ConnectionFactory when it detects that ActiveMQ is available on the classpath. If the broker is present, an embedded broker is started and configured automatically.
This seems to be true when using the JMSTemplate. If I want to use spring integration auto configuration then unfortunately this does not work. ActiveMQ seems to be configured AFTER spring integration. Spring boot reports error for missing connection factory. I am using spring boot version 1.1.4 and most current version of spring integration for this.
I get this stacktrace from spring boot:
2014-08-08 09:24:21.050 ERROR 6728 --- [ main] o.s.boot.SpringApplication : Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.jms.JmsSendingMessageHandler#0': Cannot create inner bean '(inner bean)#54930080' of type [org.springframework.integration.jms.DynamicJmsTemplate] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#54930080': Cannot resolve reference to bean 'connectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'connectionFactory' is defined at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean( BeanDefinitionValueResolver.java:290) at org.springframework.beans.factory.support.BeanDefinitionValueResolver. resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)
For me it seems that the dependencies in spring boot auto configurations are not correct with respect of spring integration and jms template. Standard JMS auto configuration looks like the following:
@ConditionalOnClass(JmsTemplate.class) @ConditionalOnBean(ConnectionFactory.class) @EnableConfigurationProperties(JmsProperties.class) @AutoConfigureAfter({ HornetQAutoConfiguration.class, ActiveMQAutoConfiguration.class }) public class JmsAutoConfiguration
Spring integration looks like the following:
@Configuration @ConditionalOnClass(EnableIntegration.class) @AutoConfigureAfter(JmxAutoConfiguration.class) public class IntegrationAutoConfiguration {
Shouldn't there be at least some kind of auto configuration for the dynamic jms template that spring integration creates regarding connection factory and active mq. Considering the spring boot ref docs I would expect correct auto configuration with jms for spring integration as well?
原文:https://stackoverflow.com/questions/25193079
最满意答案
正如其他人所说,1-10级不能很好,因为人们有不同的水平。
Pick A或B方法的问题是它不能保证系统是可传递的(A可以击败B,而是B打败C和C节拍A)。 让非传递比较运算符打破排序算法 。 对于这个例子,对于这个例子,没有选择作为枢轴的字母将被错误地排列在一起。
在任何给定的时间,你想要所有图片的绝对排名(即使其中一些/全部都被绑定)。 除非有人投票,否则您也希望排名不变。
我将使用选择A或B(或领带)方法,但确定类似于用于2玩家游戏(原来象棋)中的排名的Elo评级系统的排名:
Elo玩家评分系统将玩家的比赛记录与对手的比赛记录进行比较,并确定玩家赢得比赛的可能性。 这个概率因子根据每场比赛的结果来确定玩家评分上升或下降的点数。 当一名选手以较高的等级击败一名对手后,玩家的评分上升得比他(或者)打败一个较低评分的玩家(因为玩家应该打败那些评级较低的对手)。
Elo系统:
- 所有新玩家的基本等级为1600
- WinProbability = 1 /(10 ^((对手的当前评分 - 玩家的电流额定值)/ 400)+ 1)
- ScoringPt = 1分,如果他们赢了比赛,0如果他们输了,和0.5的平局。
- 玩家的新评级=玩家的老评级+(K值*(ScoringPt-玩家的胜率概率))
用图片替换“玩家”,您可以使用一种简单的方式根据公式调整图片评分。 然后,您可以使用这些数字分数执行排名。 (K值在这里是比赛的“等级”,小本地比赛是8-16,大型邀请/区域的比例是24-32,你可以使用像20这样的常数。
使用这种方法,您只需要为每张图片保留一个数字,这比将每张图片的各个排名保留给每个其他图片要少得多的内存密集度。
编辑:根据意见增加了一点肉。
As others have said, ranking 1-10 does not work that well because people have different levels.
The problem with the Pick A-or-B method is that its not guaranteed for the system to be transitive (A can beat B, but B beats C, and C beats A). Having nontransitive comparison operators breaks sorting algorithms. With quicksort, against this example, the letters not chosen as the pivot will be incorrectly ranked against each other.
At any given time, you want an absolute ranking of all the pictures (even if some/all of them are tied). You also want your ranking not to change unless someone votes.
I would use the Pick A-or-B (or tie) method, but determine ranking similar to the Elo ratings system which is used for rankings in 2 player games (originally chess):
The Elo player-rating system compares players’ match records against their opponents’ match records and determines the probability of the player winning the matchup. This probability factor determines how many points a players’ rating goes up or down based on the results of each match. When a player defeats an opponent with a higher rating, the player’s rating goes up more than if he or she defeated a player with a lower rating (since players should defeat opponents who have lower ratings).
The Elo System:
- All new players start out with a base rating of 1600
- WinProbability = 1/(10^(( Opponent’s Current Rating–Player’s Current Rating)/400) + 1)
- ScoringPt = 1 point if they win the match, 0 if they lose, and 0.5 for a draw.
- Player’s New Rating = Player’s Old Rating + (K-Value * (ScoringPt–Player’s Win Probability))
Replace "players" with pictures and you have a simple way of adjusting both pictures' rating based on a formula. You can then perform a ranking using those numeric scores. (K-Value here is the "Level" of the tournament. It's 8-16 for small local tournaments and 24-32 for larger invitationals/regionals. You can just use a constant like 20).
With this method, you only need to keep one number for each picture which is a lot less memory intensive than keeping the individual ranks of each picture to each other picture.
EDIT: Added a little more meat based on comments.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
正如其他人所说,1-10级不能很好,因为人们有不同的水平。 Pick A或B方法的问题是它不能保证系统是可传递的(A可以击败B,而是B打败C和C节拍A)。 让非传递比较运算符打破排序算法 。 对于这个例子,对于这个例子,没有选择作为枢轴的字母将被错误地排列在一起。 在任何给定的时间,你想要所有图片的绝对排名(即使其中一些/全部都被绑定)。 除非有人投票,否则您也希望排名不变。 我将使用选择A或B(或领带)方法,但确定类似于用于2玩家游戏(原来象棋)中的排名的Elo评级系统的排名: Elo玩家评分系统将玩家的 ...
-
由于数组是通过引用传递的,因此您可以像这样使用它: function rankify(obj) { // PHASE 1: get a reference of all the sub-arrays var references = []; for(var key in obj) { // for each key in the object obj obj[key].forEach(function(e) { // for each eleme ...
-
从结果表中选择怎么样? string query = @"SET @rank=0; Select a.Rank from (SELECT player_ID,@rank:=@rank+1 As Rank FROM player_profile ORDER BY HP DESC) a where player_ID=@1"; What about selecting from the resulting table? string query = @"SET @rank=0; Select a. ...
-
您可以使用数组进行拼接和迭代,然后校正范围。 function changeRank(object) { ranks.splice(object.newRank - 1, 0, ranks.splice(object.currentRank - 1, 1)[0]); ranks.forEach(function (a, i) { a.rank = i + 1; }); } var array = [{ id: 1, rank: 2 }, { id: 1 ...
-
如果你想从世界的C#端做到这一点: DataTable dt = new DataTable(); dt.DefaultView.Sort = "ratio DESC"; dt.Columns.Add(new DataColumn("Rank", typeof(int))); int count = 1; foreach (DataRowView dr in dt.DefaultView) { dr["Rank"] = count++; } 每当使用DataTable时,您需要引用dt.Defau ...
-
好像你可以得到某种数字排名系统,然后根据它进行排序。 只需从赢/输运动或象棋中借用算法,并将每个图像比较视为回合。 有人看了,这里有一些类似于Java的算法的示例代码 这是一个可以在python中借用的库 如果您搜索ELO,您将找到几乎任何语言的版本。 获得数字图像排名后,您可以按照自己喜欢的方式对其进行排序。 可能有其他排名算法你可以考虑赢/输比赛,这是我搜索国际象棋排名时的第一个。 Seems like you could just get some kind of numerical ranking ...
-
使用系列rank方法: In [11]: df.a.rank() Out[11]: 0 4 1 1 2 8 3 10 4 6 5 2 6 3 7 9 8 7 9 5 Name: a, dtype: float64 它有一个相应的升序参数: In [12]: df.a.rank(ascending=False) Out[12]: 0 7 1 10 2 3 3 1 4 5 5 9 6 ...
-
排列的排名(Rank of a Permutation)[2022-05-09]
通过首先简化并递归思考,可以很容易地解决这个问题。 因此,我们首先假设输入序列中的所有元素都是唯一的,然后“唯一”排列集就是一组排列。 现在,为了找到序列a_1, a_2, a_3, ..., a_n在其排列集中的排名,我们可以: 对序列进行排序以获得b_1, b_2, ..., b_n 。 根据定义,这种排列具有等级0 。 现在我们比较a_1和b_1 。 如果它们是相同的,那么我们可以简单地从问题中删除它们: a_1, a_2, ..., a_n的等级将与仅a_2, ..., a_n的等级相同。 否则b_ ...