首页 \ 问答 \ 通过弹簧集成自动配置ActiveMQ(Autoconfiguration of ActiveMQ with spring integration)

通过弹簧集成自动配置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
更新时间:2022-01-23 13:01

最满意答案

正如其他人所说,1-10级不能很好,因为人们有不同的水平。

Pick A或B方法的问题是它不能保证系统是可传递的(A可以击败B,而是B打败C和C节拍A)。 让非传递比较运算符打破排序算法 。 对于这个例子,对于这个例子,没有选择作为枢轴的字母将被错误地排列在一起。

在任何给定的时间,你想要所有图片的绝对排名(即使其中一些/全部都被绑定)。 除非有人投票,否则您也希望排名不变。

我将使用选择A或B(或领带)方法,但确定类似于用于2玩家游戏(原来象棋)中的排名的Elo评级系统的排名:

Elo玩家评分系统将玩家的比赛记录与对手的比赛记录进行比较,并确定玩家赢得比赛的可能性。 这个概率因子根据每场比赛的结果来确定玩家评分上升或下降的点数。 当一名选手以较高的等级击败一名对手后,玩家的评分上升得比他(或者)打败一个较低评分的玩家(因为玩家应该打败那些评级较低的对手)。

Elo系统:

  1. 所有新玩家的基本等级为1600
  2. WinProbability = 1 /(10 ^((对手的当前评分 - 玩家的电流额定值)/ 400)+ 1)
  3. ScoringPt = 1分,如果他们赢了比赛,0如果他们输了,和0.5的平局。
  4. 玩家的新评级=玩家的老评级+(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:

  1. All new players start out with a base rating of 1600
  2. WinProbability = 1/(10^(( Opponent’s Current Rating–Player’s Current Rating)/400) + 1)
  3. ScoringPt = 1 point if they win the match, 0 if they lose, and 0.5 for a draw.
  4. 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.

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)