小编mle*_*ski的帖子

带有Spring JMS的ActiveMQ - 如何发送NONPERSISTENT消息?

我正在尝试将deliveryMode显式设置为NONPERSISTENT并将其发送到ActiveMQ.

这是我的Spring JMS配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:beans="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jms="http://www.springframework.org/schema/jms"
       xsi:schemaLocation="http://www.springframework.org/schema/jms
      http://www.springframework.org/schema/jms/spring-jms-4.1.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan base-package="com.app" />
    <!-- enable the configuration of jms on annotations -->
    <jms:annotation-driven/>

    <!-- =============================================== -->
    <!-- JMS Common, Define JMS connectionFactory       -->
    <!-- =============================================== -->
    <!-- Activemq connection factory -->
    <bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <!-- brokerURL, You may have different IP or port -->
        <constructor-arg index="0" value="tcp://localhost:61616" />
    </bean>

    <!-- Pooled Spring connection factory -->
    <bean id="connectionFactory"
          class="org.springframework.jms.connection.CachingConnectionFactory">
        <constructor-arg ref="amqConnectionFactory" />
    </bean> …
Run Code Online (Sandbox Code Playgroud)

java spring activemq-classic spring-jms

5
推荐指数
1
解决办法
1993
查看次数

使用Integer.max作为比较器的Java 8 Lambdas max()

我用简单List的示例值写了,我希望流从Stream返回最大值.我知道max()功能需要,Comparator但事实证明,我也可以通过Integer::max(任何人都可以解释我的,为什么?).

此外,程序打印出奇怪的结果,我在"内部"检查它看起来没问题,但在我得到最终结果后 - 它们不准确.

例:

@Test
public void testHowIntegerMaxWorksInStream() {
    List<Integer> list = Arrays.asList(5,3,8);
    Optional<Integer> op = list.stream().max((a, b) -> {
        System.out.println("Input arguments a=" + a + ", b=" + b);

        int max = Integer.max(a, b);
        System.out.println("Returning max(a,b)=" + max);
        return max;
    });
    System.out.println("Optional result=" + op.get());
}
Run Code Online (Sandbox Code Playgroud)

输出:

Input arguments a=5, b=3
Returning max(a,b)=5
Input arguments a=5, b=8
Returning max(a,b)=8 // OK, Integer::max got 8.. but then ...
Optional result=5 // …
Run Code Online (Sandbox Code Playgroud)

java lambda java-8

3
推荐指数
3
解决办法
2354
查看次数

标签 统计

java ×2

activemq-classic ×1

java-8 ×1

lambda ×1

spring ×1

spring-jms ×1